mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 07:17:54 +08:00
core/runtime: plumb anthropic HTTP timeout
This commit is contained in:
@@ -106,10 +106,15 @@ def create_client(provider: Provider, *, model: str | None = None) -> ProtocolCl
|
||||
if effective.preset == "deepseek":
|
||||
return DeepseekOpenAIClient(provider_to_openai_config(effective))
|
||||
if effective.preset == "anthropic":
|
||||
try:
|
||||
http_timeout = normalize_http_timeout(effective.timeout)
|
||||
except InvalidHttpTimeoutError as exc:
|
||||
raise ProviderNotSupportedError(str(exc)) from exc
|
||||
return AnthropicClient(
|
||||
AnthropicConfigCls(
|
||||
api_key=effective.access_key_or_token,
|
||||
base_url=effective.url or DEFAULT_ANTHROPIC_BASE_URL,
|
||||
timeout=http_timeout,
|
||||
)
|
||||
)
|
||||
msg = f"provider preset {effective.preset!r} is not supported"
|
||||
|
||||
@@ -73,13 +73,15 @@ def test_deepseek_ignores_legacy_convention_extra() -> None:
|
||||
assert isinstance(client, DeepseekOpenAIClient)
|
||||
|
||||
|
||||
def test_anthropic_not_implemented() -> None:
|
||||
def test_anthropic_client_created() -> None:
|
||||
from plyngent.lmproto.anthropic import AnthropicClient
|
||||
|
||||
provider = AnthropicProvider(access_key_or_token="sk-test")
|
||||
provider = AnthropicProvider(access_key_or_token="sk-test", timeout=30)
|
||||
client = create_client(provider)
|
||||
assert isinstance(client, AnthropicClient)
|
||||
assert client.kind == "messages"
|
||||
# timeout is passed through to the niquests session
|
||||
assert client.session.timeout == 30
|
||||
|
||||
|
||||
def test_model_level_preset_url_overrides_parent() -> None:
|
||||
|
||||
Reference in New Issue
Block a user