[Feature Request]: Structured Outputs with Pydantic
Closed this issue · 0 comments
alckasoc commented
Feature Description
Instead of a list of dictionaries (Python native types), we can organize the outputs into Pydantic objects to organize data and attach metadata. Will be useful later.
ATTENTION: Only include the structured outputs for the refactored agents (ReAct, Self-Refine, and CRITIC) for now.
Reason
Here's an example:
class ReflexionCoTOutput(BaseModel):
"""The output of the ReflexionCoT agent.
Attributes:
is_correct (bool): Whether the answer is correct.
answer (str): The generated answer.
thought (str): The thought generated by the agent.
action (str): The action taken by the agent.
observation (str): The observation made by the agent.
"""
is_correct: bool = Field(..., description="Whether the answer is correct.")
answer: str = Field(..., description="The generated answer.")
thought: str = Field(..., description="The thought generated by the agent.")
action: str = Field(..., description="The action taken by the agent.")
observation: str = Field(..., description="The observation made by the agent.")
Additionally, for each agent, for all strategies, the list of dictionaries should have the same keys. For each agent, the agent should have a single Pydantic class that structures all the outputs.