mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-10 20:22:26 +00:00
test - async claude streaming
This commit is contained in:
@@ -831,22 +831,25 @@ def test_bedrock_claude_3_streaming():
|
||||
pytest.fail(f"Error occurred: {e}")
|
||||
|
||||
|
||||
def test_claude_3_streaming_finish_reason():
|
||||
@pytest.mark.asyncio
|
||||
async def test_claude_3_streaming_finish_reason():
|
||||
try:
|
||||
litellm.set_verbose = True
|
||||
messages = [
|
||||
{"role": "system", "content": "Be helpful"},
|
||||
{"role": "user", "content": "What do you know?"},
|
||||
]
|
||||
response: ModelResponse = completion( # type: ignore
|
||||
response: ModelResponse = await litellm.acompletion( # type: ignore
|
||||
model="claude-3-opus-20240229",
|
||||
messages=messages,
|
||||
stream=True,
|
||||
max_tokens=10,
|
||||
)
|
||||
complete_response = ""
|
||||
# Add any assertions here to check the response
|
||||
num_finish_reason = 0
|
||||
for idx, chunk in enumerate(response):
|
||||
async for chunk in response:
|
||||
print(f"chunk: {chunk}")
|
||||
if isinstance(chunk, ModelResponse):
|
||||
if chunk.choices[0].finish_reason is not None:
|
||||
num_finish_reason += 1
|
||||
|
||||
Reference in New Issue
Block a user