feat: transparent anthropic api incl. native anthropic api backend
This commit is contained in:
parent
c9e495876b
commit
1d012a92ef
11 changed files with 1431 additions and 20 deletions
|
|
@ -70,6 +70,16 @@ def llama_endpoints(cfg) -> list:
|
|||
return list(dict.fromkeys([*cfg.llama_server_endpoints, *cfg.llama_swap_endpoints]))
|
||||
|
||||
|
||||
def is_anthropic_endpoint(endpoint: str) -> bool:
|
||||
"""True if the endpoint is a configured native Anthropic Messages-API backend.
|
||||
|
||||
These speak the Anthropic wire format (``x-api-key`` / ``anthropic-version``
|
||||
headers, ``/v1/messages``), not OpenAI Chat Completions, so requests routed to
|
||||
them are forwarded verbatim rather than translated.
|
||||
"""
|
||||
return endpoint in get_config().anthropic_endpoints
|
||||
|
||||
|
||||
def is_ext_openai_endpoint(endpoint: str) -> bool:
|
||||
"""
|
||||
Determine if an endpoint is an external OpenAI-compatible endpoint (not Ollama, llama-server or llama-swap).
|
||||
|
|
@ -117,8 +127,8 @@ def get_tracking_model(endpoint: str, model: str) -> str:
|
|||
|
||||
This ensures consistent model naming across all routes for usage tracking.
|
||||
"""
|
||||
# External OpenAI endpoints are not shown in PS, keep as-is
|
||||
if is_ext_openai_endpoint(endpoint):
|
||||
# External OpenAI / native Anthropic endpoints are not shown in PS, keep as-is
|
||||
if is_ext_openai_endpoint(endpoint) or is_anthropic_endpoint(endpoint):
|
||||
return model
|
||||
|
||||
# llama-server / llama-swap endpoints use normalized names in PS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue