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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a118f742137f788207fb3e4b724ec2420884ef5610776d1437385cd2fa963649
4
- data.tar.gz: 44b4d16c5295b974afa28d2b9f694bf0c2b0cb95ba810826eaa5a72b141cd1e1
3
+ metadata.gz: ce9db5e8198fb863f8dd612b39b70a6d7b533e88d8a6ba19ec584d411f718541
4
+ data.tar.gz: 9ade07a85413d98df255a94b56099610c468d7644ace498392dc38b2799123b5
5
5
  SHA512:
6
- metadata.gz: b689d259dbc4f8b583a62d5b95e84053aa58f41d594cf03fb5b681dc10d180e4d3ab5d86844d9875821c3d6b8c3270ff7e5faf5660c89501a8e72e8e7bf9d1b0
7
- data.tar.gz: 6aa3ef6dda08bccd058deb550c23a0059693f759476b8394fa0d0c5f24497475decd2beb81a7f5818c6a58e243b8d8484bda22e405fcd965ae602bd789451904
6
+ metadata.gz: be9bfec349c828c30865d22c32004769b650eca02252fa2401fe097d2fd87ad09711228b8d9980333ded71a6df990b0734ced95b935818c159c238a75502e61d
7
+ data.tar.gz: f3d70faaeffb523d07f329d0919c6c648f610f0b643314842d533dd9c73ab9c5b3c97d405bcf208ebfd2f895c7bf8c104bc475192e476061676d86829d1ae452
@@ -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
- def initialize(client: nil, session: nil, tools: [], context: nil, system_prompt: nil, messages: [], model: nil)
19
- @client = client || build_client(session: session)
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[:id],
144
- session_name: session[:name]
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
@@ -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
- # Select only the fields needed for the API
118
- hash = { role: @raw_message[:role], content: @raw_message[:content] }
119
- hash[:tool_calls] = @raw_message[:tool_calls] if @raw_message[:tool_calls]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helicone
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helicone-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genevere