Skip to content

Prompt user to click Rerun if empty #1215

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

Merged
merged 3 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lumen/ai/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ class AnalystAgent(ChatAgent):

requires = param.List(default=["source", "pipeline"], readonly=True)

async def respond(
self,
messages: list[Message],
render_output: bool = False,
step_title: str | None = None,
) -> Any:
messages = super().respond(messages, render_output, step_title)
if len(self._memory["data"]) == 0 and self._memory.get("sql"):
self._memory["sql"] = f"{self._memory['sql']}\n-- No data was returned from the query."
return messages

class ListAgent(Agent):
"""
Expand Down
4 changes: 4 additions & 0 deletions lumen/ai/prompts/AnalystAgent/main.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ Here was the plan that was executed:
"""

Here is the current dataset:
{% if memory.data|length == 0 %}
The data is empty. Critique the SQL query and suggest what other columns or values should be used instead. Then prompt the user to click the rerun button below if they'd like to try again.
{% else %}
{{ memory.data }}
{% endif %}

{% if 'sql' in memory %}
Here is the current SQL query:
Expand Down