Class: DSPy::Teleprompt::GEPA::MutationEngine
- Inherits:
-
Object
- Object
- DSPy::Teleprompt::GEPA::MutationEngine
- Extended by:
- T::Sig
- Defined in:
- lib/dspy/teleprompt/gepa.rb
Overview
MutationEngine: Handles LLM-based prompt transformations for genetic evolution
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#instruction_proposer ⇒ Object
readonly
Returns the value of attribute instruction_proposer.
Instance Method Summary collapse
- #batch_mutate(programs, execution_traces: [], failed_examples: []) ⇒ Object
- #emit_event(event_name, data = {}) ⇒ Object
-
#initialize(config:) ⇒ MutationEngine
constructor
A new instance of MutationEngine.
- #mutate_program(program, execution_traces: [], failed_examples: []) ⇒ Object
Constructor Details
#initialize(config:) ⇒ MutationEngine
Returns a new instance of MutationEngine.
1992 1993 1994 1995 |
# File 'lib/dspy/teleprompt/gepa.rb', line 1992 def initialize(config:) @config = config @instruction_proposer = InstructionProposer.new(config: config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
1986 1987 1988 |
# File 'lib/dspy/teleprompt/gepa.rb', line 1986 def config @config end |
#instruction_proposer ⇒ Object (readonly)
Returns the value of attribute instruction_proposer.
1989 1990 1991 |
# File 'lib/dspy/teleprompt/gepa.rb', line 1989 def instruction_proposer @instruction_proposer end |
Instance Method Details
#batch_mutate(programs, execution_traces: [], failed_examples: []) ⇒ Object
2025 2026 2027 2028 2029 |
# File 'lib/dspy/teleprompt/gepa.rb', line 2025 def batch_mutate(programs, execution_traces: [], failed_examples: []) return [] if programs.empty? programs.map { |program| mutate_program(program, execution_traces: execution_traces, failed_examples: failed_examples) } end |
#emit_event(event_name, data = {}) ⇒ Object
2033 2034 2035 2036 |
# File 'lib/dspy/teleprompt/gepa.rb', line 2033 def emit_event(event_name, data = {}) # For now, just a placeholder - could integrate with DSPy event system # In full implementation, this would emit events for monitoring end |
#mutate_program(program, execution_traces: [], failed_examples: []) ⇒ Object
1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 |
# File 'lib/dspy/teleprompt/gepa.rb', line 1999 def mutate_program(program, execution_traces: [], failed_examples: []) return program if rand > @config.mutation_rate begin original_instruction = extract_instruction(program) # Use LLM-based instruction proposal instead of hardcoded mutations improved_instruction = @instruction_proposer.propose_instruction( original_instruction: original_instruction, execution_traces: execution_traces, failed_examples: failed_examples ) create_mutated_program(program, improved_instruction) rescue => e emit_event('mutation_error', { error: e., program_type: program.class.name }) # Return original program on mutation failure program end end |