Add PromptFeedback API for per-message thumbs ratings (#67) #70

Merged
westfarn merged 1 commits from feature/prompt-feedback-api-67 into master 2026-08-04 03:23:58 -07:00
Owner

Summary

  • Closes #67 — new PromptFeedback model (unique on (prompt, user)) with rating (up|down), optional reason / comment, and timestamps via TimeInfoBase.
  • POST /api/prompt_feedback upserts { prompt_id, rating, reason?, comment? }; DELETE /api/prompt_feedback?prompt_id= clears the caller's vote.
  • GET conversation_details now nests the caller's feedback: { rating, reason, comment } (or null) on each prompt so chat_web_app#101 can rehydrate thumbs UI.
  • Auth required; users can only rate assistant prompts in their own non-deleted conversations. Distinct from app-wide POST /feedbacks/.
  • Joinable to PromptMetric via prompt_id for per-model accuracy slices.

Test plan

  • uv run python manage.py test chat_backend.tests.test_views_prompt_feedback
  • Upsert thumbs up, then down with reason/comment — one row updated
  • DELETE clears vote; second DELETE → 404
  • Rating another user's prompt → 404; rating a user message → 400
  • Reload conversation details → assistant prompts show caller feedback only
  • Companion FE chat_web_app#101 thumbs + reason popover against this API
## Summary - Closes [#67](https://git.aimloperations.com/ai_ml_operations/chat_backend/issues/67) — new `PromptFeedback` model (unique on `(prompt, user)`) with `rating` (`up`|`down`), optional `reason` / `comment`, and timestamps via `TimeInfoBase`. - `POST /api/prompt_feedback` upserts `{ prompt_id, rating, reason?, comment? }`; `DELETE /api/prompt_feedback?prompt_id=` clears the caller's vote. - `GET conversation_details` now nests the caller's `feedback: { rating, reason, comment }` (or `null`) on each prompt so [chat_web_app#101](https://git.aimloperations.com/ai_ml_operations/chat_web_app/pulls/101) can rehydrate thumbs UI. - Auth required; users can only rate assistant prompts in their own non-deleted conversations. Distinct from app-wide `POST /feedbacks/`. - Joinable to `PromptMetric` via `prompt_id` for per-model accuracy slices. ## Test plan - [ ] `uv run python manage.py test chat_backend.tests.test_views_prompt_feedback` - [ ] Upsert thumbs up, then down with reason/comment — one row updated - [ ] DELETE clears vote; second DELETE → 404 - [ ] Rating another user's prompt → 404; rating a user message → 400 - [ ] Reload conversation details → assistant prompts show caller feedback only - [ ] Companion FE [chat_web_app#101](https://git.aimloperations.com/ai_ml_operations/chat_web_app/pulls/101) thumbs + reason popover against this API
westfarn added 1 commit 2026-08-04 03:05:00 -07:00
Add PromptFeedback API for per-message thumbs ratings (#67).
CI / test (pull_request) Successful in 10s
Unit Tests / test (pull_request) Successful in 10s
9a07497b38
Upsert/delete prompt_feedback and hydrate caller ratings on
conversation_details so chat_web_app message actions can persist votes.
Author
Owner

Companion FE: chat_web_app#101 already posts/deletes prompt_feedback and hydrates from conversation_details.feedback — shapes match this PR.

Companion FE: [chat_web_app#101](https://git.aimloperations.com/ai_ml_operations/chat_web_app/pulls/101) already posts/deletes `prompt_feedback` and hydrates from `conversation_details.feedback` — shapes match this PR.
westfarn merged commit 2aeb95136a into master 2026-08-04 03:23:58 -07:00
westfarn deleted branch feature/prompt-feedback-api-67 2026-08-04 03:23:59 -07:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ai_ml_operations/chat_backend#70