10 lines
354 B
Python
10 lines
354 B
Python
|
|
"""OpenAI/Chat Completions 兼容基址规范化(多供应商共用)。"""
|
||
|
|
|
||
|
|
|
||
|
|
def normalize_openai_compatible_base_url(raw: str, *, fallback: str) -> str:
|
||
|
|
base = (raw or "").strip().rstrip("/") or fallback
|
||
|
|
for suffix in ("/v1/chat/completions", "/v1"):
|
||
|
|
if base.endswith(suffix):
|
||
|
|
base = base[: -len(suffix)]
|
||
|
|
return base
|