Skip to content

Commit b7db1d1

Browse files
committed
Dash Streamlit consistency
1 parent eba443c commit b7db1d1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

dash/pages/embed_dashboard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dash import html, dcc, callback, Input, Output, State
1+
from dash import html, dcc, callback, Input, Output
22
import dash_bootstrap_components as dbc
33
import dash
44

@@ -7,7 +7,7 @@
77
__name__,
88
path="/bi/dashboard",
99
title="AI/BI Dashboard",
10-
name="Embed a dashboard",
10+
name="AI/BI Dashboard",
1111
category="Business Intelligence",
1212
icon="material-symbols:dashboard",
1313
)

dash/pages/genie_api.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from dash import html, dcc, callback, Input, Output, State
22
import dash_bootstrap_components as dbc
3-
from dash.exceptions import PreventUpdate
43
import dash
54
from databricks.sdk import WorkspaceClient
65
from databricks.sdk.service.dashboards import GenieMessage
@@ -13,7 +12,7 @@
1312
__name__,
1413
path='/bi/genie',
1514
title='Genie',
16-
name='Converse with your data',
15+
name='Genie',
1716
category='Business Intelligence',
1817
icon='material-symbols:model-training'
1918
)
@@ -151,6 +150,7 @@ def layout():
151150

152151
# Chat history area
153152
html.Div(id="chat-history-genie", className="mt-4"),
153+
dcc.Store(id='conversation-id'),
154154

155155
# Status/error messages
156156
html.Div(id="status-area-genie", className="mt-3")
@@ -237,39 +237,41 @@ def process_genie_response(response):
237237
Output("status-area-genie", "children")],
238238
Input("chat-button", "n_clicks"),
239239
[State("genie-space-id-input", "value"),
240+
State("conversation-id", "value"),
240241
State("question-input", "value")],
241242
prevent_initial_call=True
242243
)
243-
def update_chat(n_clicks, genie_space_id, question):
244-
if not all([genie_space_id, question]):
245-
return no_update, dbc.Alert(
244+
def update_chat(n_clicks, genie_space_id, conversation_id, prompt):
245+
if not all([genie_space_id, prompt]):
246+
return dash.no_update, dbc.Alert(
246247
"Please fill in all fields",
247248
color="warning"
248249
)
249250

250251
try:
251-
if st.session_state.get("conversation_id"):
252+
if conversation_id:
252253
conversation = w.genie.create_message_and_wait(
253-
genie_space_id, st.session_state.conversation_id, prompt
254+
genie_space_id, conversation_id, prompt
254255
)
255256
process_genie_response(conversation)
256257
else:
257258
conversation = w.genie.start_conversation_and_wait(genie_space_id, prompt)
259+
conversation_id = conversation.conversation_id
258260
process_genie_response(conversation)
259261

260262

261263
return [
262264
html.Div([
263265
dbc.Card(
264266
dbc.CardBody([
265-
html.P(f"Q: {question}"),
267+
html.P(f"Q: {prompt}"),
266268
html.P("A: Processing your question...")
267269
])
268270
)
269271
], className="mb-3")
270272
], None
271273
except Exception as e:
272-
return no_update, dbc.Alert(
274+
return dash.no_update, dbc.Alert(
273275
f"An error occurred: {str(e)}",
274276
color="danger"
275277
)

0 commit comments

Comments
 (0)