samim2024 commited on
Commit
c4c4d96
·
verified ·
1 Parent(s): 6bcb8cd

Upload 5 files

Browse files
Files changed (5) hide show
  1. .env +1 -0
  2. .env.example +2 -0
  3. app.py +20 -0
  4. requirements.txt +0 -0
  5. utils.py +20 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ OPENAI_API_KEY="sk-3f8iW6nSTjf2422hgnm9654gh6g4fss5hkluYz7dO98vje4uPCT"
.env.example ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ OPENAI_API_KEY=""
2
+ HUGGINGFACEHUB_API_TOKEN=""
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from dotenv import load_dotenv
3
+ from utils import query_agent
4
+
5
+ load_dotenv()
6
+
7
+
8
+ st.title("Let's do some analysis on your CSV")
9
+ st.header("Please upload your CSV file here:")
10
+
11
+ # Capture the CSV file
12
+ data = st.file_uploader("Upload CSV file",type="csv")
13
+
14
+ query = st.text_area("Enter your query")
15
+ button = st.button("Generate Response")
16
+
17
+ if button:
18
+ # Get Response
19
+ answer = query_agent(data,query)
20
+ st.write(answer)
requirements.txt ADDED
Binary file (332 Bytes). View file
 
utils.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##from langchain.agents import create_pandas_dataframe_agent #This import has been recently replaced by the below
2
+ from langchain_experimental.agents import create_pandas_dataframe_agent
3
+ import pandas as pd
4
+ #from langchain.llms import OpenAI
5
+ #New import from langchain, which replaces the above
6
+ from langchain_openai import OpenAI
7
+
8
+ def query_agent(data, query):
9
+
10
+ # Parse the CSV file and create a Pandas DataFrame from its contents.
11
+ df = pd.read_csv(data)
12
+
13
+ llm = OpenAI()
14
+
15
+ # Create a Pandas DataFrame agent.
16
+ agent = create_pandas_dataframe_agent(llm, df, verbose=True)
17
+
18
+ #Python REPL: A Python shell used to evaluating and executing Python commands.
19
+ #It takes python code as input and outputs the result. The input python code can be generated from another tool in the LangChain
20
+ return agent.invoke(query)