Aditya Patkar commited on
Commit
fb16faf
1 Parent(s): 6e03f80
Files changed (2) hide show
  1. app.py +43 -0
  2. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from langchain.agents import create_pandas_dataframe_agent
4
+ from langchain.chat_models import ChatOpenAI
5
+ from langchain.agents.agent_types import AgentType
6
+
7
+ import pandas as pd
8
+
9
+ form = st.sidebar.form(key='my_form')
10
+ user_api_key = form.text_input(
11
+ label="#### Your OpenAI API key 👇",
12
+ placeholder="Paste your openAI API key, sk-",
13
+ type="password")
14
+ uploaded_file = form.file_uploader("Choose a file")
15
+ text_prompt = form.text_area('Text Prompt', value='Hello, how are you?')
16
+ submit_button = form.form_submit_button(label='Submit')
17
+ if submit_button :
18
+ df = pd.read_csv(uploaded_file)
19
+
20
+ st.title("OpenAI Chatbot 🤖"
21
+ )
22
+ st.subheader("This is a simple chatbot that uses OpenAI's GPT-3 model to generate responses to your text prompt. ")
23
+
24
+ st.subheader("Your data:")
25
+ st.write(df)
26
+
27
+ #horizontal line
28
+ st.markdown("""---""")
29
+
30
+ st.subheader("AI generated response:")
31
+
32
+ agent = create_pandas_dataframe_agent(
33
+ ChatOpenAI(temperature=0, model="gpt-3.5-turbo-16k", openai_api_key=user_api_key),
34
+ df,
35
+ verbose=True,
36
+ agent_type=AgentType.OPENAI_FUNCTIONS,
37
+ )
38
+
39
+ result = agent.run(text_prompt)
40
+ st.write(result)
41
+
42
+
43
+
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ langchain==0.0.263
2
+ openai==0.27.8
3
+ pandas==2.0.2
4
+ streamlit==1.23.1
5
+ streamlit_chat==0.0.2.2
6
+ tabulate==0.9.0