Spaces:
Build error
Build error
Create utils.py
Browse files
utils.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
df = pd.read_csv(data)
|
| 8 |
+
|
| 9 |
+
llm = OpenAI()
|
| 10 |
+
|
| 11 |
+
agent = create_pandas_dataframe_agent(llm,df,verbose = True)
|
| 12 |
+
|
| 13 |
+
return agent.run(query)
|
| 14 |
+
|