|
27 | 27 | from databricks.sdk import WorkspaceClient |
28 | 28 |
|
29 | 29 |
|
| 30 | +# Refer to the source code for the full implmenetation. |
| 31 | +
|
| 32 | +
|
30 | 33 | def get_query_result(statement_id): |
31 | 34 | # For simplicity, let's say data fits in one chunk, query.manifest.total_chunk_count = 1 |
32 | 35 |
|
@@ -274,28 +277,31 @@ def update_chat(n_clicks, genie_space_id, conversation_id, prompt, chat_history) |
274 | 277 | try: |
275 | 278 | if conversation_id: |
276 | 279 | conversation = w.genie.create_message_and_wait(genie_space_id, conversation_id, prompt) |
| 280 | + # Access error codes via conversation.error for detailed exception handling. |
277 | 281 | else: |
278 | 282 | conversation = w.genie.start_conversation_and_wait(genie_space_id, prompt) |
279 | 283 | conversation_id = conversation.conversation_id |
| 284 | + # Access error codes via conversation.error for detailed exception handling. |
280 | 285 |
|
281 | 286 | chat_history = process_genie_response(conversation, chat_history) |
282 | 287 | chat_display = format_message_display(chat_history) |
283 | 288 |
|
284 | 289 | return chat_history, chat_display, conversation_id |
285 | 290 |
|
286 | 291 | 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"), "" |
288 | 293 |
|
289 | 294 |
|
290 | 295 | @callback( |
291 | 296 | [Output("chat-history-store", "data", allow_duplicate=True), |
292 | 297 | Output("chat-history", "children", allow_duplicate=True), |
293 | 298 | 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"),], |
295 | 301 | prevent_initial_call=True, |
296 | 302 | ) |
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) |
299 | 305 |
|
300 | 306 |
|
301 | 307 | @callback( |
|
0 commit comments