rairo commited on
Commit
ed4cefc
·
1 Parent(s): c78370b

Update demo.py

Browse files
Files changed (1) hide show
  1. demo.py +49 -0
demo.py CHANGED
@@ -1,3 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import pandas as pd
2
 
3
  import os
@@ -79,3 +127,4 @@ demo = gr.Interface(
79
  title="Ask BuzyHelper",
80
  )
81
  demo.launch(share=True)
 
 
1
+
2
+ import pandas as pd
3
+
4
+ import os
5
+ import gradio as gr
6
+ import io
7
+ from langchain.chains.question_answering import load_qa_chain
8
+ from langchain import PromptTemplate, LLMChain
9
+ from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent
10
+ from langchain.chat_models import ChatOpenAI
11
+ from langchain.agents.agent_types import AgentType
12
+ from langchain.chat_models import ChatOpenAI
13
+ import pandas as pd
14
+ from langchain.llms import OpenAI
15
+ from dotenv import load_dotenv
16
+ import google.generativeai as palm
17
+ from langchain.llms import GooglePalm
18
+
19
+ def questiondocument(user_question):
20
+ load_dotenv()
21
+ #
22
+ df = pd.read_excel("tour_op2.xlsx")
23
+ #df['Profit'] = df['Profit'].apply(lambda x: "R{:.1f}".format((x)))
24
+ #df['Revenue'] = df['Revenue'].apply(lambda x: "R{:.1f}".format((x)))
25
+ #llm = ChatOpenAI(model_name='gpt-3.5-turbo-0613', temperature=0, openai_api_key=os.getenv('OPENAI_API_KEY'))
26
+ llm = GooglePalm(temperature=0, google_api_key=os.environ['PALM'])
27
+ #agent = create_pandas_dataframe_agent(llm, df, verbose=True, agent_type=AgentType.OPENAI_FUNCTIONS)
28
+ agent = create_pandas_dataframe_agent(llm, df, agent="structured_chat-zero-shot-react-description", verbose=True)
29
+ response = agent.run(user_question)
30
+ return response
31
+
32
+ demo = gr.Interface(
33
+
34
+ fn=questiondocument,
35
+ inputs=["text"],
36
+ outputs=["text"],
37
+ title="Ask BuzyHelper",
38
+ )
39
+ demo.launch(share=True)
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ '''
48
+
49
  import pandas as pd
50
 
51
  import os
 
127
  title="Ask BuzyHelper",
128
  )
129
  demo.launch(share=True)
130
+ '''