Skip to content
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

✨ feat: Add Message Feedback with Tag Options #5878

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rubentalstra
Copy link
Collaborator

@rubentalstra rubentalstra commented Feb 14, 2025

Summary

This PR introduces an enhanced message feedback system that allows users to rate responses with either a thumbs up or thumbs down. For negative feedback (thumbs down), users can now provide additional context through a set of predefined feedback tags and an optional text comment. This additional feedback helps us better understand and improve our responses.

Closes: #901

Changes Overview

Backend Updates

  • Message Schema Enhancements:

    • Updated the messageSchema in api/models/schema/messageSchema.js to include a structured ratingContent object with tags, tagChoices, and text.
  • New Feedback API Route:

    • Added a new endpoint in api/server/routes/messages.js (PUT /:conversationId/:messageId/feedback) that handles feedback updates.
    • Implements default tag choices for thumbs-down feedback if none are provided.
  • Data Provider & Types:

    • Updated API endpoints in packages/data-provider/src/api-endpoints.ts to include a feedback endpoint.
    • Extended the data service in packages/data-provider/src/data-service.ts with an updateFeedback function.
    • Added a new react-query mutation (useUpdateFeedbackMutation) in packages/data-provider/src/react-query/react-query-service.ts.
    • Revised schemas (packages/data-provider/src/schemas.ts) and types (packages/data-provider/src/types.ts) to reflect the new feedback properties.

Frontend Updates

  • New Feedback UI Component:

    • Introduced FeedbackTagOptions.tsx to display a list of predefined feedback tags for users to select when providing negative feedback.
  • Enhanced Message Interaction:

    • Updated HoverButtons.tsx to include new thumbs up/down icons and to correctly handle feedback submission.
    • Modified MessageRender.tsx to integrate the feedback component and display a thank-you message once feedback is submitted.
  • SVG Icon Additions:

    • Added new SVG components ThumbUpIcon.tsx and ThumbDownIcon.tsx for better visual feedback representation.
    • Updated the icon index in client/src/components/svg/index.ts for consistent exports.
  • Hook Updates:

    • Extended the useMessageActions hook to include the new feedback mutation, ensuring the UI reflects feedback changes immediately.

Localization & Miscellaneous

  • Updated translation strings in client/src/locales/en/translation.json for positive ("Good response") and negative ("Bad response") feedback messages.

Change Type

  • New feature (non-breaking change which adds functionality)
  • Translation update

Testing

Test Configuration:

  • Backend:

    • Tested the new /feedback API endpoint using Postman to ensure proper handling of feedback submissions, including defaulting tag choices for thumbs-down ratings.
  • Frontend:

    • Verified that clicking the thumbs up/down buttons triggers the correct feedback flow.
    • Confirmed that when a user submits a thumbs down rating, the FeedbackTagOptions component renders with predefined tags.
    • Ensured that after a tag is selected, a thank-you message appears for a few seconds.
    • Conducted local integration testing to verify UI updates and mutation flows.
  • General:

    • All local unit tests pass without errors.
    • No new warnings were introduced.

Checklist

  • My code adheres to this project's style guidelines.
  • I have performed a self-review of my own code.
  • I have commented on complex sections of the code.
  • I have updated relevant documentation.
  • My changes do not introduce new warnings.
  • Local unit tests pass with my changes.
  • Dependent changes have been merged and published in downstream modules.

TODO:
- needs some refactoring.
- needs some UI animations.
@rubentalstra rubentalstra changed the title feat: response feedback buttons positive and 'negative' feat: response feedback buttons positive and negative Feb 14, 2025
@rubentalstra rubentalstra changed the title feat: response feedback buttons positive and negative WIP feat: response feedback buttons positive and negative Feb 14, 2025
/>
) : showThankYou ? (
<div className="inline-flex rounded-lg border border-token-border-light p-4">
<div className="text-sm">Thanks for your feedback!</div>

Check failure

Code scanning / ESLint

disallow literal string Error

disallow literal string: Thanks for your feedback!
@rubentalstra rubentalstra changed the title WIP feat: response feedback buttons positive and negative WIP ✨ feat: Add Message Feedback with Tag Options Feb 15, 2025
@rubentalstra rubentalstra added the ✨ enhancement New feature or request label Feb 15, 2025
@rubentalstra
Copy link
Collaborator Author

rubentalstra commented Feb 15, 2025

Screenshot 2025-02-15 at 14 44 01
Screenshot 2025-02-15 at 14 44 24
Screenshot 2025-02-15 at 14 44 38
Screenshot 2025-02-15 at 14 44 43

@rubentalstra rubentalstra changed the title WIP ✨ feat: Add Message Feedback with Tag Options ✨ feat: Add Message Feedback with Tag Options Feb 15, 2025
<div className="min-h-[96px] w-full">
<div className="relative mt-2 flex w-full flex-col gap-3 rounded-lg border border-token-border-light p-4">
<div className="flex justify-between items-center">
<div className="text-sm text-token-text-secondary">Tell us more:</div>

Check failure

Code scanning / ESLint

disallow literal string Error

disallow literal string: Tell us more:
Comment on lines +91 to +93
<OGDialogTitle className="text-lg font-semibold leading-6 text-token-text-primary">
Provide additional feedback
</OGDialogTitle>

Check failure

Code scanning / ESLint

disallow literal string Error

disallow literal string:
Provide additional feedback
Comment on lines +112 to +114
<span className="absolute -top-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full bg-blue-500 text-white text-xs">
</span>

Check failure

Code scanning / ESLint

disallow literal string Error

disallow literal string:

Comment on lines +139 to +141
>
Submit
</button>

Check failure

Code scanning / ESLint

disallow literal string Error

disallow literal string: <button
type="button"
onClick={handleSubmit}
className={cn('btn btn-primary', !selectedTag && 'opacity-50 cursor-not-allowed')}
disabled={!selectedTag}
>
Submit
@walbercardoso
Copy link
Contributor

Nice work. Is the feedback I send stored somewhere?

@rubentalstra
Copy link
Collaborator Author

rubentalstra commented Feb 17, 2025

@walbercardoso yes this is stored on the message object.

https://github.com/danny-avila/LibreChat/pull/5878/files#diff-baba50088a01ce3750bbb41c95be6f4a812f82b942ff283389ba4605f4d107b0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Chat rating button
3 participants