Skip to content

feat(openai-compat): thinking/reasoning_content 双向透传与 reasoning_effort(附启动脚本/Docker 杂项) - #4

Closed
jk-uzi wants to merge 5 commits into
dengyie:mainfrom
jk-uzi:feat/openai-reasoning
Closed

jk-uzi wants to merge 5 commits into
dengyie:mainfrom
jk-uzi:feat/openai-reasoning

Conversation

@jk-uzi

@jk-uzi jk-uzi commented Oct 4, 2026

Copy link
Copy Markdown

概述

OpenAI 兼容层补齐思考文本(thinking / reasoning_content)双向透传与 reasoning_effort 参数,使 Chatbox / pi-ai / DeepSeek 风格客户端能正确看到并回传思考过程。

改动要点

  • 请求侧(openai_to_anthropic):多轮重放时历史轮 reasoning_content → Anthropic thinking 块(上游不校验 signature,空串可过);reasoning_effort 为 low/high/max 时透传上游,其余值(off/none)不带——上游不支持关闭思考
  • 响应侧(anthropic_to_openai + 流式 StreamConverter):thinking 块/thinking_delta 聚合为 message.reasoning_content 与流式增量 chunk(DeepSeek/pi-ai 通用约定)

测试

  • 新增 tests/unit/test_openai_compat.py(13 例,双向 + 流式)
  • 全量 pytest 通过;ruff / mypy 干净(与 CI 一致)

附带杂项(独立提交,可按需 cherry-pick 或单独处理)

本分支同时携带 3 个与网关功能无关的仓库杂项提交,为省 PR 往返一并提交:

  1. docs: README 补充 Docker 部署说明(与下面 Docker 文件配套)
  2. chore: 前端版本号对齐 + captcha_node lockfile 同步(puppeteer-core)
  3. chore: Linux/Windows 启动脚本(stop/restart 语义对齐、健康检查、依赖自装)+ Dockerfile/compose/.dockerignore(多阶段镜像:python3.11-slim + node22 + Debian chromium + tini + CJK 字体;.env/data 不入镜像)+ .gitattributes 的 *.bat CRLF 规则 + 本地杂物 gitignore

jk-uzi added 4 commits October 4, 2026 10:32
- 请求侧:历史轮 reasoning_content → Anthropic thinking 块(signature 空串可过);
  reasoning_effort low/high/max 透传上游,其余值不带(上游不支持关思考)
- 响应侧:thinking 块聚合为 message.reasoning_content(DeepSeek/pi-ai 风格)
- 流式:thinking_delta → reasoning_content 增量 chunk
- start.sh / start.bat:启动/停止/重启语义对齐——停旧实例(serve.pid, 优雅→强杀)、
  端口占用检测、依赖自动安装、后台运行+日志、/meta 健康检查
- .gitattributes:*.bat/*.cmd 强制 CRLF(cmd 对 LF 的 goto/label 有解析怪癖)
- Dockerfile + compose + .dockerignore:多阶段镜像(python3.11-slim + node22 +
  Debian chromium + tini + CJK 字体),数据卷 ./data,.env 不入镜像
- .gitignore:排除 serve.log/pid、.trae_*、.sg_* 等本地运行产物
@jk-uzi
jk-uzi force-pushed the feat/openai-reasoning branch from b62f034 to b87963f Compare October 4, 2026 02:58
@jk-uzi jk-uzi closed this Oct 4, 2026
@jk-uzi
jk-uzi deleted the feat/openai-reasoning branch October 4, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant