Skip to content

Commit

Permalink
Merge pull request #77 from wagtail/feature/add-litellm-chat-streamin…
Browse files Browse the repository at this point in the history
…g-test

Feature/add litellm chat streaming test
  • Loading branch information
tomusher authored Aug 9, 2024
2 parents ea41b7d + 870c200 commit ba35e82
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ requires-python = ">=3.11"
dependencies = [
"Django>=4.2",
"Wagtail>=5.2",
"litellm>=1.41.15",
"litellm>=1.43.2",
"openai>=1.28.1",
"aiohttp>=3.9.0b0; python_version >= '3.12'",
]
Expand Down
17 changes: 17 additions & 0 deletions tests/test_ai_utils/test_backends/test_litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@ def test_litellm_chat(make_chat_backend):
assert response.choices[0] == response_text


@if_litellm_installed
def test_litellm_streaming_chat(make_chat_backend):
backend = make_chat_backend()
input_text = "Little trotty wagtail, he waddled in the mud."
response_text = "And left his little footmarks, trample where he would."
messages: List[ChatMessage] = [
{"content": message, "role": "user"} for message in input_text
]
response = backend.chat(messages=messages, stream=True, mock_response=response_text)

full_text = ""
for chunk in response:
full_text += chunk["content"]

assert full_text == response_text


@if_litellm_installed
async def test_litellm_async_chat(make_chat_backend):
backend = make_chat_backend()
Expand Down

0 comments on commit ba35e82

Please sign in to comment.