refactor!: 技术标识也全部换掉(logger / UA / 脚本 / 前端 / 文档)

老板要求:技术标识也要换,脚本啥的都换。

运行时
  · 所有 logging.getLogger("api-gateway…") → "xiaoyin-gateway…"(main/metrics/circuit/settings/sessions/users/gomodels/video_owners/adapters)
  · app/main.py 的上游 User-Agent 默认值 → xiaoyin-gateway/{VERSION}
  · data/gateway.yaml 里 opencode 的 UA 覆盖 → xiaoyin-gateway/2.4.0
  · run.py 启动横幅 → [xiaoyin-gateway]

脚本
  · scripts/sync_models.py、sync_onemin.py 的探测 UA
  · scripts/ci_check.sh 的横幅

前端
  · 配置备份文件的 kind: api-gateway-backup → xiaoyin-gateway-backup
    (导入逻辑本来就不校验 kind,旧备份照样能恢复)
  · dist 产物同步打补丁,不用重新 build

文档
  · README / CHANGELOG 里的服务名、`supervisorctl restart api-gateway:api-gateway_00` 等
  · 另一个技能 dsh-plugin-publish 的敏感词规则里也提到了旧名,一并更新

唯一没动的
  · .gitignore 里那行指向 /root/.trash/2026-09-13-api-gateway-cleanup 的注释 ——
    那是磁盘上真实存在的历史目录名,改了反而指错地方
This commit is contained in:
Jidekin committed 2026-11-20 16:30:42 +08:00
1 parent cc2d7bec5a
commit 69f0039256
19 files changed
+48 -48

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@ from app.config import (
)
from app.models import CHAT_CORE_KEYS, PROTECTED_VIDEO_KEYS, strip_protected
log = logging.getLogger("api-gateway")
log = logging.getLogger("xiaoyin-gateway")
# ── 上游"某参数只允许取某个值"的报错形态(第二十五轮)──
# 各家措辞不同,这里收录已实测到的两类:
+1 -1
View File
@@ -36,7 +36,7 @@ from typing import Any, AsyncIterator
import httpx
log = logging.getLogger("api-gateway.agents")
log = logging.getLogger("xiaoyin-gateway.agents")
#: 单轮对话的超时(秒)。引擎可能跑很久(多步工具),给足。
DEFAULT_TIMEOUT = 300.0
+1 -1
View File
@@ -37,7 +37,7 @@ from app.adapters.qwenpaw_engine import (
stream_chat,
)
log = logging.getLogger("api-gateway.agents")
log = logging.getLogger("xiaoyin-gateway.agents")
QWENPAW_CONFIG = Path("~/.qwenpaw/config.json")
+1 -1
View File
@@ -13,7 +13,7 @@ import threading
import time
from collections import deque
log = logging.getLogger("api-gateway.circuit")
log = logging.getLogger("xiaoyin-gateway.circuit")
class CircuitBreaker:
+2 -2
View File
@@ -33,7 +33,7 @@ import time
import urllib.request
_URL = "https://opencode.ai/inference/go/v1/models"
log = logging.getLogger("api-gateway.gomodels")
log = logging.getLogger("xiaoyin-gateway.gomodels")
_TTL = 6 * 3600
_RETRY_AFTER_FAIL = 300
_TIMEOUT = 6
@@ -46,7 +46,7 @@ _at = 0.0
def _fetch() -> dict[str, dict]:
req = urllib.request.Request(
_URL,
headers={"Accept": "application/json", "User-Agent": "api-gateway/gomodels"},
headers={"Accept": "application/json", "User-Agent": "xiaoyin-gateway/gomodels"},
)
with urllib.request.urlopen(req, timeout=_TIMEOUT) as resp: # noqa: S310
payload = json.loads(resp.read().decode("utf-8", "replace"))
+2 -2
View File
@@ -162,7 +162,7 @@ def _setup_logging() -> None:
# 基础日志先起来,进 lifespan 后按 observability 重配
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(name)s] %(levelname)s: %(message)s")
log = logging.getLogger("api-gateway")
log = logging.getLogger("xiaoyin-gateway")
# 调用日志的内容上限(2026-10-23,2.9.12 再放宽):默认 **4 MiB**(≈100 万 token 的文本)。
# 老板要求「详情内容都不要截断」—— 4 MiB 对任何正常对话都等于不截断;
@@ -4704,7 +4704,7 @@ async def opencode_go_usage(_auth=Depends(require_auth)):
raise HTTPException(503, "OpenCode Go 未配置 API Key")
base = str(pconfig.base_url or "https://opencode.ai/zen/go/v1").rstrip("/")
ua = (pconfig.extra_headers or {}).get("User-Agent") or f"api-gateway/{VERSION}"
ua = (pconfig.extra_headers or {}).get("User-Agent") or f"xiaoyin-gateway/{VERSION}"
try:
async with httpx.AsyncClient(timeout=10) as client:
r = await client.get(
+1 -1
View File
@@ -13,7 +13,7 @@ from collections import deque
from contextvars import ContextVar
from typing import Any
log = logging.getLogger("api-gateway.metrics")
log = logging.getLogger("xiaoyin-gateway.metrics")
# 请求级「归属账号」上下文(ContextVar,每 task/请求独立;由 main.py require_auth 写入)。
# 访问日志与指标通过它给每条记录打上账号,实现:
+1 -1
View File
@@ -31,7 +31,7 @@ import threading
import time
from pathlib import Path
log = logging.getLogger("api-gateway.sessions")
log = logging.getLogger("xiaoyin-gateway.sessions")
# 落盘文件名固定为 sessions.json;结构带 version,便于以后改格式时兼容读取。
_FILE_VERSION = 1
+1 -1
View File
@@ -41,7 +41,7 @@ from app.config import (
validate_warnings,
)
log = logging.getLogger("api-gateway.settings")
log = logging.getLogger("xiaoyin-gateway.settings")
# ── 改了必须重启进程才生效的键(其余都是"每请求读配置",保存即生效) ──
# host / port:uvicorn 在进程启动时绑定,改文件不会重绑。
+1 -1
View File
@@ -28,7 +28,7 @@ import secrets
import threading
import time
log = logging.getLogger("api-gateway.users")
log = logging.getLogger("xiaoyin-gateway.users")
USERNAME_RE = re.compile(r"^[A-Za-z0-9]+$")
ITERATIONS = 200_000
+1 -1
View File
@@ -30,7 +30,7 @@ import threading
import time
from pathlib import Path
log = logging.getLogger("api-gateway.video_owners")
log = logging.getLogger("xiaoyin-gateway.video_owners")
_FILE_VERSION = 1