ruby-openai-swarm 0.5.1 → 0.5.2

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: 326dc0fd2fb1f748c48c67f3f610e7dd3d14911f712e4016ab8cd13a19d6fd6e
4
- data.tar.gz: 4d12edacb8d5daa6fe863daa72a06b1f3cad8ded0c01a2c882995ac8b23e1561
3
+ metadata.gz: 4a304be528163ce02e8b107cf6f1b00187728c0d6d390b7913c93c508b15ce6b
4
+ data.tar.gz: ab3cba71e6e0e512cc8416dc4a55ef72c10a2c9ecf44eb067c25d9caaf9acdad
5
5
  SHA512:
6
- metadata.gz: 584b8772071a78dfdf43eb33f1e3d31c7c0b47618ffe4d766d07bfdd305781975655a8a1c7b9e9dc4f0e6dee8766881ce3e921ac063bff7a2eb6c7f4dbc1e1bf
7
- data.tar.gz: 99c9ff59009c4822397299566a19b0ac07d02d81b47ad03c1449dd7700ca3e9ed5ea62ec1d75223fb1f6ef1c27d44efe93d02717d587527c30c7b41541f2e8b5
6
+ metadata.gz: 5f5eb6c7d2e807f9dea5c87bc62efd7100abd25ec43d76031218c3746f9a0fb5430324330a45da0e8f1ef50cb4236fbc1c47919f3f2d185b5e2ca4989b2ebf86
7
+ data.tar.gz: 013ee84128fa20057fcd6639c29a078ca5364299330c3838ad107a8ae9a49b0592cd64dd4c4f3326825b323e954c0f78e3dd15a643ccb7d7850c9c6e24bf072b
@@ -28,7 +28,7 @@ module OpenAISwarm
28
28
  # )
29
29
  # end
30
30
 
31
- def get_chat_completion(agent_tracker, history, context_variables, model_override, stream, debug)
31
+ def get_chat_completion(agent_tracker, history, context_variables, model_override, stream, debug, metadata = nil)
32
32
  agent = agent_tracker.current_agent
33
33
  context_variables = context_variables.dup
34
34
  instructions = agent.instructions.respond_to?(:call) ? agent.instructions.call(context_variables) : agent.instructions
@@ -56,6 +56,11 @@ module OpenAISwarm
56
56
  tools: Util.request_tools_excluded(tools, agent_tracker.tracking_agents_tool_name, agent.strategy.prevent_agent_reentry),
57
57
  }
58
58
 
59
+ # Add metadata if provided
60
+ # Add support for LiteLLM observability with Langfuse
61
+ # See: https://docs.litellm.ai/docs/observability/langfuse_integration
62
+ create_params[:metadata] = metadata if metadata
63
+
59
64
  # TODO: https://platform.openai.com/docs/guides/function-calling/how-do-functions-differ-from-tools
60
65
  # create_params[:functions] = tools unless tools.empty?
61
66
  # create_params[:function_call] = agent.tool_choice if agent.tool_choice
@@ -168,7 +173,7 @@ module OpenAISwarm
168
173
  partial_response
169
174
  end
170
175
 
171
- def run(agent:, messages:, context_variables: {}, model_override: nil, stream: false, debug: false, max_turns: Float::INFINITY, execute_tools: true)
176
+ def run(agent:, messages:, context_variables: {}, model_override: nil, stream: false, debug: false, max_turns: Float::INFINITY, execute_tools: true, metadata: nil)
172
177
  agent_tracker = OpenAISwarm::Agents::ChangeTracker.new(agent)
173
178
  if stream
174
179
  return run_and_stream(
@@ -178,7 +183,8 @@ module OpenAISwarm
178
183
  model_override: model_override,
179
184
  debug: debug,
180
185
  max_turns: max_turns,
181
- execute_tools: execute_tools
186
+ execute_tools: execute_tools,
187
+ metadata: metadata
182
188
  )
183
189
  end
184
190
 
@@ -197,7 +203,8 @@ module OpenAISwarm
197
203
  context_variables,
198
204
  model_override,
199
205
  stream,
200
- debug
206
+ debug,
207
+ metadata
201
208
  )
202
209
 
203
210
  message = completion.dig('choices', 0, 'message') || {}
@@ -237,7 +244,7 @@ module OpenAISwarm
237
244
  end
238
245
 
239
246
  # TODO(Grayson): a lot of copied code here that will be refactored
240
- def run_and_stream(agent:, messages:, context_variables: {}, model_override: nil, debug: false, max_turns: Float::INFINITY, execute_tools: true)
247
+ def run_and_stream(agent:, messages:, context_variables: {}, model_override: nil, debug: false, max_turns: Float::INFINITY, execute_tools: true, metadata: nil)
241
248
  agent_tracker = OpenAISwarm::Agents::ChangeTracker.new(agent)
242
249
  active_agent = agent
243
250
  context_variables = context_variables.dup
@@ -255,7 +262,8 @@ module OpenAISwarm
255
262
  context_variables,
256
263
  model_override,
257
264
  true, # stream
258
- debug
265
+ debug,
266
+ metadata
259
267
  )
260
268
 
261
269
  yield({ delim: "start" }) if block_given?
@@ -1,3 +1,3 @@
1
1
  module OpenAISwarm
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  end
22
22
 
23
23
  spec.require_paths = ["lib"]
24
- spec.add_dependency "ruby-openai", "~> 7.3"
24
+ spec.add_dependency "ruby-openai", ">= 7.3", "< 9.0"
25
25
  spec.add_dependency "ostruct"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  spec.add_development_dependency "rake", "~> 13.0"
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-openai-swarm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grayson Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-03 00:00:00.000000000 Z
11
+ date: 2025-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '7.3'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '9.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '7.3'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '9.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: ostruct
29
35
  requirement: !ruby/object:Gem::Requirement