feat(cloud): support Anthropic provider base URL
Tests / Test passed: 665

This commit is contained in:
2026-07-14 07:58:38 +08:00
parent 8b7e5a2800
commit 9250254dec
13 changed files with 124 additions and 39 deletions
+31
View File
@@ -1,7 +1,9 @@
from __future__ import annotations
import base64
import sys
from typing import Any
from types import SimpleNamespace
import pytest
@@ -124,6 +126,35 @@ def test_anthropic_tool_calling_client_includes_image_block_when_screenshot_pres
assert content[1] == {"type": "text", "text": "user"}
def test_anthropic_tool_calling_client_passes_custom_base_url_to_sdk(
monkeypatch,
) -> None:
constructed: list[dict[str, Any]] = []
class RecordingAnthropic:
def __init__(self, **kwargs: str) -> None:
constructed.append(kwargs)
monkeypatch.setitem(
sys.modules,
"anthropic",
SimpleNamespace(Anthropic=RecordingAnthropic),
)
client = AnthropicToolCallingClient(
model="test-model",
api_key="managed-api-key",
base_url="https://anthropic-proxy.example",
)
assert isinstance(client._client(), RecordingAnthropic)
assert constructed == [
{
"api_key": "managed-api-key",
"base_url": "https://anthropic-proxy.example",
}
]
def test_anthropic_tool_calling_client_wraps_transport_errors() -> None:
messages = FakeMessages(error=TimeoutError("timed out"))
client = AnthropicToolCallingClient(model="test-model", transport=FakeTransport(messages))