dspy-openai 1.0.2 → 1.0.3

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: e1d8fbfeab5565e4ef4847257b2e82aca7468beb11b5c3e179504fef3669ffb3
4
- data.tar.gz: 95b61be39388a3cf2acfd7d74b397ec1b24dac2343932e6476830b870fbb3e88
3
+ metadata.gz: 40eb2bc2c132320aa8d90a64c64601dba7c4b711355f640c1aa5b92020b56699
4
+ data.tar.gz: b501f4eb22ec635b0be129602ed84fc20340b009d83251ba479379a970267b2f
5
5
  SHA512:
6
- metadata.gz: ac0af9799be8627cab6f81127a3c15807bf884ad93cdc912342caae1c95b1f61d337df59cbaf84879c05ea8d5d8f6c5ad560a590807a604c591b247f8ff3f5a0
7
- data.tar.gz: 662a5b2430a3eeaad636e4b7adeeedb32b657c367a49d6ad863ef0808bd4b27fd8a5793649e2fea3300812822455fbd9a03652830dbdd16ecb9b292b12c0217a
6
+ metadata.gz: 559d3f26f3e63a93048763151e7c542e52d0a0da29380805cedb3894579bc708fbbdd3c6ea5e748a06e80ea9746e0c12081ad8e08d8b25d966c7109ddb3c3727
7
+ data.tar.gz: 13de448698cde83f428400cb7cf24b81ee582eeedd13ba046f1db98572cd23305a0ac2c7dc9aad84322083a424570a8a30c12e5113998e43d8ab2f2d44869ecf
data/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  **Build reliable LLM applications in idiomatic Ruby using composable, type-safe modules.**
10
10
 
11
11
  DSPy.rb is the Ruby port of Stanford's [DSPy](https://dspy.ai). Instead of wrestling with brittle prompt strings, you define typed signatures and let the framework handle the rest. Prompts become functions. LLM calls become predictable.
12
+ The `1.x` line is the stable release track for production Ruby LLM applications.
12
13
 
13
14
  ```ruby
14
15
  require 'dspy'
@@ -137,26 +138,18 @@ result.answer # => "60 km/h"
137
138
  Build agents that use tools to accomplish tasks:
138
139
 
139
140
  ```ruby
140
- class SearchTool < DSPy::Tools::Tool
141
+ class SearchTool < DSPy::Tools::Base
141
142
  tool_name "search"
142
- description "Search for information"
143
-
144
- input do
145
- const :query, String
146
- end
147
-
148
- output do
149
- const :results, T::Array[String]
150
- end
143
+ tool_description "Search for information"
151
144
 
145
+ sig { params(query: String).returns(String) }
152
146
  def call(query:)
153
147
  # Your search implementation
154
- { results: ["Result 1", "Result 2"] }
148
+ "Result 1, Result 2"
155
149
  end
156
150
  end
157
151
 
158
- toolset = DSPy::Tools::Toolset.new(tools: [SearchTool.new])
159
- agent = DSPy::ReAct.new(signature: ResearchTask, tools: toolset, max_iterations: 5)
152
+ agent = DSPy::ReAct.new(ResearchTask, tools: [SearchTool.new], max_iterations: 5)
160
153
  result = agent.call(question: "What's the latest on Ruby 3.4?")
161
154
  ```
162
155
 
@@ -185,8 +178,8 @@ result = agent.call(question: "What's the latest on Ruby 3.4?")
185
178
  A [Claude Skill](https://github.com/vicentereig/dspy-rb-skill) is available to help you build DSPy.rb applications:
186
179
 
187
180
  ```bash
188
- # Claude Code
189
- git clone https://github.com/vicentereig/dspy-rb-skill ~/.claude/skills/dspy-rb
181
+ # Claude Code — install from the vicentereig/engineering marketplace
182
+ claude install-skill vicentereig/engineering --skill dspy-rb
190
183
  ```
191
184
 
192
185
  For Claude.ai Pro/Max, download the [skill ZIP](https://github.com/vicentereig/dspy-rb-skill/archive/refs/heads/main.zip) and upload via Settings > Skills.
@@ -201,7 +194,7 @@ The [examples/](examples/) directory has runnable code for common patterns:
201
194
  - Prompt optimization
202
195
 
203
196
  ```bash
