Spaces:
Sleeping
Sleeping
pwilczewski
commited on
Commit
·
d70f60e
1
Parent(s):
2944273
save plot example
Browse files
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 |
-
|
16 |
-
nplt.
|
17 |
-
nplt.
|
18 |
-
nplt.
|
19 |
-
nplt.
|
20 |
-
nplt.
|
21 |
-
nplt.
|
22 |
-
nplt.
|
23 |
-
nplt.
|
|
|
|
|
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=
|
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()
|