Jayavathsan commited on
Commit
a6cb770
·
1 Parent(s): 3f6dbc9

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +17 -0
utils.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.agents import create_pandas_dataframe_agent
2
+ import pandas as pd
3
+ from langchain.llms import OpenAI
4
+
5
+ def query_agent(data, query):
6
+
7
+ # Parse the CSV file and create a Pandas DataFrame from its contents.
8
+ df = pd.read_csv(data)
9
+
10
+ llm = OpenAI()
11
+
12
+ # Create a Pandas DataFrame agent.
13
+ agent = create_pandas_dataframe_agent(llm, df, verbose=True)
14
+
15
+ #Python REPL: A Python shell used to evaluating and executing Python commands.
16
+ #It takes python code as input and outputs the result. The input python code can be generated from another tool in the LangChain
17
+ return agent.run(query)