Classes
ReflectionProcessor
Processor for reflection-based self-evaluation and improvement.Parameters
Parameter | Type | Default | Description |
---|---|---|---|
config | ReflectionConfig | - | Configuration for reflection process |
Functions
process_with_reflection
Process a task response through reflection and improvement cycles.
Parameters:
agent
(Agent): The main agent that generated the responsetask
(Task): The task being processedinitial_response
(Any): The initial response to evaluate and improve
Any
: The final improved response
_create_evaluator_agent
Create an evaluator agent for reflection.
Parameters:
main_agent
(Agent): The main agent to create evaluator from
Agent
: The evaluator agent
_evaluate_response
Evaluate a response using the evaluator agent.
Parameters:
evaluator
(Agent): The evaluator agenttask
(Task): The task being evaluatedresponse
(str): The response to evaluatestate
(ReflectionState): The current reflection state
EvaluationResult
: The evaluation result
_generate_improved_response
Generate an improved response based on evaluation feedback.
Parameters:
agent
(Agent): The main agenttask
(Task): The task being processedprevious_response
(str): The previous responseevaluation
(EvaluationResult): The evaluation resultstate
(ReflectionState): The current reflection state
Any
: The improved response
_extract_response_text
Extract text representation from response.
Parameters:
response
(Any): The response to extract text from
str
: The extracted text
_convert_to_response_format
Convert improved response back to original format.
Parameters:
response_text
(str): The improved response textoriginal_response
(Any): The original responsetask
(Task): The task being processed
Any
: The converted response
_build_evaluation_context
Build context for evaluation.
Parameters:
task
(Task): The task being evaluatedstate
(ReflectionState): The current reflection state
str
: The evaluation context
_build_improvement_context
Build context for improvement.
Parameters:
task
(Task): The task being processedstate
(ReflectionState): The current reflection state
str
: The improvement context
_create_fallback_evaluation
Create a fallback evaluation when the evaluator fails.
Parameters:
response
(str): The response to evaluateerror
(str): The error message
EvaluationResult
: The fallback evaluation result