Skip to content

Commit f4fcce6

Browse files
committed
Improve Genie / fix minor bugs
1 parent e1d60c0 commit f4fcce6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

dash/pages/genie_api.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
from databricks.sdk import WorkspaceClient
2828
2929
30+
# Refer to the source code for the full implmenetation.
31+
32+
3033
def get_query_result(statement_id):
3134
# For simplicity, let's say data fits in one chunk, query.manifest.total_chunk_count = 1
3235
@@ -274,28 +277,31 @@ def update_chat(n_clicks, genie_space_id, conversation_id, prompt, chat_history)
274277
try:
275278
if conversation_id:
276279
conversation = w.genie.create_message_and_wait(genie_space_id, conversation_id, prompt)
280+
# Access error codes via conversation.error for detailed exception handling.
277281
else:
278282
conversation = w.genie.start_conversation_and_wait(genie_space_id, prompt)
279283
conversation_id = conversation.conversation_id
284+
# Access error codes via conversation.error for detailed exception handling.
280285

281286
chat_history = process_genie_response(conversation, chat_history)
282287
chat_display = format_message_display(chat_history)
283288

284289
return chat_history, chat_display, conversation_id
285290

286291
except Exception as e:
287-
return dash.no_update, dbc.Alert(f"An error occurred: {str(e)}", color="danger")
292+
return dash.no_update, dbc.Alert(f"Check the required permissions. An error occurred: {str(e)}", color="danger"), ""
288293

289294

290295
@callback(
291296
[Output("chat-history-store", "data", allow_duplicate=True),
292297
Output("chat-history", "children", allow_duplicate=True),
293298
Output("conversation-id", "value", allow_duplicate=True),],
294-
Input("clear-button", "n_clicks"),
299+
[Input("clear-button", "n_clicks"),
300+
Input("genie-space-id", "value"),],
295301
prevent_initial_call=True,
296302
)
297-
def clear_chat(n_clicks):
298-
return [], [], None if n_clicks else (dash.no_update, dash.no_update, None)
303+
def clear_chat(n_clicks, value):
304+
return [], [], None if n_clicks or value else (dash.no_update, dash.no_update, None)
299305

300306

301307
@callback(

0 commit comments

Comments
 (0)