mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
refactor: 提取 is_codex_url 到公共 utils 模块
将重复的 Codex URL 判断逻辑提取到 src/utils/url_utils.py, 避免 transport.py 和 adapter.py 中的代码重复。
This commit is contained in:
@@ -20,6 +20,7 @@ from src.core.api_format import (
|
||||
)
|
||||
from src.core.logger import logger
|
||||
from src.services.provider.format import normalize_endpoint_signature
|
||||
from src.utils.url_utils import is_codex_url
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from src.models.database import ProviderAPIKey, ProviderEndpoint
|
||||
@@ -148,7 +149,7 @@ def build_provider_url(
|
||||
path = _resolve_default_path(endpoint_sig)
|
||||
# Codex OAuth 端点(chatgpt.com/backend-api/codex)使用 /responses 而非 /v1/responses
|
||||
base_url = getattr(endpoint, "base_url", "") or ""
|
||||
if endpoint_sig == "openai:cli" and _is_codex_url(base_url):
|
||||
if endpoint_sig == "openai:cli" and is_codex_url(base_url):
|
||||
path = "/responses"
|
||||
if effective_path_params:
|
||||
try:
|
||||
@@ -195,15 +196,6 @@ def _resolve_default_path(endpoint_sig: str | None) -> str:
|
||||
return "/"
|
||||
|
||||
|
||||
def _is_codex_url(base_url: str) -> bool:
|
||||
"""判断是否是 Codex OAuth 端点(如 chatgpt.com/backend-api/codex)。
|
||||
|
||||
Codex 端点不走标准 /v1 前缀,直接使用 /responses。
|
||||
"""
|
||||
url = base_url.rstrip("/")
|
||||
return "/backend-api/codex" in url or url.endswith("/codex")
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Vertex AI 配置
|
||||
# ==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user