awacke1 commited on
Commit
489434f
·
1 Parent(s): 1abeec2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -0
app.py CHANGED
@@ -29,6 +29,59 @@ from langchain.memory import ConversationBufferMemory
29
  from langchain.chains import ConversationalRetrievalChain
30
  from templates import css, bot_template, user_template
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
 
34
  def generate_filename(prompt, file_type):
 
29
  from langchain.chains import ConversationalRetrievalChain
30
  from templates import css, bot_template, user_template
31
 
32
+ #bokeh intro
33
+ import streamlit-bokeh-events as sbe
34
+
35
+
36
+
37
+ import streamlit as st
38
+ from bokeh.plotting import figure
39
+ from bokeh.models import ColumnDataSource, CustomJS
40
+
41
+ # import function
42
+ from streamlit_bokeh_events import streamlit_bokeh_events
43
+
44
+ # create plot
45
+ p = figure(tools="lasso_select")
46
+ cds = ColumnDataSource(
47
+ data={
48
+ "x": [1, 2, 3, 4],
49
+ "y": [4, 5, 6, 7],
50
+ }
51
+ )
52
+ p.circle("x", "y", source=cds)
53
+
54
+ # define events
55
+ cds.selected.js_on_change(
56
+ "indices",
57
+ CustomJS(
58
+ args=dict(source=cds),
59
+ code="""
60
+ document.dispatchEvent(
61
+ new CustomEvent("YOUR_EVENT_NAME", {detail: {your_data: "goes-here"}})
62
+ )
63
+ """
64
+ )
65
+ )
66
+
67
+ # result will be a dict of {event_name: event.detail}
68
+ # events by default is "", in case of more than one events pass it as a comma separated values
69
+ # event1,event2
70
+ # debounce is in ms
71
+ # refresh_on_update should be set to False only if we dont want to update datasource at runtime
72
+ # override_height overrides the viewport height
73
+ result = streamlit_bokeh_events(
74
+ bokeh_plot=p,
75
+ events="YOUR_EVENT_NAME",
76
+ key="foo",
77
+ refresh_on_update=False,
78
+ override_height=600,
79
+ debounce_time=500)
80
+
81
+ # use the result
82
+ st.write(result)
83
+
84
+
85
 
86
 
87
  def generate_filename(prompt, file_type):