i have a use case where i have a csv and a text file .
the csv holds the raw data and the text file explains the business process that the csv represent.
i want to inject both sources as tools for a wrapper agent, that will answer the client questions. this is how i defined the tools:
tools = [
Tool(
name='process_info',
func=process_chain.run,
description=desc_process
),
Tool(
name='csv-chain',
func=csv_agent.run,
description=description)
]
then, i define the wrapper agent:
llm_chain = LLMChain(llm=llm, prompt=prompt)
tool_names = [tool.name for tool in tools]
agent = LLMSingleActionAgent(
llm_chain=llm_chain,
output_parser=output_parser,
stop=["\nObservation:"],
allowed_tools=tool_names
)
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools,
verbose=True)
agent_executor.run("which test had the biggest drop in value")
the output indicates that it couldn't reach the actual csv data.
Action: csv-chain
Action Input:
- File path to the CSV file containing the value data
- Calculate the difference between each test's value and the overall value
- Sort the tests by the difference in descending order
> Entering new AgentExecutor chain...
Thought: I need to read the CSV file into a pandas dataframe and then calculate the
difference between each test's value and the overall value. Finally, I need to sort
the tests by the difference in descending order.
Action: python_repl_ast
Action Input:
```
import pandas as pd
# read the CSV file into a pandas dataframe
df = pd.read_csv('file_path_to_csv')
# calculate the overall value
overall_value = df['value'].mean()
#calculate the difference between each test's value and the overall value
df['value_difference'] = df['value'] - overall_value
# sort the tests by the difference in descending order
df_sorted = df.sort_values(by='value_difference', ascending=False)
```
Observation: FileNotFoundError: [Errno 2] No such file or directory:
'file_path_to_csv'
but when i use the actual tool as :
csv_agent.run("what is the average value")
it answers correctly:
> Entering new AgentExecutor chain...
Thought: Use the `mean()` function to calculate the average value
Action: python_repl_ast
Action Input: df['value'].mean()
Observation: 0.58463
Thought:The average value is 0.58463
Final Answer: 0.58463
> Finished chain.
0.58463