mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
feat(anthropic): add User-Agent header for Anthropic API calls (#35268)
This commit is contained in:
@@ -53,6 +53,15 @@ def test_initialization() -> None:
|
||||
assert model.anthropic_api_url == "https://api.anthropic.com"
|
||||
|
||||
|
||||
def test_user_agent_header_in_client_params() -> None:
|
||||
"""Test that _client_params includes a User-Agent header."""
|
||||
llm = ChatAnthropic(model=MODEL_NAME, api_key="test-key") # type: ignore[arg-type]
|
||||
params = llm._client_params
|
||||
assert "default_headers" in params
|
||||
assert "User-Agent" in params["default_headers"]
|
||||
assert params["default_headers"]["User-Agent"].startswith("langchain-anthropic/")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("async_api", [True, False])
|
||||
def test_streaming_attribute_should_stream(async_api: bool) -> None: # noqa: FBT001
|
||||
llm = ChatAnthropic(model=MODEL_NAME, streaming=True)
|
||||
|
||||
Reference in New Issue
Block a user