Class: DSPy::HistoryEntry

Inherits:
T::Struct
  • Object
show all
Defined in:
lib/dspy/re_act.rb

Overview

Define a simple struct for history entries with proper type annotations

Instance Method Summary collapse

Instance Method Details

#to_hObject

Custom serialization to ensure compatibility with the rest of the code Note: We don’t use .compact here to ensure tool_input is always present as a key, even when nil, for consistent history entry structure



26
27
28
29
30
31
32
33
34
# File 'lib/dspy/re_act.rb', line 26

def to_h
  {
    step: step,
    thought: thought,
    action: action,
    tool_input: tool_input,
    observation: observation
  }
end