Update conversation agent app to include all the objects returned by the genie API#667
Conversation
…ary) and polish UI genie_room.py: process_genie_response now collects all attachment data into a rich dict (text_response, sql_query, sql_description, dataframe, content, error) instead of returning only the first match. Callers updated accordingly. app.py: Renders all response sections in order — text response, SQL description, data table, collapsible SQL code, insight button, and message content. Removed inline styles in favor of CSS classes. style.css: Added .sql-description with blue accent border, polished toggle-query and insight buttons, improved section spacing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
genie_room.py: Add _generate_data_summary() for DataFrame stats, pd.to_numeric conversion for numeric columns, data_summary and status fields in response dict. app.py: Show text response at top only when no query data; show follow-up question below data summary; suppress echoed user question from msg_content; render data_summary stats block below table. style.css: Add .data-summary styling for stats overview block. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…maries Add user feedback buttons (thumbs up/down) that send ratings to the Genie space via the SDK. Separate text attachments by purpose so follow-up questions no longer overwrite the real text summary in responses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Combine thumbs up/down into a single callback that toggles the active CSS class on the clicked button, providing visual feedback to the user. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the conversational agent Dash app to preserve and render the full set of objects returned by the Databricks Genie API (text, SQL metadata, results, and content), and adds message feedback support.
Changes:
- Refactors Genie response processing to return a structured dict containing text, SQL/query metadata, dataframe results, summaries, and error/status info.
- Updates the Dash UI to render response sections in a consistent order and adds thumbs up/down feedback controls.
- Refreshes CSS for SQL description, toggle/query controls, insight button styling, and section spacing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| conversational-agent-app/genie_room.py | Returns a rich response dict from Genie (incl. dataframe + summary) and adds a feedback API wrapper. |
| conversational-agent-app/app.py | Renders all response components (text/SQL/table/summary/controls) and adds a callback for feedback submission. |
| conversational-agent-app/assets/style.css | Adds styling for SQL description, toggles, insight button, and response section spacing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| def start_new_conversation(question: str, token: str, space_id: str) -> Tuple[str, Dict[str, Any]]: | ||
| """ | ||
| Start a new conversation with Genie. | ||
| Returns: (conversation_id, response_dict) | ||
| """ | ||
| client = GenieClient( | ||
| host=DATABRICKS_HOST, | ||
| space_id=space_id, | ||
| token=token | ||
| ) | ||
|
|
||
| try: | ||
| # Start a new conversation | ||
| response = client.start_conversation(question) | ||
| conversation_id = response["conversation_id"] | ||
| message_id = response["message_id"] | ||
|
|
||
| # Wait for the message to complete | ||
| complete_message = client.wait_for_message_completion(conversation_id, message_id) | ||
|
|
||
| # Process the response | ||
| result, query_text = process_genie_response(client, conversation_id, message_id, complete_message) | ||
|
|
||
| return conversation_id, result, query_text | ||
|
|
||
| result = process_genie_response(client, conversation_id, message_id, complete_message) | ||
| result["message_id"] = message_id | ||
|
|
||
| return conversation_id, result | ||
|
|
||
| except Exception as e: | ||
| return None, f"Sorry, an error occurred: {str(e)}. Please try again.", None | ||
| return None, { | ||
| "text_response": f"Sorry, an error occurred: {str(e)}. Please try again.", | ||
| "sql_query": None, "sql_description": None, | ||
| "dataframe": None, "data_summary": None, | ||
| "content": None, "status": "ERROR", "error": str(e), | ||
| "message_id": None, | ||
| } |
There was a problem hiding this comment.
start_new_conversation is annotated to return Tuple[str, Dict[str, Any]], but the exception path returns (None, {...}). Update the return type to allow None (e.g., Tuple[str | None, Dict[str, Any]]) or avoid returning None here so callers can rely on the declared type.
conversational-agent-app/app.py
Outdated
| df = response.get("dataframe") | ||
| data_summary = response.get("data_summary") | ||
| msg_content = response.get("content") | ||
| error = response.get("error") |
There was a problem hiding this comment.
error = response.get("error") is assigned but never used. Either render the error in the UI (when present) or remove this variable to avoid dead code.
| error = response.get("error") |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
genie_room.py: process_genie_response now collects all attachment data into a
rich dict (text_response, sql_query, sql_description, dataframe, content, error)
instead of returning only the first match. Callers updated accordingly.
app.py: Renders all response sections in order — text response, SQL description,
data table, collapsible SQL code, insight button, and message content. Removed
inline styles in favor of CSS classes. Removed logout button.
style.css: Added .sql-description with blue accent border, polished toggle-query
and insight buttons, improved section spacing.