Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion astrbot/core/provider/sources/anthropic_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ def _create_http_client(self, provider_config: dict) -> httpx.AsyncClient | None
try:
from anthropic import _base_client as anthropic_base_client

httpx_module = getattr(anthropic_base_client, "httpx", httpx)
httpx_module = getattr(
anthropic_base_client,
"httpx2",
getattr(anthropic_base_client, "httpx", httpx),
)
except ImportError:
pass
return create_proxy_client(
Expand Down
8 changes: 7 additions & 1 deletion tests/test_anthropic_kimi_code_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,13 @@ def fake_create_proxy_client(
assert captured["provider_label"] == "Anthropic"
assert captured["proxy"] == "http://127.0.0.1:7890"
assert captured["headers"] == {"X-Trace-Id": "trace-1"}
assert captured["httpx_module"] is anthropic_base_client.httpx
sdk_httpx = getattr(
anthropic_base_client,
"httpx2",
getattr(anthropic_base_client, "httpx", None),
)
assert sdk_httpx is not None
assert captured["httpx_module"] is sdk_httpx


def test_create_http_client_falls_back_to_global_httpx_module(monkeypatch):
Expand Down
Loading