MCPcopy Create free account
hub / github.com/SuperJJ007/CSSwitch / normalize_openai_base

Function normalize_openai_base

proxy/csswitch_proxy.py:322–330  ·  view source on GitHub ↗

OpenAI 兼容端点存 base root。用户若误填到 /chat/completions 或 /models, 这里收敛回 root,避免后续双拼。

(base)

Source from the content-addressed store, hash-verified

320
321
322def normalize_openai_base(base):
323 """OpenAI 兼容端点存 base root。用户若误填到 /chat/completions 或 /models,
324 这里收敛回 root,避免后续双拼。"""
325 b = (base or "").strip().rstrip("/")
326 for suffix in ("/v1/chat/completions", "/chat/completions",
327 "/v1/responses", "/responses", "/v1/models", "/models"):
328 if b.endswith(suffix):
329 b = b[: -len(suffix)].rstrip("/")
330 return b
331
332
333def _ends_with_version_segment(base):

Callers 2

openai_endpointFunction · 0.85
csswitch_proxy.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected