swarm_sdk 2.7.4 → 2.7.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: b5c93c6e9a850d624b8ac0fe9d31e53a4a764a1caa23319efcfa5b34edfd33b8
4
- data.tar.gz: 2d4ec3258101a45507cbacbd98eeb86d8448627e35faedd2a693c0a18d8622a1
3
+ metadata.gz: 6aaba8cabb5957715e88ee02e40e9492fe3546791c806d1ddaff95e967f77aba
4
+ data.tar.gz: 752d15e6e69bb1a9941212d1c33622d678dcc0dc734b88b77a845c7fca4e982b
5
5
  SHA512:
6
- metadata.gz: ac8f8c8dea846e5b0783b49dace5f2e01a0908ebed31eb377fdd4217480e99499fe9eb4bda14772cbfd71d52badc642687434a214f76cf136768c21967e1beff
7
- data.tar.gz: 61a58b209810484c7bcf24727feaa8fb0e23aafc485dbb3ad8a510c095caeaa72778b0e3c97b22eb599a2d9153ef95093dc9aa6a3b34e717b23c4c5d9797b490
6
+ metadata.gz: 36532a008bbb328cddf60bca55d7d8e210b2c0701ca546190164a16067d3878e26c6c4a6d347e9f262669c34289bad7ac0ddd714062a6d4ab9807e0ef5fd9dc5
7
+ data.tar.gz: e7e512794d27d5bd378ea1c96e66f18683cbab8c95e3820672bd74174e0fd5963894958a61aa2e7cf40485c908a7a7adf6a7cbda9d7bfdd480ccd0c3156e4d15
@@ -117,6 +117,9 @@ module SwarmSDK
117
117
  def build_custom_context(provider:, base_url:, timeout:)
118
118
  RubyLLM.context do |config|
119
119
  config.request_timeout = timeout
120
+ # Set read_timeout to match request_timeout for streaming support
121
+ # This ensures long gaps between chunks (model thinking) don't cause timeouts
122
+ config.read_timeout = SwarmSDK.config.llm_read_timeout || timeout
120
123
 
121
124
  configure_provider_base_url(config, provider, base_url) if base_url
122
125
  end
@@ -56,6 +56,15 @@ module SwarmSDK
56
56
  gpustack_api_key: [:gpustack_api_key, "GPUSTACK_API_KEY"],
57
57
  }.freeze
58
58
 
59
+ # RubyLLM connection settings that proxy to RubyLLM.config
60
+ # Maps SwarmSDK config key => [RubyLLM config key, ENV variable, default value]
61
+ RUBYLLM_CONNECTION_MAPPINGS = {
62
+ llm_request_timeout: [:request_timeout, "SWARM_SDK_LLM_REQUEST_TIMEOUT", 300],
63
+ llm_read_timeout: [:read_timeout, "SWARM_SDK_LLM_READ_TIMEOUT", nil], # nil = use request_timeout
64
+ llm_open_timeout: [:open_timeout, "SWARM_SDK_LLM_OPEN_TIMEOUT", 30],
65
+ llm_write_timeout: [:write_timeout, "SWARM_SDK_LLM_WRITE_TIMEOUT", 30],
66
+ }.freeze
67
+
59
68
  # SwarmSDK defaults that can be overridden
60
69
  # Maps config key => [ENV variable, default proc]
61
70
  DEFAULTS_MAPPINGS = {
@@ -152,6 +161,46 @@ module SwarmSDK
152
161
  end
153
162
  end
154
163
 
164
+ # ========== RubyLLM Connection Accessors (with RubyLLM proxying) ==========
165
+
166
+ # @!method llm_request_timeout
167
+ # Get the LLM request timeout (seconds)
168
+ # @return [Integer] The timeout (default: 300)
169
+ #
170
+ # @!method llm_read_timeout
171
+ # Get the LLM read timeout (seconds) - time to wait between chunks
172
+ # @return [Integer, nil] The timeout (nil = use request_timeout)
173
+ #
174
+ # @!method llm_open_timeout
175
+ # Get the LLM connection open timeout (seconds)
176
+ # @return [Integer] The timeout (default: 30)
177
+ #
178
+ # @!method llm_write_timeout
179
+ # Get the LLM write timeout (seconds)
180
+ # @return [Integer] The timeout (default: 30)
181
+
182
+ RUBYLLM_CONNECTION_MAPPINGS.each_key do |config_key|
183
+ ruby_llm_key, _env_key, default_value = RUBYLLM_CONNECTION_MAPPINGS[config_key]
184
+
185
+ # Getter with default fallback
186
+ define_method(config_key) do
187
+ ensure_env_loaded!
188
+ if @explicit_values.key?(config_key)
189
+ @explicit_values[config_key]
190
+ elsif @env_values.key?(config_key)
191
+ @env_values[config_key]
192
+ else
193
+ default_value
194
+ end
195
+ end
196
+
197
+ # Setter with RubyLLM proxying
198
+ define_method("#{config_key}=") do |value|
199
+ @explicit_values[config_key] = value
200
+ RubyLLM.config.public_send("#{ruby_llm_key}=", value)
201
+ end
202
+ end
203
+
155
204
  # ========== Defaults Accessors (with module constant fallback) ==========
156
205
 
157
206
  # @!method default_model
@@ -256,6 +305,18 @@ module SwarmSDK
256
305
  RubyLLM.config.public_send("#{ruby_llm_key}=", value)
257
306
  end
258
307
 
308
+ # Load RubyLLM connection settings and proxy to RubyLLM
309
+ RUBYLLM_CONNECTION_MAPPINGS.each do |config_key, (ruby_llm_key, env_key, _default)|
310
+ next if @explicit_values.key?(config_key)
311
+ next unless ENV.key?(env_key)
312
+
313
+ value = parse_env_value(ENV[env_key], config_key)
314
+ @env_values[config_key] = value
315
+
316
+ # Proxy to RubyLLM
317
+ RubyLLM.config.public_send("#{ruby_llm_key}=", value)
318
+ end
319
+
259
320
  # Load defaults (no RubyLLM proxy)
260
321
  DEFAULTS_MAPPINGS.each do |config_key, (env_key, _default_proc)|
261
322
  next if @explicit_values.key?(config_key)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SwarmSDK
4
- VERSION = "2.7.4"
4
+ VERSION = "2.7.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swarm_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.4
4
+ version: 2.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Arruda
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 1.9.6
74
+ version: 1.9.7
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 1.9.6
81
+ version: 1.9.7
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: ruby_llm_swarm-mcp
84
84
  requirement: !ruby/object:Gem::Requirement