mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Update OpenAI chat actor tests to handle more questions being extracted
This commit is contained in:
parent
03befc9b12
commit
241b9009ba
1 changed files with 8 additions and 13 deletions
|
@ -88,15 +88,12 @@ def test_extract_question_with_date_filter_from_relative_year():
|
||||||
@pytest.mark.chatquality
|
@pytest.mark.chatquality
|
||||||
def test_extract_multiple_explicit_questions_from_message():
|
def test_extract_multiple_explicit_questions_from_message():
|
||||||
# Act
|
# Act
|
||||||
response = extract_questions("What is the Sun? What is the Moon?")
|
responses = extract_questions("What is the Sun? What is the Moon?")
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
expected_responses = [
|
assert len(responses) >= 2
|
||||||
("sun", "moon"),
|
assert any(["sun" in response.lower() or "moon" in response.lower() for response in responses]), (
|
||||||
]
|
"Expected sun or moon mentioned in generated search queries but got: " + responses
|
||||||
assert len(response) == 2
|
|
||||||
assert any([start in response[0].lower() and end in response[1].lower() for start, end in expected_responses]), (
|
|
||||||
"Expected two search queries in response but got: " + response[0]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,11 +122,10 @@ def test_generate_search_query_using_question_from_chat_history():
|
||||||
]
|
]
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
response = extract_questions("Does he have any sons?", conversation_log=populate_chat_history(message_list))
|
responses = extract_questions("Does he have any sons?", conversation_log=populate_chat_history(message_list))
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert len(response) == 1
|
assert all(["Vader" in response for response in responses])
|
||||||
assert "Vader" in response[0]
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@ -141,11 +137,10 @@ def test_generate_search_query_using_answer_from_chat_history():
|
||||||
]
|
]
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
response = extract_questions("Is she a Jedi?", conversation_log=populate_chat_history(message_list))
|
responses = extract_questions("Is she a Jedi?", conversation_log=populate_chat_history(message_list))
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert len(response) == 1
|
assert all(["Leia" in response for response in responses])
|
||||||
assert "Leia" in response[0]
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue