Fix chat tests since streaming. Pass args correctly to chat methods

- Fix testing gpt converse method after it started streaming responses
- Pass stop in model_kwargs dictionary and api key in openai_api_key
  parameter to chat completion methods. This should resolve the arg
  warning thrown by OpenAI module
This commit is contained in:
Debanjum Singh Solanky
2023-07-07 15:23:44 -07:00
parent 48870d9170
commit 11f0a9f196
3 changed files with 42 additions and 33 deletions

View File

@@ -186,11 +186,12 @@ def test_generate_search_query_with_date_and_context_from_chat_history():
@pytest.mark.chatquality
def test_chat_with_no_chat_history_or_retrieved_content():
# Act
response = converse(
response_gen = converse(
references=[], # Assume no context retrieved from notes for the user_query
user_query="Hello, my name is Testatron. Who are you?",
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
expected_responses = ["Khoj", "khoj"]
@@ -210,12 +211,13 @@ def test_answer_from_chat_history_and_no_content():
]
# Act
response = converse(
response_gen = converse(
references=[], # Assume no context retrieved from notes for the user_query
user_query="What is my name?",
conversation_log=populate_chat_history(message_list),
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
expected_responses = ["Testatron", "testatron"]
@@ -240,12 +242,13 @@ def test_answer_from_chat_history_and_previously_retrieved_content():
]
# Act
response = converse(
response_gen = converse(
references=[], # Assume no context retrieved from notes for the user_query
user_query="Where was I born?",
conversation_log=populate_chat_history(message_list),
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
assert len(response) > 0
@@ -264,7 +267,7 @@ def test_answer_from_chat_history_and_currently_retrieved_content():
]
# Act
response = converse(
response_gen = converse(
references=[
"Testatron was born on 1st April 1984 in Testville."
], # Assume context retrieved from notes for the user_query
@@ -272,6 +275,7 @@ def test_answer_from_chat_history_and_currently_retrieved_content():
conversation_log=populate_chat_history(message_list),
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
assert len(response) > 0
@@ -289,12 +293,13 @@ def test_refuse_answering_unanswerable_question():
]
# Act
response = converse(
response_gen = converse(
references=[], # Assume no context retrieved from notes for the user_query
user_query="Where was I born?",
conversation_log=populate_chat_history(message_list),
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
expected_responses = [
@@ -329,11 +334,12 @@ Expenses:Food:Dining 10.00 USD""",
]
# Act
response = converse(
response_gen = converse(
references=context, # Assume context retrieved from notes for the user_query
user_query="What did I have for Dinner today?",
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
expected_responses = ["tacos", "Tacos"]
@@ -360,11 +366,12 @@ Expenses:Food:Dining 10.00 USD""",
]
# Act
response = converse(
response_gen = converse(
references=context, # Assume context retrieved from notes for the user_query
user_query="How much did I spend on dining this year?",
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
assert len(response) > 0
@@ -383,12 +390,13 @@ def test_answer_general_question_not_in_chat_history_or_retrieved_content():
]
# Act
response = converse(
response_gen = converse(
references=[], # Assume no context retrieved from notes for the user_query
user_query="Write a haiku about unit testing in 3 lines",
conversation_log=populate_chat_history(message_list),
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
expected_responses = ["test", "Test"]
@@ -414,11 +422,12 @@ My sister, Aiyla is married to Tolga. They have 3 kids, Yildiz, Ali and Ahmet.""
]
# Act
response = converse(
response_gen = converse(
references=context, # Assume context retrieved from notes for the user_query
user_query="How many kids does my older sister have?",
api_key=api_key,
)
response = "".join([response_chunk for response_chunk in response_gen])
# Assert
expected_responses = ["which sister", "Which sister", "which of your sister", "Which of your sister"]