raiseValueError("Extractor and filling tools are required.")
agent_cls=_get_agent_cls_from_llm(Settings.llm)
extractor_agent=agent_cls(
name="extractor",
description="An agent that extracts missing cells from CSV files and generates questions to fill them.",
tools=[extractor_tool],
system_prompt="""
You are a helpful assistant who extracts missing cells from CSV files.
Only extract missing cells from CSV files and generate questions to fill them.
Always handoff the task to the `researcher` agent after extracting the questions.
""",
llm=Settings.llm,
can_handoff_to=["researcher"],
)
returnworkflow
classInputEvent(Event):
input:List[ChatMessage]
response:bool=False
classExtractMissingCellsEvent(Event):
tool_calls:list[ToolSelection]
classFindAnswersEvent(Event):
tool_calls:list[ToolSelection]
classFillEvent(Event):
tool_calls:list[ToolSelection]
classFormFillingWorkflow(Workflow):
"""
A predefined workflow for filling missing cells in a CSV file.
Required tools:
- query_engine: A query engine to query for the answers to the questions.
- extract_question: Extract missing cells in a CSV file and generate questions to fill them.
- answer_question: Query for the answers to the questions.
Flow:
1. Extract missing cells in a CSV file and generate questions to fill them.
2. Query for the answers to the questions.
3. Fill the missing cells with the answers.
"""
_default_system_prompt="""
You are a helpful assistant who helps fill missing cells in a CSV file.
Only extract missing cells from CSV files.
Only use provided data - never make up any information yourself. Fill N/A if an answer is not found.
If there is no query engine tool or the gathered information has many N/A values indicating the questions don't match the data, respond with a warning and ask the user to upload a different file or connect to a knowledge base.