-
-
Notifications
You must be signed in to change notification settings - Fork 30
Add follow-up suggestion chips after successful queries #1764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ghostiee-11
wants to merge
9
commits into
holoviz:main
Choose a base branch
from
ghostiee-11:feat/smart-followup-suggestions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
582b0e1
Add follow-up suggestion icon button after successful queries
ghostiee-11 869fcb0
Address review: on-demand follow-up, remove toggle, fix naming
ghostiee-11 e84ae85
Address review: notify on failure, fix async pattern, keep icon visible
ghostiee-11 d91b685
Address review: rename follow_up key, simplify footer_actions, bump pin
ghostiee-11 17e88cf
Fix CI: fallback to footer_objects until footer_actions is released
ghostiee-11 40df87c
Address review: use footer_actions directly, restore panel-material-u…
ghostiee-11 3e17d44
Merge branch 'main' into feat/smart-followup-suggestions
ahuang11 bd3e033
Add on-demand follow-up suggestion icon after successful queries
ghostiee-11 454c26d
Merge branch 'main' into feat/smart-followup-suggestions
ghostiee-11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,7 +25,7 @@ | |||||
| from ..config import PROMPTS_DIR, MissingContextError | ||||||
| from ..context import TContext | ||||||
| from ..llm import LlamaCpp, Llm, Message | ||||||
| from ..models import ThinkingYesNo | ||||||
| from ..models import FollowUpSuggestion, ThinkingYesNo | ||||||
| from ..report import ActorTask, Section, TaskGroup | ||||||
| from ..tools import MetadataLookup, Tool, VectorLookupToolUser | ||||||
| from ..utils import ( | ||||||
|
|
@@ -284,6 +284,11 @@ class Coordinator(Viewer, VectorLookupToolUser): | |||||
| "template": PROMPTS_DIR / "Coordinator" / "tool_relevance.jinja2", | ||||||
| "response_model": ThinkingYesNo, | ||||||
| }, | ||||||
| "follow_up_suggestions": { | ||||||
| "template": PROMPTS_DIR / "Coordinator" / "follow_up_suggestions.jinja2", | ||||||
| "response_model": FollowUpSuggestion, | ||||||
| "llm_spec": "ui", | ||||||
| }, | ||||||
| }, | ||||||
| ) | ||||||
|
|
||||||
|
|
@@ -509,6 +514,40 @@ async def _check_tool_relevance(self, tool: Tool, tool_output: str, actor: Actor | |||||
|
|
||||||
| return result.yes | ||||||
|
|
||||||
| async def suggest_followup(self, plan: Plan) -> str | None: | ||||||
| """Generate a single follow-up suggestion from a completed plan. | ||||||
|
|
||||||
| Returns a suggestion query string, or None on failure. | ||||||
| """ | ||||||
| pipeline = plan.out_context.get("pipeline") | ||||||
| if pipeline is None: | ||||||
| return None | ||||||
|
|
||||||
| data_summary = plan.out_context.get("data", "") | ||||||
| if not data_summary: | ||||||
| return None | ||||||
|
|
||||||
| sql = plan.out_context.get("sql", "") | ||||||
| previous_queries = [ | ||||||
| m["content"] for m in plan.history | ||||||
| if m.get("role") == "user" | ||||||
| ] | ||||||
| output_type = "chart" if plan.out_context.get("view") else "table" | ||||||
|
|
||||||
| try: | ||||||
| result = await self._invoke_prompt( | ||||||
| "follow_up_suggestions", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| messages=[{"role": "user", "content": "Generate a follow-up suggestion."}], | ||||||
| context=plan.out_context, | ||||||
| data_summary=data_summary, | ||||||
| sql=sql, | ||||||
| output_type=output_type, | ||||||
| previous_queries=previous_queries, | ||||||
| ) | ||||||
| return result.query | ||||||
| except Exception: | ||||||
| return None | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it should raise a notification perhaps through pn.state.notifications instead of failing silently. |
||||||
|
|
||||||
| def __panel__(self): | ||||||
| return self.interface | ||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| {% extends 'Actor/main.jinja2' %} | ||
|
|
||
| {% block instructions %} | ||
| Suggest ONE concise follow-up question based on the user's query and the resulting data. | ||
|
|
||
| Rules: | ||
| - MUST reference specific column names from the data summary | ||
| - Keep it short and actionable (under 100 characters) | ||
| - Do NOT repeat any previous queries | ||
| - Do NOT suggest analyses the data cannot support | ||
| {% endblock %} | ||
|
|
||
| {% block examples %} | ||
| Examples: | ||
| - "Show revenue trend over date by product" | ||
| - "Compare revenue across region" | ||
| - "Filter to top 5 products by revenue" | ||
| {% endblock %} | ||
|
|
||
| {% block context %} | ||
| Data Summary: | ||
| {{ data_summary }} | ||
| {% if sql %} | ||
| SQL Executed: {{ sql }} | ||
| {% endif %} | ||
| Output Type: {{ output_type }} | ||
| {% if previous_queries %} | ||
| Previous Queries (do NOT repeat): | ||
| {% for q in previous_queries %}- {{ q }} | ||
| {% endfor %}{% endif %} | ||
| {% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.