ruby-openai-swarm 0.4.0.1 → 0.4.0.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: 455b72e5872a2f9e11dad1509769c5e3037cef23b3a622337fa419f9c8a2ab20
4
- data.tar.gz: 8f51f50b6ee3de651073783610d26f1394f2fbdb130aa8926b5184af921cfce0
3
+ metadata.gz: 75a68f00ed7c7e975dad8438d4642e42e035bbe05d5f3e3ef8f759536a74af97
4
+ data.tar.gz: 73ec246a79465191f8365064618d7c76832fa3b58148fd60e703f4c3b69b8e11
5
5
  SHA512:
6
- metadata.gz: fc109240efa4af18db7d9d2d60cf9e22fd55c36a9b9845617aa23a3ea912610001c98e0567cd34abd8dcf5e3f1cb86b85b0d474d356023912add3e2c730ad6cf
7
- data.tar.gz: 2d5d5740139edc78c5de1116c41e57397b3fce75f114f0459889c2f49c35846473a38fe35048977a5cecb79cb27d9af7d98c9fce48fa8926666165f6766f1dd3
6
+ metadata.gz: a7b11e67573db5f5197fc137f239f183b0771f9aec067e5f3ba7c4f734145c82bbd9038bfb3a238b6b9b98f58d96c76f61664ef60b875eea516a4d73884b933e
7
+ data.tar.gz: 639c4469e468a6819d7ed7bea1ac19a8ca97e3c160c3bbab066aa377087b0854bc13e0dc82044a1fb12f7c85abb2c545d1baec1baa040feca07e1fa4be9bf021
data/.gitignore CHANGED
@@ -27,7 +27,8 @@ build-iPhoneSimulator/
27
27
  .ruby-version
28
28
  .ruby-gemset
29
29
  /tmp
30
+ Gemfile*.lock
30
31
 
31
32
  # rspec failure tracking
32
33
  .rspec_status
