pwilczewski commited on
Commit
d70f60e
·
1 Parent(s): 2944273

save plot example

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -12,15 +12,17 @@ df = pd.read_csv("USSTHPI.csv")
12
  python_repl_tool = PythonAstREPLTool(locals={"df": df})
13
 
14
  import matplotlib.pyplot as nplt
15
- nplt.figure(figsize=(10, 5))
16
- nplt.plot(df['DATE'], df['USSTHPI'], label='USSTHPI')
17
- nplt.title('Time Series of USSTHPI')
18
- nplt.xlabel('Date')
19
- nplt.ylabel('USSTHPI')
20
- nplt.legend()
21
- nplt.xticks(rotation=45)
22
- nplt.tight_layout()
23
- nplt.savefig('plots/plot.png')
 
 
24
 
25
  # cell 2
26
  from langchain.agents import AgentExecutor, create_openai_tools_agent
@@ -106,5 +108,5 @@ def greet(name):
106
  resp = graph.invoke({"messages": [HumanMessage(content="Run the analysis")]}, debug=True)
107
  return resp
108
 
109
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
110
  demo.launch()
 
12
  python_repl_tool = PythonAstREPLTool(locals={"df": df})
13
 
14
  import matplotlib.pyplot as nplt
15
+ def gen_plot():
16
+ nplt.figure(figsize=(10, 5))
17
+ nplt.plot(df['DATE'], df['USSTHPI'], label='USSTHPI')
18
+ nplt.title('Time Series of USSTHPI')
19
+ nplt.xlabel('Date')
20
+ nplt.ylabel('USSTHPI')
21
+ nplt.legend()
22
+ nplt.xticks(rotation=45)
23
+ nplt.tight_layout()
24
+ nplt.savefig('plots/plot.png')
25
+ return "plots/plot.png"
26
 
27
  # cell 2
28
  from langchain.agents import AgentExecutor, create_openai_tools_agent
 
108
  resp = graph.invoke({"messages": [HumanMessage(content="Run the analysis")]}, debug=True)
109
  return resp
110
 
111
+ demo = gr.Interface(fn=gen_plot, inputs="text", outputs="text")
112
  demo.launch()