ruby-openai-swarm 0.2.4 → 0.2.5

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: ef97e65185db604611e9a15e4e5a3dcf3b35eb38e8c87e54040175f1947280b8
4
- data.tar.gz: cac5ea7cad0afc755fd528e39e5f77c10db1ecbda43d94b4021863d6f1ac5cea
3
+ metadata.gz: cbea41bea26f5e39c1441ed97500e665d40a690d70e7e1808b860a45acafd748
4
+ data.tar.gz: 7bb5230432bd503ff5e6a6cd263d75acd2070846cc6df75442519cf35fd9ade8
5
5
  SHA512:
6
- metadata.gz: 80460e88514e6e117d11de243ddb44f3d412b6c009f6d5ace6f18e82c615fef54f6ccab33e0e0ebb1ec0b9a2d762a2011ed8bef48dc3d0afaf6dd908eb07d331
7
- data.tar.gz: 101d70a78daa2d7f2be6917b23aaa81ff0c6e76d37d6a49d5405af7983fd2ba19f974ef6620fec79b4899644a6b8c4d208b45df9292aee834456f6fea57bee6e
6
+ metadata.gz: 1763ee7808957a4ae784681f6505c227af4dcadaddde476447dc0dd6837f64d6106e9b91f6b50be9fc3dc0b1da948c579a2850db4f4cd1b0843eaa6227c88333
7
+ data.tar.gz: 07fc02cfef9035871e28726171d8f4de803332fa38be5d0964c985ee71b8473317f21dc2a839fad281c805a3822de890907113e9cf683db470987babce22a7ee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-openai-swarm (0.2.4)
4
+ ruby-openai-swarm (0.2.5)
5
5
  ruby-openai (~> 7.3)
6
6
 
7
7
  GEM
@@ -65,4 +65,4 @@ params:
65
65
  GUIDE_EXAMPLES
66
66
  puts guide_examples
67
67
 
68
- OpenAISwarm::Repl.run_demo_loop(triage_agent, context_variables: context_variables, stream: true, debug: env_debug)
68
+ OpenAISwarm::Repl.run_demo_loop(triage_agent, context_variables: context_variables, debug: env_debug)
@@ -46,7 +46,6 @@ Details:
46
46
  Example: “What’s the weather in NYC?”
47
47
  Action: Calls get_weather with location “New York City”.
48
48
  Response: Only provides weather details.
49
-
50
49
  2. Multiple Function Calls
51
50
  Example: “Tell me the weather in New York and the latest news headlines.”
52
51
  Action: Calls get_weather for weather and get_news for news.
@@ -59,19 +58,4 @@ GUIDE_EXAMPLES
59
58
 
60
59
  puts guide_examples
61
60
 
62
- # OpenAISwarm::Repl.run_demo_loop(agent, stream: true, debug: env_debug)
63
-
64
- OpenAISwarm.new.run_and_stream(
65
- agent: agent,
66
- debug: true,
67
- messages: [{"role" => "user", "content" => "Tell me the weather in New York and the latest news headlines."}]
68
- ) do |chunk|
69
- if chunk.key?("content") && !chunk["content"].nil?
70
- puts ">>>#{chunk}"
71
- end
72
-
73
- if chunk.key?('response')
74
- binding.pry
75
- # log_llm_request(chunk['response'])
76
- end
77
- end
61
+ OpenAISwarm::Repl.run_demo_loop(agent, stream: true, debug: env_debug)
@@ -1,10 +1,13 @@
1
1
  module OpenAISwarm
2
2
  class FunctionDescriptor
3
- attr_reader :target_method, :description
3
+ attr_reader :target_method,
4
+ :description,
5
+ :parameters
4
6
 
5
- def initialize(target_method:, description: '')
7
+ def initialize(target_method:, description: '', parameters: nil)
6
8
  @target_method = target_method.is_a?(Method) ? target_method : method(target_method)
7
9
  @description = description
10
+ @parameters = parameters
8
11
  end
9
12
  end
10
13
  end
@@ -52,6 +52,7 @@ module OpenAISwarm
52
52
  def self.function_to_json(func_instance)
53
53
  is_target_method = func_instance.respond_to?(:target_method) || func_instance.is_a?(OpenAISwarm::FunctionDescriptor)
54
54
  func = is_target_method ? func_instance.target_method : func_instance
55
+ custom_parameters = is_target_method ? func_instance.parameters : nil
55
56
 
56
57
  function_name = func.name
57
58
  function_parameters = func.parameters
@@ -82,16 +83,18 @@ module OpenAISwarm
82
83
 
83
84
  description = func_instance.respond_to?(:description) ? func_instance&.description : nil
84
85
 
86
+ json_parameters = {
87
+ type: "object",
88
+ properties: parameters,
89
+ required: required
90
+ }
91
+
85
92
  {
86
93
  type: "function",
87
94
  function: {
88
95
  name: function_name,
89
96
  description: description || '',
90
- parameters: {
91
- type: "object",
92
- properties: parameters,
93
- required: required
94
- }
97
+ parameters: custom_parameters || json_parameters
95
98
  }
96
99
  }
97
100
  end
@@ -1,3 +1,3 @@
1
1
  module OpenAISwarm
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-openai-swarm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grayson