Skip to content

fix: optimize Codex relay - #2826

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
dahetaoa:fix-codex-and-sqlite
Feb 5, 2026
Merged

fix: optimize Codex relay#2826
seefs001 merged 1 commit into
QuantumNous:mainfrom
dahetaoa:fix-codex-and-sqlite

Conversation

@dahetaoa

@dahetaoa dahetaoa commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

1. 修复订阅计划表的数据库兼容性 (SQLite/PostgreSQL)

  • 修改说明:在 SubscriptionPlan 模型中移除显式的 decimal(10,6) 标签,并在 model/main.go 的 SQLite 迁移脚本中同步改用 REAL 类型。
  • 解决问题:解决了在 SQLite 环境下因不支持显式 decimal 类型导致的初始化问题。

2. 优化 Codex 渠道的中继逻辑

  • 字段补全:为 instructions 字段增加默认值(空字符串),防止部分通过通用 OpenAI 协议调用的请求因缺少该字段而报错。
  • 请求头优化:强制设置严格的 Content-Type: application/json 并优化 Accept 头,避免非 Codex 客户端因未携带正确参数而被 Codex 后端拒绝。

是否有破坏性更新:否

Summary by CodeRabbit

  • Bug Fixes
    • Improved Codex request handling by ensuring proper instruction field formatting and standardizing HTTP headers for streaming and non-streaming responses.

@coderabbitai

coderabbitai Bot commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The Codex adaptor is updated to ensure proper request formatting by defaulting empty instructions to an empty string and standardizing HTTP headers. Content-Type is explicitly set to application/json, and Accept header is conditionally set based on streaming mode.

Changes

Cohort / File(s) Summary
Codex Adaptor Request Handling
relay/channel/codex/adaptor.go
Updated ConvertOpenAIResponsesRequest to default empty content to empty string JSON literal for instructions field. Updated SetupRequestHeader to explicitly set Content-Type to application/json and standardize Accept header based on streaming mode.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 The adaptor hops with headers neat,
Instructions never left incomplete,
Content flows as JSON streams,
A rabbit's standardized API dreams! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title 'fix: optimize Codex relay' is partially related to the changeset but does not highlight the main change. The raw_summary shows additions to ConvertOpenAIResponsesRequest and SetupRequestHeader, but the objectives reveal two distinct changes: SQLite compatibility fixes and Codex relay optimizations. The title only addresses the secondary Codex optimization aspect, not the primary SQLite subscription plan compatibility issue. Update the title to reflect both main changes, such as 'fix: resolve SQLite compatibility and optimize Codex relay' or prioritize it based on which change is more critical.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seefs001

seefs001 commented Feb 4, 2026

Copy link
Copy Markdown
Collaborator

1就不必了吧,codex的可以改,可以清理一下我来merge

@Calcium-Ion

Calcium-Ion commented Feb 4, 2026

Copy link
Copy Markdown
Member

你的修改可能会导致已经安装的用户出现迁移失败,无法启动的问题

@dahetaoa
dahetaoa force-pushed the fix-codex-and-sqlite branch from 3dc1db9 to 05ed9d4 Compare February 4, 2026 21:43
@dahetaoa

dahetaoa commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

1就不必了吧,codex的可以改,可以清理一下我来merge

已清理关于1的修改,现在仅保留对codex渠道的修复,麻烦查看下

@seefs001 seefs001 changed the title fix: resolve SQLite compatibility for subscription plans and optimize Codex relay fix: optimize Codex relay Feb 5, 2026
@seefs001
seefs001 merged commit 9d73aa4 into QuantumNous:main Feb 5, 2026
1 check passed
@dahetaoa
dahetaoa deleted the fix-codex-and-sqlite branch February 5, 2026 16:20
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
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.

3 participants