dspy 0.10.0 → 0.10.1
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 +4 -4
- data/lib/dspy/errors.rb +25 -0
- data/lib/dspy/mixins/instrumentation_helpers.rb +3 -0
- data/lib/dspy/version.rb +1 -1
- data/lib/dspy.rb +18 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b721c6c31be4c7a18cb488a7646ff356d658618a5a64ff36f50be9f731d9755a
|
4
|
+
data.tar.gz: 2e13ea6bf39e6a89872d604f22c7b197bf50924058824ff2a3483d859f1ba744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6966d789e0ebad1e6ee6c65deaef2dec1d67d483908e7c0847df84998b4f167ad346d20de974af7194db890fcccabe38f3b38ab33dde95b430fdcd3b86a6045
|
7
|
+
data.tar.gz: 373e489777b036968ad5152aabc01141212c0409c849d89337075f1b2000de7504b8e2eaccca9755c4e52195b1d05d0667f9e4a8fe54c621cd90ba37b18837b0
|
data/lib/dspy/errors.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DSPy
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
class ConfigurationError < Error
|
7
|
+
def self.missing_lm(module_name)
|
8
|
+
new(<<~MESSAGE)
|
9
|
+
No language model configured for #{module_name} module.
|
10
|
+
|
11
|
+
To fix this, configure a language model either globally:
|
12
|
+
|
13
|
+
DSPy.configure do |config|
|
14
|
+
config.lm = DSPy::LM.new("openai/gpt-4", api_key: ENV["OPENAI_API_KEY"])
|
15
|
+
end
|
16
|
+
|
17
|
+
Or on the module instance:
|
18
|
+
|
19
|
+
module_instance.configure do |config|
|
20
|
+
config.lm = DSPy::LM.new("anthropic/claude-3", api_key: ENV["ANTHROPIC_API_KEY"])
|
21
|
+
end
|
22
|
+
MESSAGE
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -15,6 +15,9 @@ module DSPy
|
|
15
15
|
# Prepares base instrumentation payload for prediction-based modules
|
16
16
|
sig { params(signature_class: T.class_of(DSPy::Signature), input_values: T::Hash[Symbol, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
|
17
17
|
def prepare_base_instrumentation_payload(signature_class, input_values)
|
18
|
+
# Validate LM is configured before accessing its properties
|
19
|
+
raise DSPy::ConfigurationError.missing_lm(self.class.name) if lm.nil?
|
20
|
+
|
18
21
|
{
|
19
22
|
signature_class: signature_class.name,
|
20
23
|
model: lm.model,
|
data/lib/dspy/version.rb
CHANGED
data/lib/dspy.rb
CHANGED
@@ -5,6 +5,7 @@ require 'dry/logger'
|
|
5
5
|
require 'securerandom'
|
6
6
|
|
7
7
|
require_relative 'dspy/version'
|
8
|
+
require_relative 'dspy/errors'
|
8
9
|
|
9
10
|
module DSPy
|
10
11
|
extend Dry::Configurable
|
@@ -145,3 +146,20 @@ require_relative 'dspy/registry/signature_registry'
|
|
145
146
|
require_relative 'dspy/registry/registry_manager'
|
146
147
|
|
147
148
|
# LoggerSubscriber will be lazy-initialized when first accessed
|
149
|
+
|
150
|
+
# Detect potential gem conflicts and warn users
|
151
|
+
# DSPy uses the official openai gem, warn if ruby-openai (community version) is detected
|
152
|
+
if defined?(OpenAI) && defined?(OpenAI::Client) && !defined?(OpenAI::Internal)
|
153
|
+
warn <<~WARNING
|
154
|
+
WARNING: ruby-openai gem detected. This may cause conflicts with DSPy's OpenAI integration.
|
155
|
+
|
156
|
+
DSPy uses the official 'openai' gem. The community 'ruby-openai' gem uses the same
|
157
|
+
OpenAI namespace and will cause conflicts.
|
158
|
+
|
159
|
+
To fix this, remove 'ruby-openai' from your Gemfile and use the official gem instead:
|
160
|
+
- Remove: gem 'ruby-openai'
|
161
|
+
- Keep: gem 'openai' (official SDK that DSPy uses)
|
162
|
+
|
163
|
+
The official gem provides better compatibility and is actively maintained by OpenAI.
|
164
|
+
WARNING
|
165
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dspy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vicente Reig Rincón de Arellano
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/dspy.rb
|
163
163
|
- lib/dspy/chain_of_thought.rb
|
164
164
|
- lib/dspy/code_act.rb
|
165
|
+
- lib/dspy/errors.rb
|
165
166
|
- lib/dspy/evaluate.rb
|
166
167
|
- lib/dspy/example.rb
|
167
168
|
- lib/dspy/few_shot_example.rb
|