Skip to content

Response Rating (Like/Dislike + Comment) #56

@pawelkiszczak

Description

@pawelkiszczak

Response Rating (Like/Dislike + Comment)

Allow users to rate agent responses — creating a feedback loop for evaluation.

Backend

New model: MessageRating

class MessageRating(Base):
    id: uuid.UUID
    message_id: uuid.UUID       # FK → Message
    user_id: uuid.UUID          # FK → User
    rating: int                 # 1 = like, -1 = dislike
    comment: str | None         # Optional comment
    created_at: datetime

    __table_args__ = (
        UniqueConstraint("message_id", "user_id"),
    )

Endpoints

POST   /conversations/{conv_id}/messages/{msg_id}/rate    — {rating: 1|-1, comment?: str}
DELETE /conversations/{conv_id}/messages/{msg_id}/rate    — Remove rating
GET    /admin/ratings                                     — List ratings (admin)
GET    /admin/ratings/summary                             — Aggregated stats

Schema update

In schemas/conversation.py, update MessageRead to include:

  • user_rating: int | None
  • rating_count: dict | None

Frontend

Thumbs in message-item.tsx

Under each assistant message (currently: copy button, timestamps):

  • 👍 / 👎 toggle buttons (lucide-react icons — already in the project)
  • After 👎 → textarea: "What went wrong?" + Submit button
  • Toast: "Thanks for your feedback" (using sonner — already in the project)

Admin dashboard

New page: /admin/ratings

  • Chart of likes/dislikes per day (recharts or chart.js)
  • List of negative ratings with comments (sortable, filterable)
  • Link to the related conversation for each rating

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions