Spaces:
Running
Running
File size: 835 Bytes
2e7b8ca a9e27c0 2e7b8ca a9e27c0 2e7b8ca a9e27c0 2e7b8ca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from __future__ import annotations
"""Public generation route classification shared by HTTP boundaries."""
from typing import Literal
type WireApi = Literal["messages", "responses", "gemini", "chat"]
_GEMINI_ACTIONS = (":generateContent", ":streamGenerateContent")
def generation_api(path: str) -> WireApi | None:
if path == "/v1/messages":
return "messages"
if path == "/v1/responses":
return "responses"
if path == "/v1/chat/completions":
return "chat"
if path.startswith("/v1beta/models/"):
return "gemini"
# Gemini SDKs with a custom base URL call /v1/models/... too. OpenAI clients
# share that prefix, so only Gemini generation methods are Gemini there.
if path.startswith("/v1/models/") and path.endswith(_GEMINI_ACTIONS):
return "gemini"
return None
|