-
Notifications
You must be signed in to change notification settings - Fork 0
/
step2
executable file
·92 lines (79 loc) · 1.68 KB
/
step2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env ruby
require "bundler"
Bundler.require(:default)
Dotenv.load
require_relative "lib/render"
renderer = Render.new
PROMPT = "Who won the Formula 1 2024 Belgian Grand Prix? You can use the Wikipedia for the 2024 Belgian Grand Prix: https://en.m.wikipedia.org/wiki/2024_Belgian_Grand_Prix"
request = <<~JSON
{
"model": "claude-3-5-sonnet",
"messages": [
{
"role": "user",
"content": "#{PROMPT}"
}
],
"tools": [
{
"type": "heroku_tool",
"function": "web_browsing_single_page"
}
],
"tool_choice": "auto"
}
JSON
renderer.heroku_print("Here is the request we are sending to Heroku for inferencing...")
renderer.print_markdown(
<<~MARKDOWN
```json
#{request}
```
MARKDOWN
)
full_request = <<~JSON
{
"model": "claude-3-5-sonnet",
"messages": [
{
"role": "user",
"content": "#{PROMPT}"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "web_browsing_single_page",
"description": "Visits a single URL and returns the content of the web page as Markdown text.",
"parameters": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "The URL to visit"
}
},
"required": [
"url"
]
}
}
}
],
"tool_choice": "auto"
}
JSON
answer = renderer.confirm("Ready to see the full OpenAI-style request?")
exit(0) unless answer
renderer.print_markdown(
<<~MARKDOWN
```json
#{full_request}
```
MARKDOWN
)
answer = renderer.confirm("Ready to send the inference request?")
exit(0) unless answer
renderer.inference_request(request:)
renderer.hr