helicone-rb 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/helicone/agent.rb +9 -21
- data/lib/helicone/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a118f742137f788207fb3e4b724ec2420884ef5610776d1437385cd2fa963649
|
|
4
|
+
data.tar.gz: 44b4d16c5295b974afa28d2b9f694bf0c2b0cb95ba810826eaa5a72b141cd1e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b689d259dbc4f8b583a62d5b95e84053aa58f41d594cf03fb5b681dc10d180e4d3ab5d86844d9875821c3d6b8c3270ff7e5faf5660c89501a8e72e8e7bf9d1b0
|
|
7
|
+
data.tar.gz: 6aa3ef6dda08bccd058deb550c23a0059693f759476b8394fa0d0c5f24497475decd2beb81a7f5818c6a58e243b8d8484bda22e405fcd965ae602bd789451904
|
data/lib/helicone/agent.rb
CHANGED
|
@@ -4,7 +4,7 @@ module Helicone
|
|
|
4
4
|
class Agent
|
|
5
5
|
MAX_ITERATIONS = 10
|
|
6
6
|
|
|
7
|
-
attr_reader :client, :tools, :messages, :context, :
|
|
7
|
+
attr_reader :client, :tools, :messages, :context, :model
|
|
8
8
|
|
|
9
9
|
# Create an agent with tools and optional context
|
|
10
10
|
#
|
|
@@ -14,14 +14,12 @@ module Helicone
|
|
|
14
14
|
# @param context [Object] Context object passed to tool#initialize
|
|
15
15
|
# @param system_prompt [String] System prompt
|
|
16
16
|
# @param messages [Array<Helicone::Message>] Initial messages (for continuing conversations)
|
|
17
|
-
# @param
|
|
18
|
-
|
|
19
|
-
def initialize(client: nil, session: nil, tools: [], context: nil, system_prompt: nil, messages: [], turn_model: nil, response_model: nil)
|
|
17
|
+
# @param model [String] Model to use (defaults to Helicone.configuration.default_model)
|
|
18
|
+
def initialize(client: nil, session: nil, tools: [], context: nil, system_prompt: nil, messages: [], model: nil)
|
|
20
19
|
@client = client || build_client(session: session)
|
|
21
20
|
@tools = tools
|
|
22
21
|
@context = context
|
|
23
|
-
@
|
|
24
|
-
@response_model = response_model || turn_model
|
|
22
|
+
@model = model
|
|
25
23
|
@messages = messages.dup
|
|
26
24
|
|
|
27
25
|
# Add system message at the start if provided and not already present
|
|
@@ -40,7 +38,7 @@ module Helicone
|
|
|
40
38
|
|
|
41
39
|
iterations = 0
|
|
42
40
|
while iterations < max_iterations
|
|
43
|
-
response = call_llm
|
|
41
|
+
response = call_llm
|
|
44
42
|
|
|
45
43
|
tool_calls = response.tool_calls
|
|
46
44
|
if tool_calls && !tool_calls.empty?
|
|
@@ -59,17 +57,7 @@ module Helicone
|
|
|
59
57
|
|
|
60
58
|
iterations += 1
|
|
61
59
|
else
|
|
62
|
-
# No tool calls -
|
|
63
|
-
if @response_model && @response_model != @turn_model
|
|
64
|
-
final_response = @client.chat(messages: @messages, model: @response_model)
|
|
65
|
-
return AgentResult.new(
|
|
66
|
-
content: final_response.content,
|
|
67
|
-
messages: @messages,
|
|
68
|
-
iterations: iterations,
|
|
69
|
-
response: final_response
|
|
70
|
-
)
|
|
71
|
-
end
|
|
72
|
-
|
|
60
|
+
# No tool calls - we're done
|
|
73
61
|
return AgentResult.new(
|
|
74
62
|
content: response.content,
|
|
75
63
|
messages: @messages,
|
|
@@ -80,7 +68,7 @@ module Helicone
|
|
|
80
68
|
end
|
|
81
69
|
|
|
82
70
|
# Max iterations reached - make one final call without tools to get a response
|
|
83
|
-
final_response = @client.chat(messages: @messages, model: @
|
|
71
|
+
final_response = @client.chat(messages: @messages, model: @model)
|
|
84
72
|
|
|
85
73
|
AgentResult.new(
|
|
86
74
|
content: final_response.content,
|
|
@@ -106,10 +94,10 @@ module Helicone
|
|
|
106
94
|
Helicone.configuration.logger
|
|
107
95
|
end
|
|
108
96
|
|
|
109
|
-
def call_llm
|
|
97
|
+
def call_llm
|
|
110
98
|
@client.chat(
|
|
111
99
|
messages: @messages,
|
|
112
|
-
model: model,
|
|
100
|
+
model: @model,
|
|
113
101
|
tools: tools_for_api,
|
|
114
102
|
tool_choice: "auto"
|
|
115
103
|
)
|
data/lib/helicone/version.rb
CHANGED