33
- log/openai_swarm.log
34
+ log/openai_swarm.log
data/README.md CHANGED
@@ -16,7 +16,7 @@ A Ruby-based educational framework adapted from OpenAI’s [Swarm](https://githu
16
16
  - [Bundler](#bundler)
17
17
  - [Gem install](#gem-install)
18
18
  - [Logger](#logger)
19
- - [examples](#examples)
19
+ - [Quick start](#quick-start)
20
20
  - [Documentation](#documentation)
21
21
 
22
22
  ## quick show
@@ -86,7 +86,7 @@ def spanish_agent
86
86
  OpenAISwarm::Agent.new(
87
87
  name: "Spanish Agent",
88
88
  instructions: "You only speak Spanish.",
89
- model: "gpt-4o-mini"
89
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL']
90
90
  )
91
91
  end
92
92
 
@@ -98,7 +98,7 @@ transfer_to_spanish_agent = OpenAISwarm::FunctionDescriptor.new(
98
98
  english_agent = OpenAISwarm::Agent.new(
99
99
  name: "English Agent",
100
100
  instructions: "You only speak English.",
101
- model: "gpt-4o-mini",
101
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
102
102
  functions: [transfer_to_spanish_agent]
103
103
  )
104
104
 
@@ -127,9 +127,20 @@ OpenAISwarm.configure do |config|
127
127
  end
128
128
  ```
129
129
 
130
- # Examples
130
+ ## Quick Start
131
131
 
132
- Setting ACCESS_TOKEN for AI Providers in examples
132
+ ### Choose the default model name
133
+
134
+ `export SWARM_AGENT_DEFAULT_MODEL=gpt-4o-mini`
135
+
136
+ or
137
+
138
+ `export SWARM_AGENT_DEFAULT_MODEL=deepseek-chat`
139
+
140
+ DeepSeek V3 is 1/10 price of gpt-4o-mini, so try it!
141
+
142
+
143
+ ### Setting ACCESS_TOKEN for AI Providers in examples
133
144
 
134
145
  - For OpenRouter:
135
146
 
@@ -139,7 +150,11 @@ Setting ACCESS_TOKEN for AI Providers in examples
139
150
 
140
151
  `OPENAI_ACCESS_TOKEN=cxxxxx` or `export OPENAI_ACCESS_TOKEN=cxxxxx`
141
152
 
142
- Check out `/examples` for inspiration! Learn more about each one in its README.
153
+ - For DeepSeek:
154
+
155
+ `DEEPSEEK_ACCESS_TOKEN=cxxxxx` or `export DEEPSEEK_ACCESS_TOKEN=cxxxxx`
156
+
157
+ ### Check out `/examples` for inspiration! Learn more about each one in its README.
143
158
 
144
159
  - [X] [`basic`](examples/basic): Simple examples of fundamentals like setup, function calling, handoffs, and context variables
145
160
  - running: `ruby examples/basic/agent_handoff.rb`
@@ -44,7 +44,7 @@ end
44
44
  # Define agents
45
45
  def triage_agent
46
46
  @triage_agent ||= OpenAISwarm::Agent.new(
47
- model: "gpt-4o-mini",
47
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
48
48
  name: "Triage Agent",
49
49
  instructions: method(:triage_instructions),
50
50
  functions: [
@@ -55,7 +55,7 @@ end
55
55
 
56
56
  def flight_modification
57
57
  @flight_modification ||= OpenAISwarm::Agent.new(
58
- model: "gpt-4o-mini",
58
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
59
59
  name: "Flight Modification Agent",
60
60
  instructions: <<~INSTRUCTIONS,
61
61
  You are a Flight Modification Agent for a customer service airlines company.
@@ -70,7 +70,7 @@ end
70
70
 
71
71
  def flight_cancel
72
72
  @flight_cancel ||= OpenAISwarm::Agent.new(
73
- model: "gpt-4o-mini",
73
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
74
74
  name: "Flight Cancel Traversal",
75
75
  instructions: STARTER_PROMPT + FLIGHT_CANCELLATION_POLICY,
76
76
  functions: [
@@ -85,7 +85,7 @@ end
85
85
 
86
86
  def flight_change
87
87
  @flight_change ||= OpenAISwarm::Agent.new(
88
- model: "gpt-4o-mini",
88
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
89
89
  name: "Flight Change Traversal",
90
90
  instructions: STARTER_PROMPT + FLIGHT_CHANGE_POLICY,
91
91
  functions: [
@@ -100,7 +100,7 @@ end
100
100
 
101
101
  def lost_baggage
102
102
  @lost_baggage ||= OpenAISwarm::Agent.new(
103
- model: "gpt-4o-mini",
103
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
104
104
  name: "Lost Baggage Traversal",
105
105
  instructions: STARTER_PROMPT + LOST_BAGGAGE_POLICY,
106
106
  functions: [
@@ -7,7 +7,7 @@ def spanish_agent
7
7
  OpenAISwarm::Agent.new(
8
8
  name: "Spanish Agent",
9
9
  instructions: "You only speak Spanish.",
10
- model: "gpt-4o-mini"
10
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL']
11
11
  )
12
12
  end
13
13
 
@@ -19,7 +19,7 @@ transfer_to_spanish_agent = OpenAISwarm::FunctionDescriptor.new(
19
19
  english_agent = OpenAISwarm::Agent.new(
20
20
  name: "English Agent",
21
21
  instructions: "You only speak English.",
22
- model: "gpt-4o-mini",
22
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
23
23
  functions: [transfer_to_spanish_agent]
24
24
  )
25
25
 
@@ -6,7 +6,7 @@ client = OpenAISwarm.new
6
6
  agent = OpenAISwarm::Agent.new(
7
7
  name: "Agent",
8
8
  instructions: "You are a helpful agent.",
9
- model: "gpt-4o-mini"
9
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL']
10
10
  )
11
11
  messages = [{"role": "user", "content": "Hi!"}]
12
12
  response = client.run(agent: agent, messages: messages)
@@ -24,7 +24,7 @@ function_instance = OpenAISwarm::FunctionDescriptor.new(
24
24
  agent = OpenAISwarm::Agent.new(
25
25
  name: "Agent",
26
26
  instructions: method(:instructions),
27
- model: "gpt-4o-mini",
27
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
28
28
  functions: [function_instance]
29
29
  )
30
30
 
@@ -27,7 +27,7 @@ get_weather_instance = OpenAISwarm::FunctionDescriptor.new(
27
27
  agent = OpenAISwarm::Agent.new(
28
28
  name: "Agent",
29
29
  instructions: "You are a helpful agent.",
30
- model: "gpt-4o-mini",
30
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
31
31
  functions: [
32
32
  get_weather_instance,
33
33
  get_news_instance
@@ -5,7 +5,7 @@ client = OpenAISwarm.new
5
5
  agent = OpenAISwarm::Agent.new(
6
6
  name: "Agent",
7
7
  instructions: "You are a helpful agent.",
8
- model: "gpt-4o-mini",
8
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
9
9
  )
10
10
 
11
11
  def pretty_print_messages(messages)
@@ -6,6 +6,11 @@ def env_debug
6
6
  end
7
7
 
8
8
  # TODO: refactor it
9
+ OpenAI.configure do |config|
10
+ config.access_token = ENV['DEEPSEEK_ACCESS_TOKEN']
11
+ config.uri_base = "https://api.deepseek.com"
12
+ end if ENV['DEEPSEEK_ACCESS_TOKEN']
13
+
9
14
  OpenAI.configure do |config|
10
15
  config.access_token = ENV['OPEN_ROUTER_ACCESS_TOKEN']
11
16
  config.uri_base = "https://openrouter.ai/api/v1"
@@ -33,7 +33,7 @@ def weather_agent
33
33
  OpenAISwarm::Agent.new(
34
34
  name: "Weather Agent",
35
35
  instructions: "You are a helpful agent.",
36
- model: "gpt-4o-mini",
36
+ model: ENV['SWARM_AGENT_DEFAULT_MODEL'],
37
37
  functions: [
38
38
  function_instance_send_email,
39
39
  function_instance_get_weather
@@ -1,4 +1,5 @@
1
1
  require 'ruby/openai'
2
+ require 'ostruct'
2
3
  begin
3
4
  require 'pry'
4
5
  rescue LoadError
@@ -1,3 +1,3 @@
1
1
  module OpenAISwarm
2
- VERSION = "0.4.0.1"
2
+ VERSION = "0.4.0.2"
3
3
  end
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.require_paths = ["lib"]
24
24
  spec.add_dependency "ruby-openai", "~> 7.3"
25
+ spec.add_dependency "ostruct"
25
26
  spec.add_development_dependency "rspec", "~> 3.0"
26
27
  spec.add_development_dependency "rake", "~> 13.0"
27
28
  spec.add_development_dependency "pry"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-openai-swarm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.1
4
+ version: 0.4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grayson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-26 00:00:00.000000000 Z
11
+ date: 2025-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '7.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ostruct
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -78,7 +92,6 @@ files:
78
92
  - ".gitignore"
79
93
  - ".rspec"
80
94
  - Gemfile
81
- - Gemfile.lock
82
95
  - README.md
83
96
  - Rakefile
84
97
  - assets/logo-swarm.png
@@ -141,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
154
  - !ruby/object:Gem::Version
142
155
  version: '0'
143
156
  requirements: []
144
- rubygems_version: 3.1.4
157
+ rubygems_version: 3.5.3
145
158
  signing_key:
146
159
  specification_version: 4
147
160
  summary: A Ruby implementation of OpenAI function calling swarm
data/Gemfile.lock DELETED
@@ -1,56 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ruby-openai-swarm (0.4.0.1)
5
- ruby-openai (~> 7.3)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- base64 (0.2.0)
11
- coderay (1.1.3)
12
- diff-lcs (1.5.1)
13
- event_stream_parser (1.0.0)
14
- faraday (2.8.1)
15
- base64
16
- faraday-net_http (>= 2.0, < 3.1)
17
- ruby2_keywords (>= 0.0.4)
18
- faraday-multipart (1.1.0)
19
- multipart-post (~> 2.0)
20
- faraday-net_http (3.0.2)
21
- method_source (1.1.0)
22
- multipart-post (2.4.1)
23
- pry (0.14.2)
24
- coderay (~> 1.1)
25
- method_source (~> 1.0)
26
- rake (13.2.1)
27
- rspec (3.13.0)
28
- rspec-core (~> 3.13.0)
29
- rspec-expectations (~> 3.13.0)
30
- rspec-mocks (~> 3.13.0)
31
- rspec-core (3.13.2)
32
- rspec-support (~> 3.13.0)
33
- rspec-expectations (3.13.3)
34
- diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.13.0)
36
- rspec-mocks (3.13.2)
37
- diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.13.0)
39
- rspec-support (3.13.1)
40
- ruby-openai (7.3.1)
41
- event_stream_parser (>= 0.3.0, < 2.0.0)
42
- faraday (>= 1)
43
- faraday-multipart (>= 1)
44
- ruby2_keywords (0.0.5)
45
-
46
- PLATFORMS
47
- ruby
48
-
49
- DEPENDENCIES
50
- pry
51
- rake (~> 13.0)
52
- rspec (~> 3.0)
53
- ruby-openai-swarm!
54
-
55
- BUNDLED WITH
56
- 2.1.4