OpenAI LLM: update modelname_to_contextsize with new models (#2843)

Token counts pulled from https://openai.com/pricing
This commit is contained in:
Tim Asp
2023-04-13 11:13:34 -07:00
committed by GitHub
parent 82d1d5f24e
commit be4fb24b32
2 changed files with 42 additions and 21 deletions

View File

@@ -211,3 +211,14 @@ async def test_openai_chat_async_streaming_callback() -> None:
result = await llm.agenerate(["Write me a sentence with 100 words."])
assert callback_handler.llm_streams != 0
assert isinstance(result, LLMResult)
def test_openai_modelname_to_contextsize_valid() -> None:
"""Test model name to context size on a valid model."""
assert OpenAI().modelname_to_contextsize("davinci") == 2049
def test_openai_modelname_to_contextsize_invalid() -> None:
"""Test model name to context size on an invalid model."""
with pytest.raises(ValueError):
OpenAI().modelname_to_contextsize("foobar")