Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -4,17 +4,9 @@ import os
|
|
4 |
import io
|
5 |
from flask import Flask, request, jsonify
|
6 |
from flask_cors import CORS, cross_origin
|
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 |
-
|
15 |
from dotenv import load_dotenv
|
16 |
-
import google.generativeai as palm
|
17 |
-
from langchain.llms import GooglePalm
|
18 |
import json
|
19 |
|
20 |
|
@@ -48,15 +40,6 @@ def bot():
|
|
48 |
data = eval(str(json_table))
|
49 |
df = pd.DataFrame(data)
|
50 |
print(list(df))
|
51 |
-
#df = df.rename(columns={'dateupdated': 'date'})
|
52 |
-
#df['date'] = pd.to_datetime(df['date'], format="%b %d", errors='coerce')
|
53 |
-
#df['Profit'] = df['Profit'].apply(lambda x: "R{:.1f}".format((x)))
|
54 |
-
#df['Revenue'] = df['Revenue'].apply(lambda x: "R{:.1f}".format((x)))
|
55 |
-
llm = GooglePalm(temperature=0, google_api_key=os.environ['PALM'])
|
56 |
-
|
57 |
-
agent = create_pandas_dataframe_agent(llm, df, agent="structured_chat-zero-shot-react-description", verbose=True)
|
58 |
-
response = agent.run(user_question)
|
59 |
-
#response.headers.add('Access-Control-Allow-Origin', '*')
|
60 |
return jsonify(response)
|
61 |
|
62 |
|
|
|
4 |
import io
|
5 |
from flask import Flask, request, jsonify
|
6 |
from flask_cors import CORS, cross_origin
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
import pandas as pd
|
8 |
+
|
9 |
from dotenv import load_dotenv
|
|
|
|
|
10 |
import json
|
11 |
|
12 |
|
|
|
40 |
data = eval(str(json_table))
|
41 |
df = pd.DataFrame(data)
|
42 |
print(list(df))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
return jsonify(response)
|
44 |
|
45 |
|