Class: DSPy::Teleprompt::MIPROv2::EvaluatedCandidate
- Inherits:
-
Data
- Object
- Data
- DSPy::Teleprompt::MIPROv2::EvaluatedCandidate
- Extended by:
- T::Sig
- Defined in:
- lib/dspy/teleprompt/mipro_v2.rb
Overview
Simple data structure for evaluated candidate configurations (immutable)
Instance Attribute Summary collapse
-
#config_id ⇒ Object
readonly
Returns the value of attribute config_id.
-
#few_shot_examples ⇒ Object
readonly
Returns the value of attribute few_shot_examples.
-
#instruction ⇒ Object
readonly
Returns the value of attribute instruction.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#config_id ⇒ Object (readonly)
Returns the value of attribute config_id
224 225 226 |
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 224 def config_id @config_id end |
#few_shot_examples ⇒ Object (readonly)
Returns the value of attribute few_shot_examples
224 225 226 |
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 224 def few_shot_examples @few_shot_examples end |
#instruction ⇒ Object (readonly)
Returns the value of attribute instruction
224 225 226 |
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 224 def instruction @instruction end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
224 225 226 |
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 224 def end |
#type ⇒ Object (readonly)
Returns the value of attribute type
224 225 226 |
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 224 def type @type end |
Class Method Details
.create(instruction:, few_shot_examples: [], type: CandidateType::Baseline, metadata: {}) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 235 def self.create(instruction:, few_shot_examples: [], type: CandidateType::Baseline, metadata: {}) content = "#{instruction}_#{few_shot_examples.size}_#{type.serialize}_#{metadata.hash}" config_id = Digest::SHA256.hexdigest(content)[0, 12] new( instruction: instruction.freeze, few_shot_examples: few_shot_examples.freeze, type: type, metadata: .freeze, config_id: config_id ) end |
Instance Method Details
#to_h ⇒ Object
249 250 251 252 253 254 255 256 257 |
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 249 def to_h { instruction: instruction, few_shot_examples: few_shot_examples.size, type: type.serialize, metadata: , config_id: config_id } end |