Jesus Sanchez commited on
Commit
8b29af4
·
1 Parent(s): d3c12b0

try to parse into chart

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -50,6 +50,13 @@ def from_gpt(query: str):
50
  # Run the query using the agent executor
51
  return agent_executor.run(query)
52
 
 
 
 
 
 
 
 
53
 
54
 
55
  def circle_chart():
@@ -79,7 +86,8 @@ def get_response(prompt: str, *kargs):
79
  response = from_db(table)
80
  else:
81
  on_render = st.write
82
- response = from_gpt(prompt)
 
83
 
84
  return (response, on_render)
85
 
 
50
  # Run the query using the agent executor
51
  return agent_executor.run(query)
52
 
53
+ def parse_into_chart(response: str):
54
+ if ":" not in response:
55
+ return response
56
+
57
+ data = response.split(":")[1]
58
+ return alt.Chart(data)
59
+
60
 
61
 
62
  def circle_chart():
 
86
  response = from_db(table)
87
  else:
88
  on_render = st.write
89
+ ans = from_gpt(prompt)
90
+ response = parse_into_chart(ans)
91
 
92
  return (response, on_render)
93