204
- bundle exec ruby examples/first_predictor.rb
197
+ bundle exec ruby examples/basic_search_agent.rb
205
198
  ```
206
199
 
207
200
  ## Optional Gems
@@ -5,9 +5,6 @@ require_relative '../schema_converter'
5
5
  require 'dspy/lm/vision_models'
6
6
  require 'dspy/lm/adapter'
7
7
 
8
- require 'dspy/openai/guardrails'
9
- DSPy::OpenAI::Guardrails.ensure_openai_installed!
10
-
11
8
  module DSPy
12
9
  module OpenAI
13
10
  module LM
@@ -26,7 +23,9 @@ module DSPy
26
23
  # Validate vision support if images are present
27
24
  if contains_images?(normalized_messages)
28
25
  DSPy::LM::VisionModels.validate_vision_support!('openai', model)
29
- # Convert messages to OpenAI format with proper image handling
26
+ end
27
+
28
+ if contains_media?(normalized_messages)
30
29
  normalized_messages = format_multimodal_messages(normalized_messages, 'openai')
31
30
  end
32
31
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module DSPy
4
4
  module OpenAI
5
- VERSION = '1.0.2'
5
+ VERSION = '1.0.3'
6
6
  end
7
7
  end
data/lib/dspy/openai.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'dspy/openai/version'
4
-
5
- require 'dspy/openai/guardrails'
6
- DSPy::OpenAI::Guardrails.ensure_openai_installed!
4
+ require 'dspy/support/openai_sdk_warning'
7
5
 
8
6
  require 'dspy/openai/lm/adapters/openai_adapter'
9
7
  require 'dspy/openai/lm/adapters/ollama_adapter'
10
8
  require 'dspy/openai/lm/adapters/openrouter_adapter'
11
9
  require 'dspy/openai/lm/schema_converter'
10
+
11
+ DSPy::Support::OpenAISDKWarning.warn_if_community_gem_loaded!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dspy-openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vicente Reig Rincón de Arellano
@@ -15,28 +15,40 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '0.30'
18
+ version: 0.30.1
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
22
25
  requirements:
23
26
  - - ">="
24
27
  - !ruby/object:Gem::Version
25
- version: '0.30'
28
+ version: 0.30.1
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '2.0'
26
32
  - !ruby/object:Gem::Dependency
27
33
  name: openai
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
30
36
  - - ">="
31
37
  - !ruby/object:Gem::Version
32
- version: '0'
38
+ version: 0.57.0
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.0'
33
42
  type: :runtime
34
43
  prerelease: false
35
44
  version_requirements: !ruby/object:Gem::Requirement
36
45
  requirements:
37
46
  - - ">="
38
47
  - !ruby/object:Gem::Version
39
- version: '0'
48
+ version: 0.57.0
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '1.0'
40
52
  description: Provides the OpenAI plus the Ollama and OpenRouter adapters so OpenAI-compatible
41
53
  providers can be added to DSPy.rb projects independently of the core gem.
42
54
  email:
@@ -49,7 +61,6 @@ files:
49
61
  - README.md
50
62
  - lib/dspy/openai.rb
51
63
  - lib/dspy/openai/README.md
52
- - lib/dspy/openai/guardrails.rb
53
64
  - lib/dspy/openai/lm/adapters/ollama_adapter.rb
54
65
  - lib/dspy/openai/lm/adapters/openai_adapter.rb
55
66
  - lib/dspy/openai/lm/adapters/openrouter_adapter.rb
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'dspy/lm/errors'
4
-
5
- module DSPy
6
- module OpenAI
7
- class Guardrails
8
- SUPPORTED_OPENAI_VERSIONS = "~> 0.17".freeze
9
-
10
- def self.ensure_openai_installed!
11
- require 'openai'
12
-
13
- spec = Gem.loaded_specs["openai"]
14
- unless spec && Gem::Requirement.new(SUPPORTED_OPENAI_VERSIONS).satisfied_by?(spec.version)
15
- msg = <<~MSG
16
- DSPY requires the official `openai` gem #{SUPPORTED_OPENAI_VERSIONS}.
17
- Please install or upgrade it with `bundle add openai --version "#{SUPPORTED_OPENAI_VERSIONS}"`.
18
- MSG
19
- raise DSPy::LM::UnsupportedVersionError, msg
20
- end
21
-
22
- if Gem.loaded_specs["ruby-openai"]
23
- msg = <<~MSG
24
- DSPy uses the official `openai` gem.
25
- Please remove the `ruby-openai` gem to avoid namespace conflicts.
26
- MSG
27
- raise DSPy::LM::MissingOfficialSDKError, msg
28
- end
29
- end
30
- end
31
- end
32
- end