Skip to content

Commit

Permalink
Added: chat completions context tests (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Apr 4, 2023
1 parent 825804c commit df50bcc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,25 @@ def test_get_context_no_keywords(self):
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())

# Placeholder - tests when model_type == 'v1/chat/completions'
def test_get_context_v1_chat_completions(self):
test_data_file = 'tests/test_context_data.txt'
tag = 'Tag1'
question = 'What is the population of Australia?'
model_name = 'gpt-3'
max_context_length = 50
model_type = 'v1/chat/completions'

expected_context = [
{'role': 'user', 'content': 'what is the capital of australia?'},
{'role': 'assistant', 'content': 'The capital of Australia is Canberra.'},
{'role': 'user', 'content': 'when was it founded?'},
{'role': 'assistant', 'content': "Canberra was founded in 1913 as the site for Australia's capital city."},
{'role': 'user', 'content': question},
]

result = get_context(tag, max_context_length, test_data_file, model_name, model_type=model_type, question=question)
self.assertEqual(result, expected_context)


if __name__ == '__main__':
unittest.main()

0 comments on commit df50bcc

Please sign in to comment.