Skip to content

Add a live Ask (RAG) box to the agents page #2540

Description

@JSONbored

POST /api/v1/ask is grounded RAG Q&A over the registry (Vectorize + Workers AI llama-3.1-8b, live probe health injected), but agents.tsx:83 only shows it as a curl snippet. Add a real 'Ask' box on the agents page that POSTs a question and renders the grounded answer. Maintainer-leaning because it 503s when AI is off and is AI-rate-limited, so it needs graceful degradation and the AI-availability call is the maintainer's.

Deliverables

  • Add an askQuestion mutation/query in queries.ts (or a small client helper) that POSTs { question } to /api/v1/ask with the 4096B body cap enforced
  • Add an Ask box UI to agents.tsx (input + submit + answer render), reusing existing typography/section components
  • Gracefully degrade when /api/v1/ask returns 503 ai-off (show the curl fallback + a notice; do not error the page)
  • Debounce/disable submit to respect AI_RATE_LIMITER; show a loading state while the model responds
  • Add unit tests for the request shape (body cap), the ai-off 503 branch, and the answer-render branch

References

  • repo/workers/api.mjs:3056 (handleAskRequest, 503 when AI off, body cap 4096B)
  • repo/src/ai-search.mjs (askQuestion RAG)
  • repo-ui/src/routes/agents.tsx:83 (curl snippet only)
  • repo-ui/src/lib/metagraphed/client.ts (apiFetch for POST)

📸 Required: before/after screenshots (this is a UI change)

Non-negotiable. PRs that change UI must include a before/after screenshot table. PRs without it are automatically closed — no exceptions.

Rules:

  • Show every page/feature you changed — before and after, one row each.
  • Use the markdown table below. Screenshots go inside the table only — no large full-size images pasted elsewhere in the PR.
  • Each cell is a clickable thumbnail (a small image linking to the full-size image) with a one-line caption underneath.
  • Upload screenshots to the PR by drag-and-drop (GitHub hosts them on its CDN). Do NOT commit image files to the repo.

Copy this and fill it in (replace FULL_IMAGE_URL with the URL GitHub gives you after you drop the image in):

| Page / Feature | Before | After |
|---|---|---|
| `/your-route` | [<img src="FULL_IMAGE_URL" width="260">](FULL_IMAGE_URL)<br><sub>before: short caption</sub> | [<img src="FULL_IMAGE_URL" width="260">](FULL_IMAGE_URL)<br><sub>after: short caption</sub> |


size: M · maintainer-only (owner)

Metadata

Metadata

Assignees

Labels

frontendFrontend / metagraphed-ui workmaintainer-onlyOwner-only work — yields no Gittensor points.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions