Skip to content

Conversation

@wierdvanderhaar
Copy link
Contributor

Summary of the changes / Why this is an improvement

  • Better answers

Checklist

  • Link to issue this PR refers to (if applicable): Fixes #???

@coderabbitai
Copy link

coderabbitai bot commented Apr 25, 2025

Walkthrough

A new function for generating plain-language explanations of manual guidance using an LLM was introduced. The main orchestrator function was refactored to include comprehensive error handling with try-except blocks, and its logic for constructing final answers was updated to utilize the new explanation function when appropriate. Prompt instructions for telemetry questions were expanded for clarity. The user interaction cell now features a different example question and enhanced output formatting using styled HTML for improved readability.

Changes

File(s) Change Summary
topic/chatbot/table-augmented-generation/workshop/telemetry-diagnostics-assistant.ipynb Added explain_manual_guidance function; refactored get_combined_answer with try-except error handling and nested SQL error handling; expanded telemetry prompt instructions; changed example question to "Is machine 4 overheating?"; enhanced output display with styled HTML box.

Possibly related PRs

Suggested reviewers

  • wierdvanderhaar

Poem

In the warren of code, a new helper appears,
To explain with plain words and calm user fears.
With errors now caught and answers refined,
The output looks lovely—so neatly aligned!
A question of heat, new prompts to explore,
This bunny brings clarity, and so much more.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67b0f5a and c03f78f.

📒 Files selected for processing (1)
  • topic/chatbot/table-augmented-generation/workshop/telemetry-diagnostics-assistant.ipynb (7 hunks)
🔇 Additional comments (2)
topic/chatbot/table-augmented-generation/workshop/telemetry-diagnostics-assistant.ipynb (2)

939-939: Minor improvement to error message formatting.

The addition of a trailing newline after the exception message in the explain_result_with_llm() function improves readability of the output.


1312-1369: Improved UI with styled HTML output

The user interaction cell has been enhanced with:

  • Better visual presentation using a dark-themed HTML box
  • Structured formatting for SQL queries, results, and the final answer
  • Changed example question that better demonstrates the system's capabilities

These changes significantly improve the user experience and readability of the output.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@wierdvanderhaar wierdvanderhaar requested a review from amotl April 25, 2025 14:13
@wierdvanderhaar
Copy link
Contributor Author

@amotl please review and merge.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
topic/chatbot/table-augmented-generation/workshop/telemetry-diagnostics-assistant.ipynb (3)

1241-1245: sql2 precedence can override LLM output unintentionally

sql2 is first initialised with a manual-lookup query when needs_manual is true, but later may be overwritten by parsed_sql2 from the model (or vice-versa):

sql2 = patch_cratedb_sql(parsed_sql2) if parsed_sql2 else sql2

If the model emits an empty SQL 2: block the original manual query survives; if it emits a syntactically invalid but non-empty block it will replace your safe fallback and potentially fail execution.

Recommend validating the parsed SQL before overwriting:

if parsed_sql2 and "SELECT" in parsed_sql2.upper():
    sql2 = patch_cratedb_sql(parsed_sql2)

1264-1269: Manual-only questions can ignore telemetry context

Your current precedence chain:

  1. needs_manual ➔ explain_manual_guidance(...)
  2. elif df1 not empty ➔ telemetry explanation
  3. else ➔ raw answer

A question such as “Is machine 4 overheating?” triggers both telemetry and manual context, yet only the manual explanation is returned. Consider merging both:

if needs_manual and anomaly_text:
    manual_part = explain_manual_guidance(...)
    telemetry_part = (
        explain_result_with_llm(question, df1) if df1 is not None else ""
    )
    final_answer = f"{telemetry_part}\n\n{manual_part}".strip()

1312-1369: HTML output is susceptible to accidental markup injection

joined_output may contain angle brackets (e.g., user question “<script>…”) which will be interpreted by the browser because you interpolate directly into an HTML string.
Although in a notebook the risk is lower, it is safer to escape the content:

import html
...
joined_output_html = html.escape(joined_output)
display(HTML(f"""
   <div style="...">
       {joined_output_html}
   </div>"""))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67b0f5a and c03f78f.

📒 Files selected for processing (1)
  • topic/chatbot/table-augmented-generation/workshop/telemetry-diagnostics-assistant.ipynb (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Python: 3.10 CrateDB: nightly on ubuntu-latest

@wierdvanderhaar
Copy link
Contributor Author

@amotl please review and merge.

@amotl amotl changed the title Latest-Changes Chatbot: Latest changes for workshop notebook Apr 25, 2025
Copy link
Member

@amotl amotl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Wierd, thanks for the patch. I've added some comments that try to relate to the suggestions submitted by CodeRabbit. Thanks for addressing them.

@wierdvanderhaar wierdvanderhaar requested a review from amotl April 28, 2025 12:39
@amotl
Copy link
Member

amotl commented Apr 28, 2025

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Apr 28, 2025

✅ Actions performed

Full review triggered.

Copy link
Member

@amotl amotl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like CI is succeeding on your patch, and @coderabbitai also does no longer display any admonitions or suggestions, so we figure it will be good to go. Thanks again!

@amotl amotl merged commit 3580d99 into main Apr 28, 2025
3 checks passed
@amotl amotl deleted the wh-latest branch April 28, 2025 14:43
@coderabbitai coderabbitai bot mentioned this pull request Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants