Rebase onto upstream (a4d95fd) #12

Closed
wylab wants to merge 144 commits from rebase-onto-upstream into main
Showing only changes of commit 330ecb2beb - Show all commits
+9 -14
View File
@@ -46,19 +46,14 @@ class AnthropicOAuthProvider(LLMProvider):
return f"{self.api_base.rstrip('/')}/v1/messages" return f"{self.api_base.rstrip('/')}/v1/messages"
return self.ANTHROPIC_API_URL return self.ANTHROPIC_API_URL
# Short aliases that need dated suffixes for the API @staticmethod
MODEL_ALIASES: dict[str, str] = { def _normalize_model(model: str) -> str:
"claude-sonnet-4": "claude-sonnet-4-20250514", """Normalize model name for the Anthropic API.
"claude-opus-4": "claude-opus-4-20250514",
"claude-haiku-3-5": "claude-haiku-4-5-20241022",
"claude-sonnet-4-5": "claude-sonnet-4-5-20250929",
"claude-opus-4-5": "claude-opus-4-5-20250929",
"claude-opus-4-6": "claude-opus-4-6",
}
def _resolve_model_alias(self, model: str) -> str: Anthropic model IDs use hyphens (claude-sonnet-4-5), but users often
"""Resolve short model aliases to full dated IDs.""" write dots (claude-sonnet-4.5). Normalize so both work.
return self.MODEL_ALIASES.get(model, model) """
return model.replace(".", "-")
async def _get_client(self) -> httpx.AsyncClient: async def _get_client(self) -> httpx.AsyncClient:
"""Get or create async HTTP client.""" """Get or create async HTTP client."""
@@ -253,8 +248,8 @@ class AnthropicOAuthProvider(LLMProvider):
if "/" in model: if "/" in model:
model = model.split("/")[-1] model = model.split("/")[-1]
# Resolve short aliases to dated model IDs (API requires dated suffixes) # Normalize dots to hyphens (claude-sonnet-4.5 -> claude-sonnet-4-5)
model = self._resolve_model_alias(model) model = self._normalize_model(model)
system, prepared_messages = self._prepare_messages(messages) system, prepared_messages = self._prepare_messages(messages)
anthropic_tools = self._convert_tools_to_anthropic(tools) anthropic_tools = self._convert_tools_to_anthropic(tools)