-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1004 from dimagi/cs/ui_feedback
👍👎 for UI feedback
- Loading branch information
Showing
10 changed files
with
108 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.1.2 on 2024-12-18 13:05 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('annotations', '0006_alter_tag_category'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='tag', | ||
name='category', | ||
field=models.CharField(blank=True, choices=[('bot_response', 'Bot Response'), ('safety_layer_response', 'Safety Layer Response'), ('experiment_version', 'Experiment Version'), ('response_rating', 'Response Rating')], default=''), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.http import Http404 | ||
from django.shortcuts import get_object_or_404, render | ||
|
||
from apps.chat.models import ChatMessage, ChatMessageType | ||
|
||
|
||
def rate_message(request, team_slug: str, message_id: int, rating: str): | ||
if rating not in ["👍", "👎"]: | ||
raise Http404() | ||
|
||
message = get_object_or_404(ChatMessage, id=message_id, message_type=ChatMessageType.AI) | ||
message.add_rating(rating) | ||
|
||
return render( | ||
request, | ||
template_name="experiments/chat/components/message_rating.html", | ||
context={ | ||
"team_slug": team_slug, | ||
"message": message, | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="flex flex-row gap-1" id="rating-{{message.id}}"> | ||
{% if message.rating %} | ||
<div class="text-sm">{{ message.rating }}</div> | ||
{% else %} | ||
<button | ||
hx-post="{% url 'experiments:rate_message' team_slug=team_slug message_id=message.id rating='👍' %}" | ||
hx-swap="outerHTML" | ||
hx-target="#rating-{{message.id}}" | ||
class="text-sm p-1 rounded-md hover:bg-gray-50" | ||
title="Good response"> | ||
👍 | ||
</button> | ||
<button | ||
hx-post="{% url 'experiments:rate_message' team_slug=team_slug message_id=message.id rating='👎' %}" | ||
hx-swap="outerHTML" | ||
hx-target="#rating-{{message.id}}" | ||
class="text-sm p-1 rounded-md hover:bg-gray-50" | ||
title="Bad response"> | ||
👎 | ||
</button> | ||
{% endif %} | ||
</div> |