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.



164
165
166
167
168
169
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 164

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.



155
156
157
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 155

def config_id
  @config_id
end

#few_shot_examplesObject (readonly)

Returns the value of attribute few_shot_examples.



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

def few_shot_examples
  @few_shot_examples
end

#instructionObject (readonly)

Returns the value of attribute instruction.



146
147
148
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 146

def instruction
  @instruction
end

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
end

Instance Method Details

#to_hObject



172
173
174
175
176
177
178
179
# File 'lib/dspy/teleprompt/mipro_v2.rb', line 172

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