Truncate message logs to below max supported prompt size by model

- Use tiktoken to count tokens for chat models
- Make conversation turns to add to prompt configurable via method
  argument to generate_chatml_messages_with_context method
This commit is contained in:
Debanjum Singh Solanky
2023-03-25 04:37:55 +07:00
parent 4725416fbd
commit 7e36f421f9
4 changed files with 30 additions and 6 deletions

View File

@@ -47,7 +47,7 @@ def test_chat_with_no_chat_history_or_retrieved_content(chat_client):
expected_responses = ["Khoj", "khoj"]
assert response.status_code == 200
assert any([expected_response in response_message for expected_response in expected_responses]), (
"Expected assistants name, [K|k]hoj, in response but got" + response_message
"Expected assistants name, [K|k]hoj, in response but got: " + response_message
)
@@ -69,7 +69,7 @@ def test_answer_from_chat_history(chat_client):
expected_responses = ["Testatron", "testatron"]
assert response.status_code == 200
assert any([expected_response in response_message for expected_response in expected_responses]), (
"Expected [T|t]estatron in response but got" + response_message
"Expected [T|t]estatron in response but got: " + response_message
)