-
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 #702 from dimagi/cs/show_routing_tags_in_convo
Show routing tag in web UI when "debug mode" is enabled
- Loading branch information
Showing
19 changed files
with
205 additions
and
35 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 on 2024-10-02 13:18 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('annotations', '0005_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')], 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
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
18 changes: 18 additions & 0 deletions
18
apps/experiments/migrations/0095_experiment_debug_mode_enabled.py
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 on 2024-10-02 07:51 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('experiments', '0094_consentform_working_version_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='experiment', | ||
name='debug_mode_enabled', | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
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
Empty file.
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,31 @@ | ||
import pytest | ||
|
||
from apps.chat.models import ChatMessage, ChatMessageType | ||
from apps.service_providers.llm_service.state import AssistantExperimentState, ChatExperimentState | ||
from apps.utils.factories.experiment import ExperimentSessionFactory | ||
|
||
|
||
@pytest.fixture() | ||
def session(): | ||
return ExperimentSessionFactory() | ||
|
||
|
||
# TODO: I need more tests please! | ||
@pytest.mark.django_db() | ||
class TestChatExperimentState: | ||
def test_save_message_to_history_stores_ai_message_on_state(self, session): | ||
state = ChatExperimentState(session=session, experiment=session.experiment) | ||
state.save_message_to_history(message="hi", type_=ChatMessageType.HUMAN) | ||
assert state.ai_message is None | ||
state.save_message_to_history(message="hi human", type_=ChatMessageType.AI) | ||
assert state.ai_message == ChatMessage.objects.get(message_type=ChatMessageType.AI) | ||
|
||
|
||
@pytest.mark.django_db() | ||
class TestAssistantExperimentState: | ||
def test_save_message_to_history_stores_ai_message_on_state(self, session): | ||
state = AssistantExperimentState(session=session, experiment=session.experiment) | ||
state.save_message_to_history(message="hi", type_=ChatMessageType.HUMAN) | ||
assert state.ai_message is None | ||
state.save_message_to_history(message="hi human", type_=ChatMessageType.AI) | ||
assert state.ai_message == ChatMessage.objects.get(message_type=ChatMessageType.AI) |
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 |
---|---|---|
@@ -1,9 +1,21 @@ | ||
{% load chat_tags %} | ||
<div class="chat-message-system flex flex-col" data-last-message-datetime="{{ created_at_datetime|safe }}"> | ||
<div class="flex flex-row"> | ||
{% include "experiments/chat/components/system_icon.html" %} | ||
<div class="message-contents"> | ||
<p>{{ message_text|render_markdown }}</p> | ||
<div class="flex flex-col gap-1"> | ||
{% if experiment.debug_mode_enabled %} | ||
<div> | ||
{% if message.get_safety_layer_tag_name %} | ||
<div class="badge badge-sm badge-error">Safety Layer '{{ message.get_safety_layer_tag_name }}' Triggered</div> | ||
{% endif %} | ||
{% if experiment.debug_mode_enabled and message.get_processor_bot_tag_name %} | ||
<div class="badge badge-sm badge-warning">Routed to {{ message.get_processor_bot_tag_name }}</div> | ||
{% endif %} | ||
</div> | ||
{% endif %} | ||
<div class="chat-message-system flex flex-col" data-last-message-datetime="{{ created_at_datetime|safe }}"> | ||
<div class="flex flex-row"> | ||
{% include "experiments/chat/components/system_icon.html" %} | ||
<div class="message-contents"> | ||
<p>{{ message.content|render_markdown }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.