Skip to content

Commit

Permalink
Modified: context tests to validate max_context_length (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Apr 4, 2023
1 parent b43d9b6 commit f747672
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ def test_get_context_keywords_only(self):
result = get_context("Tag1", 50, "tests/test_context_data.txt", "text-davinci-003", context_keywords_only=True, question="Who is its mayor?")
expected = "australia canberra 's capital city Who is its mayor?"
self.assertEqual(result.strip(), expected.strip())
self.assertLessEqual(len(result.split()), 50)


def test_get_context_no_keywords(self):
result = get_context("Tag1", 50, "tests/test_context_data.txt", "text-davinci-003", context_keywords_only=False, question="Who is its mayor?")
expected = "what is the capital of australia? The capital of Australia is Canberra. when was it founded? Canberra was founded in 1913 as the site for Australia's capital city. Who is its mayor?"
self.assertEqual(result.strip(), expected.strip())
self.assertLessEqual(len(result.split()), 50)

def test_get_context_v1_chat_completions(self):
test_data_file = 'tests/test_context_data.txt'
Expand All @@ -36,6 +39,7 @@ def test_get_context_v1_chat_completions(self):

result = get_context(tag, max_context_length, test_data_file, model_name, model_type=model_type, question=question)
self.assertEqual(result, expected_context)
self.assertLessEqual(sum(len(item["content"].split()) for item in result), 50)


if __name__ == '__main__':
Expand Down

0 comments on commit f747672

Please sign in to comment.