mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
refactor: 移除 Python 后端源码,全面迁移至 Rust gateway 架构
- 删除全部 Python 源码 (src/) 及 Alembic 迁移脚本,归档至 _deprecated_py_src/ - 重构 Rust gateway ai_pipeline: 拆分 planner/finalize 模块,新增 contracts/adaptation 层 - 重组 handlers 模块为 admin/public/proxy/internal/shared 子模块结构 - 新增 executor 模块,引入 Rust 原生数据库迁移 (aether-data/migrations) - 简化 CI/Docker 构建流程,移除 base image 二级构建,统一为单一 app image - 移除 Python 相关基础设施文件 (entrypoint.sh, gunicorn_conf.py, Dockerfile.base)
This commit is contained in:
40
_deprecated_py_src/utils/url_utils.py
Normal file
40
_deprecated_py_src/utils/url_utils.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
URL 处理工具函数
|
||||
|
||||
提供 URL 模式检测和处理功能。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
def is_official_openai_api_url(base_url: str | None) -> bool:
|
||||
"""判断是否为 OpenAI 官方 API 端点。"""
|
||||
value = str(base_url or "").strip()
|
||||
if not value:
|
||||
return False
|
||||
|
||||
parsed = urlparse(value if "://" in value else f"https://{value}")
|
||||
host = str(parsed.hostname or "").strip().lower()
|
||||
return host == "api.openai.com"
|
||||
|
||||
|
||||
def is_codex_url(base_url: str) -> bool:
|
||||
"""判断是否是 Codex OAuth 端点。
|
||||
|
||||
Codex OAuth 端点(如 chatgpt.com/backend-api/codex)不走标准 /v1 前缀,
|
||||
直接使用 /responses 而非 /v1/responses。
|
||||
|
||||
Args:
|
||||
base_url: 端点基础 URL
|
||||
|
||||
Returns:
|
||||
bool: 是否是 Codex 端点
|
||||
"""
|
||||
url = base_url.rstrip("/")
|
||||
return (
|
||||
"/backend-api/codex" in url
|
||||
or "/backendapi/codex" in url
|
||||
or url.endswith("/codex")
|
||||
)
|
||||
Reference in New Issue
Block a user