From fc797fadf4deac90b18c2ab8f0beb505f2517567 Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Thu, 8 May 2025 11:03:31 -0400 Subject: [PATCH] x --- .../integration_tests/test_chat_models.py | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py b/libs/partners/anthropic/tests/integration_tests/test_chat_models.py index a43d0383545..0fe97e80366 100644 --- a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py +++ b/libs/partners/anthropic/tests/integration_tests/test_chat_models.py @@ -8,47 +8,6 @@ from langchain_anthropic import ChatAnthropic, ChatAnthropicMessages MODEL_NAME = "claude-3-5-haiku-latest" - -def test_stream() -> None: - """Test streaming tokens from Anthropic.""" - llm = ChatAnthropicMessages(model_name=MODEL_NAME) # type: ignore[call-arg, call-arg] - - full: Optional[BaseMessageChunk] = None - chunks_with_input_token_counts = 0 - chunks_with_output_token_counts = 0 - chunks_with_model_name = 0 - for token in llm.stream("I'm Pickle Rick"): - assert isinstance(token.content, str) - full = token if full is None else full + token - assert isinstance(token, AIMessageChunk) - if token.usage_metadata is not None: - if token.usage_metadata.get("input_tokens"): - chunks_with_input_token_counts += 1 - if token.usage_metadata.get("output_tokens"): - chunks_with_output_token_counts += 1 - chunks_with_model_name += int("model_name" in token.response_metadata) - if chunks_with_input_token_counts != 1 or chunks_with_output_token_counts != 1: - raise AssertionError( - "Expected exactly one chunk with input or output token counts. " - "AIMessageChunk aggregation adds counts. Check that " - "this is behaving properly." - ) - assert chunks_with_model_name == 1 - # check token usage is populated - assert isinstance(full, AIMessageChunk) - assert full.usage_metadata is not None - assert full.usage_metadata["input_tokens"] > 0 - assert full.usage_metadata["output_tokens"] > 0 - assert full.usage_metadata["total_tokens"] > 0 - assert ( - full.usage_metadata["input_tokens"] + full.usage_metadata["output_tokens"] - == full.usage_metadata["total_tokens"] - ) - assert "stop_reason" in full.response_metadata - assert "stop_sequence" in full.response_metadata - assert "model_name" in full.response_metadata - - async def test_astream() -> None: """Test streaming tokens from Anthropic.""" llm = ChatAnthropicMessages(model_name=MODEL_NAME) # type: ignore[call-arg, call-arg]