Skip to content

Commit

Permalink
Add streaming callback test
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje committed Mar 8, 2024
1 parent 21f17ea commit 67e9e5d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions integrations/amazon_bedrock/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,24 @@ def test_default_inference_params(self, model_name):
assert response["replies"][0].content
assert ChatMessage.is_from(response["replies"][0], ChatRole.ASSISTANT)
assert "paris" in response["replies"][0].content.lower()

@pytest.mark.parametrize(
"model_name", ["anthropic.claude-3-sonnet-20240229-v1:0", "anthropic.claude-v2:1", "meta.llama2-13b-chat-v1"]
)
@pytest.mark.integration
def test_default_inference_with_streaming(self, model_name):

callback_called = False

def streaming_callback_verifier(chunk):
nonlocal callback_called
callback_called = True

messages = [
ChatMessage.from_system("\\nYou are a helpful assistant, be super brief in your responses."),
ChatMessage.from_user("What's the capital of France?"),
]

client = AmazonBedrockChatGenerator(model=model_name, streaming_callback=streaming_callback_verifier)
client.run(messages)
assert callback_called

0 comments on commit 67e9e5d

Please sign in to comment.