diff --git a/tests/test_gpt4all_chat_director.py b/tests/test_gpt4all_chat_director.py index 111a6a12..6da7f759 100644 --- a/tests/test_gpt4all_chat_director.py +++ b/tests/test_gpt4all_chat_director.py @@ -1,10 +1,13 @@ +# Standard Packages +import urllib.parse + # External Packages import pytest from freezegun import freeze_time from faker import Faker - # Internal Packages +from khoj.processor.conversation import prompts from khoj.processor.conversation.utils import message_to_log from khoj.utils import state @@ -172,6 +175,57 @@ def test_no_answer_in_chat_history_or_retrieved_content(client_offline_chat): ) +# ---------------------------------------------------------------------------------------------------- +@pytest.mark.chatquality +def test_answer_using_general_command(client_offline_chat): + # Arrange + query = urllib.parse.quote("/general Where was Xi Li born?") + message_list = [] + populate_chat_history(message_list) + + # Act + response = client_offline_chat.get(f"/api/chat?q={query}&stream=true") + response_message = response.content.decode("utf-8") + + # Assert + assert response.status_code == 200 + assert "Fujiang" not in response_message + + +# ---------------------------------------------------------------------------------------------------- +@pytest.mark.chatquality +def test_answer_from_retrieved_content_using_notes_command(client_offline_chat): + # Arrange + query = urllib.parse.quote("/notes Where was Xi Li born?") + message_list = [] + populate_chat_history(message_list) + + # Act + response = client_offline_chat.get(f"/api/chat?q={query}&stream=true") + response_message = response.content.decode("utf-8") + + # Assert + assert response.status_code == 200 + assert "Fujiang" in response_message + + +# ---------------------------------------------------------------------------------------------------- +@pytest.mark.chatquality +def test_answer_not_known_using_notes_command(client_offline_chat): + # Arrange + query = urllib.parse.quote("/notes Where was Testatron born?") + message_list = [] + populate_chat_history(message_list) + + # Act + response = client_offline_chat.get(f"/api/chat?q={query}&stream=true") + response_message = response.content.decode("utf-8") + + # Assert + assert response.status_code == 200 + assert response_message == prompts.no_notes_found.format() + + # ---------------------------------------------------------------------------------------------------- @pytest.mark.xfail(AssertionError, reason="Chat director not capable of answering time aware questions yet") @pytest.mark.chatquality