Skip to content

feat: return structured suggestion objects with display label and full prompt#119

Open
Ridwannurudeen wants to merge 1 commit intoOpenGradient:mainfrom
Ridwannurudeen:feat/suggestion-prompts
Open

feat: return structured suggestion objects with display label and full prompt#119
Ridwannurudeen wants to merge 1 commit intoOpenGradient:mainfrom
Ridwannurudeen:feat/suggestion-prompts

Conversation

@Ridwannurudeen
Copy link

Summary

  • Suggestions now return {"display": "...", "prompt": "..."} objects instead of plain strings
  • display is the short 2-5 word button label shown in the UI
  • prompt is a full, detailed message sent to the agent when the button is clicked
  • Includes graceful fallback: legacy plain strings are returned as display=prompt

Motivation

The suggestion buttons currently show a short label (e.g. "Analyze ETH trend") and that same short string is what gets sent to the agent. A richer, more detailed prompt improves the quality of agent responses significantly. For example, clicking "Analyze ETH trend" now sends: "Analyze Ethereum's price trend over the past 30 days, including volume, momentum, and key support and resistance levels."

Changes

api/api_types.py

  • Add Suggestion dataclass with display: str and prompt: str

templates/suggestions.jinja2

  • Updated to generate JSON objects with both display and prompt fields
  • Added detailed example responses showing the expected format

server/fastapi_server.py

  • Import Suggestion from api_types
  • Update handle_suggestions_request return type from List[str] to List[Suggestion]
  • Parse structured objects from LLM response; fall back gracefully for plain strings

Test plan

  • Verify /api/v2/agent/suggestions returns {"suggestions": [{"display": "...", "prompt": "..."}, ...]}
  • Verify frontend receives display for button label and prompt as the message to send on click
  • Verify graceful fallback when LLM returns plain strings (display == prompt)

Closes #40

…l prompt

Suggestions endpoint now returns {"display": "...", "prompt": "..."} objects
instead of plain strings. The "display" field is the short 2-5 word button
label shown in the UI; the "prompt" field is a full, detailed message sent
to the agent when the user clicks the suggestion.

- Add Suggestion type to api/api_types.py (display + prompt fields)
- Update templates/suggestions.jinja2 to generate structured objects with
  context-rich prompts alongside short display labels
- Update handle_suggestions_request to parse and return List[Suggestion]
- Gracefully falls back to display=prompt for any legacy plain string items

Closes OpenGradient#40
@Ridwannurudeen
Copy link
Author

Hi team! Just a friendly ping on this PR. It returns structured Suggestion objects (with display_label and full_prompt fields) instead of raw strings, making it easier for callers to render suggestions in UI without re-parsing. No breaking changes — happy to adjust anything if you have feedback.

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.

Make suggestion prompts longer

1 participant