ahuang11 commited on
Commit
a4b0766
1 Parent(s): 04d5a98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -80,7 +80,10 @@ async def callback(content: str, user: str, instance: pn.chat.ChatInterface):
80
  if llm_code.splitlines()[-1].strip() != "fig":
81
  llm_code += "\nfig"
82
  code_editor.value = llm_code
83
- matplotlib_pane.object = exec_with_return(llm_code)
 
 
 
84
 
85
 
86
  # instantiate widgets and panes
@@ -107,6 +110,9 @@ code_editor = pn.widgets.CodeEditor(
107
  sizing_mode="stretch_both",
108
  )
109
 
 
 
 
110
  # lay them out
111
  tabs = pn.Tabs(
112
  ("Plot", matplotlib_pane),
 
80
  if llm_code.splitlines()[-1].strip() != "fig":
81
  llm_code += "\nfig"
82
  code_editor.value = llm_code
83
+
84
+
85
+ def update_plot(event):
86
+ matplotlib_pane.object = exec_with_return(event.new)
87
 
88
 
89
  # instantiate widgets and panes
 
110
  sizing_mode="stretch_both",
111
  )
112
 
113
+ # watch for code changes
114
+ code_editor.param.watch(update_plot, "value")
115
+
116
  # lay them out
117
  tabs = pn.Tabs(
118
  ("Plot", matplotlib_pane),