helicone-rb 0.3.0 → 0.3.4
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 +14 -8
- data/lib/helicone/message.rb +3 -4
- 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: ce9db5e8198fb863f8dd612b39b70a6d7b533e88d8a6ba19ec584d411f718541
|
|
4
|
+
data.tar.gz: 9ade07a85413d98df255a94b56099610c468d7644ace498392dc38b2799123b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be9bfec349c828c30865d22c32004769b650eca02252fa2401fe097d2fd87ad09711228b8d9980333ded71a6df990b0734ced95b935818c159c238a75502e61d
|
|
7
|
+
data.tar.gz: f3d70faaeffb523d07f329d0919c6c648f610f0b643314842d533dd9c73ab9c5b3c97d405bcf208ebfd2f895c7bf8c104bc475192e476061676d86829d1ae452
|
data/lib/helicone/agent.rb
CHANGED
|
@@ -4,22 +4,25 @@ module Helicone
|
|
|
4
4
|
class Agent
|
|
5
5
|
MAX_ITERATIONS = 10
|
|
6
6
|
|
|
7
|
-
attr_reader :client, :tools, :messages, :context, :model
|
|
7
|
+
attr_reader :client, :tools, :messages, :context, :model, :options
|
|
8
8
|
|
|
9
9
|
# Create an agent with tools and optional context
|
|
10
10
|
#
|
|
11
11
|
# @param client [Helicone::Client] Optional client (creates new one if not provided)
|
|
12
12
|
# @param session [Hash] Session config for Helicone tracking (id:, name:) - creates client if no client provided
|
|
13
|
+
# @param user [Hash] User config for Helicone tracking (id:, name:) - sets Helicone-User-Id header
|
|
13
14
|
# @param tools [Array<Class>] Array of Tool subclasses
|
|
14
15
|
# @param context [Object] Context object passed to tool#initialize
|
|
15
16
|
# @param system_prompt [String] System prompt
|
|
16
17
|
# @param messages [Array<Helicone::Message>] Initial messages (for continuing conversations)
|
|
17
18
|
# @param model [String] Model to use (defaults to Helicone.configuration.default_model)
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
# @param options [Hash] Additional options passed through to chat calls (e.g., reasoning_effort)
|
|
20
|
+
def initialize(client: nil, session: nil, user: nil, tools: [], context: nil, system_prompt: nil, messages: [], model: nil, **options)
|
|
21
|
+
@client = client || build_client(session: session, user: user)
|
|
20
22
|
@tools = tools
|
|
21
23
|
@context = context
|
|
22
24
|
@model = model
|
|
25
|
+
@options = options
|
|
23
26
|
@messages = messages.dup
|
|
24
27
|
|
|
25
28
|
# Add system message at the start if provided and not already present
|
|
@@ -99,7 +102,8 @@ module Helicone
|
|
|
99
102
|
messages: @messages,
|
|
100
103
|
model: @model,
|
|
101
104
|
tools: tools_for_api,
|
|
102
|
-
tool_choice: "auto"
|
|
105
|
+
tool_choice: "auto",
|
|
106
|
+
**@options
|
|
103
107
|
)
|
|
104
108
|
end
|
|
105
109
|
|
|
@@ -136,12 +140,14 @@ module Helicone
|
|
|
136
140
|
@tools.find { |t| t.function_name == name }
|
|
137
141
|
end
|
|
138
142
|
|
|
139
|
-
def build_client(session:)
|
|
140
|
-
return Client.new unless session
|
|
143
|
+
def build_client(session:, user:)
|
|
144
|
+
return Client.new unless session || user
|
|
141
145
|
|
|
142
146
|
Client.new(
|
|
143
|
-
session_id: session
|
|
144
|
-
session_name: session
|
|
147
|
+
session_id: session&.dig(:id),
|
|
148
|
+
session_name: session&.dig(:name),
|
|
149
|
+
account_id: user&.dig(:id),
|
|
150
|
+
account_name: user&.dig(:name)
|
|
145
151
|
)
|
|
146
152
|
end
|
|
147
153
|
end
|
data/lib/helicone/message.rb
CHANGED
|
@@ -114,10 +114,9 @@ module Helicone
|
|
|
114
114
|
# @return [Hash] Message formatted for the API
|
|
115
115
|
def to_h
|
|
116
116
|
if @raw_message
|
|
117
|
-
#
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
hash
|
|
117
|
+
# Return the full raw message to preserve extra_content (thought signatures)
|
|
118
|
+
# and any other provider-specific fields (e.g., Gemini 3 requires thought_signature)
|
|
119
|
+
@raw_message
|
|
121
120
|
else
|
|
122
121
|
hash = { role: role, content: content }
|
|
123
122
|
hash[:tool_call_id] = tool_call_id if tool_call_id
|
data/lib/helicone/version.rb
CHANGED