Class: DSPy::Teleprompt::MIPROv2::CandidateConfig

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dspy/teleprompt/mipro_v2.rb

Overview

Candidate configuration for optimization trials

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instruction:, few_shot_examples:, metadata: {}) ⇒ CandidateConfig

Returns a new instance of CandidateConfig.



149
150
151
152
153
154
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 149

def initialize(instruction:, few_shot_examples:, metadata: {})
  @instruction = instruction
  @few_shot_examples = few_shot_examples
  @metadata = .freeze
  @config_id = generate_config_id
end

Instance Attribute Details

#config_idObject (readonly)

Returns the value of attribute config_id.



140
141
142
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 140

def config_id
  @config_id
end

#few_shot_examplesObject (readonly)

Returns the value of attribute few_shot_examples.



134
135
136
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 134

def few_shot_examples
  @few_shot_examples
end

#instructionObject (readonly)

Returns the value of attribute instruction.



131
132
133
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 131

def instruction
  @instruction
end

#metadataObject (readonly)

Returns the value of attribute metadata.



137
138
139
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 137

def 
  @metadata
end

Instance Method Details

#to_hObject



157
158
159
160
161
162
163
164
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 157

def to_h
  {
    instruction: @instruction,
    few_shot_examples: @few_shot_examples.size,
    metadata: @metadata,
    config_id: @config_id
  }
end