waelstaha commited on
Commit
b2feba5
·
1 Parent(s): 93d0966

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -10,6 +10,9 @@ from langchain import OpenAI
10
  from langchain import PromptTemplate, OpenAI, LLMChain
11
  from langchain.chains import SimpleSequentialChain
12
  from langchain import SQLDatabaseChain
 
 
 
13
 
14
 
15
  JSON_DATA_LABEL = 'json_data'
@@ -71,10 +74,17 @@ def get_json_chain():
71
  def plot_chart():
72
  json = st.session_state[JSON_DATA_LABEL]
73
  # print(json)
74
- if not json:
75
- return "no data to plot"
 
 
 
 
 
 
 
76
  # Add Open AI call to format outcome in a table
77
- return ""
78
 
79
 
80
  # sql_agent = get_sql_agent()
 
10
  from langchain import PromptTemplate, OpenAI, LLMChain
11
  from langchain.chains import SimpleSequentialChain
12
  from langchain import SQLDatabaseChain
13
+ from langchain.agents.agent_toolkits import create_python_agent
14
+ from langchain.tools.python.tool import PythonREPLTool
15
+ from langchain.python import PythonREPL
16
 
17
 
18
  JSON_DATA_LABEL = 'json_data'
 
74
  def plot_chart():
75
  json = st.session_state[JSON_DATA_LABEL]
76
  # print(json)
77
+ # if not json:
78
+ # return "no data to plot"
79
+
80
+ agent_executor = create_python_agent(
81
+ llm=llm,
82
+ tool=PythonREPLTool(),
83
+ verbose=True
84
+ )
85
+
86
  # Add Open AI call to format outcome in a table
87
+ return agent_executor.run("Plot these results:{json}",json)
88
 
89
 
90
  # sql_agent = get_sql_agent()