feat: codex alpha search - #6156
Conversation
WalkthroughAdds a Codex Search API endpoint with request validation, Codex-specific channel routing, upstream forwarding, model-aware pricing, quota settlement, consumption logging, and boundary tests. ChangesCodex Search relay
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
relay/helper/max_tokens_bounds_test.go (1)
90-91: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
assertfor non-fatal value checks per coding guidelines.Lines 90–91 use
require.Equal/require.EqualValuesfor non-fatal value checks. The coding guideline mandatesassertfor non-fatal value checks so all failures are reported.require.NoError(line 89) is correctly fatal.♻️ Suggested change
require.NoError(t, err) -require.Equal(t, "gpt-5.4", req.Model) -require.EqualValues(t, 4096, *req.MaxOutputTokens) +assert.Equal(t, "gpt-5.4", req.Model) +assert.EqualValues(t, 4096, *req.MaxOutputTokens)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@relay/helper/max_tokens_bounds_test.go` around lines 90 - 91, Replace the non-fatal require.Equal and require.EqualValues checks in the test with their assert equivalents, while keeping require.NoError unchanged for the fatal setup check.Source: Coding guidelines
relay/helper/price_test.go (1)
97-101: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
assertfor non-fatal value checks per coding guidelines.Lines 97–101 use
require.Equal/require.Truefor non-fatal value checks. The coding guideline mandatesassertfor non-fatal value checks so all failures are reported instead of stopping at the first.require.NoError(line 96) is correctly fatal.♻️ Suggested change
require.NoError(t, err) -require.Equal(t, 0.03, priceData.ModelPrice) -require.Equal(t, 22500, priceData.QuotaToPreConsume) -require.Equal(t, 22500, priceData.Quota) -require.True(t, priceData.UsePrice) -require.Equal(t, priceData, info.PriceData) +assert.Equal(t, 0.03, priceData.ModelPrice) +assert.Equal(t, 22500, priceData.QuotaToPreConsume) +assert.Equal(t, 22500, priceData.Quota) +assert.True(t, priceData.UsePrice) +assert.Equal(t, priceData, info.PriceData)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@relay/helper/price_test.go` around lines 97 - 101, In the priceData assertions within the test, replace the non-fatal require.Equal and require.True checks with their assert equivalents, while preserving the existing comparisons and keeping the require.NoError check fatal.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@relay/helper/max_tokens_bounds_test.go`:
- Around line 90-91: Replace the non-fatal require.Equal and require.EqualValues
checks in the test with their assert equivalents, while keeping require.NoError
unchanged for the fatal setup check.
In `@relay/helper/price_test.go`:
- Around line 97-101: In the priceData assertions within the test, replace the
non-fatal require.Equal and require.True checks with their assert equivalents,
while preserving the existing comparisons and keeping the require.NoError check
fatal.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d58f9cdd-dbc2-4dd0-abb3-001fb2ba1f7d
📒 Files selected for processing (18)
constant/codex.gocontroller/relay.godto/codex_search.gomiddleware/distributor.gomodel/ability.gomodel/channel.gomodel/channel_cache.gorelay/channel/codex/adaptor.gorelay/codex_search_handler.gorelay/common/relay_info.gorelay/constant/relay_mode.gorelay/helper/max_tokens_bounds_test.gorelay/helper/price.gorelay/helper/price_test.gorelay/helper/valid_request.gorouter/relay-router.goservice/codex_search_billing.gotypes/relay_format.go
|
@Calcium-Ion 辛苦关注一下这个PR |
目前没有支持的计划 |
|
好的,方便透露原因吗?联网搜索功能还挺有用的 |
这个pr我本地测试过了,只支持codex格式。而绝大多数人用的都是openai格式的,要想真正支持还得再修改 |
该端点仅codex订阅支持,无法确认上游是否支持(目前除codex外均没有上游支持),如果添加该功能后直接请求,请求到不支持的上游渠道上会报错 |
大佬求一个啊 🙏 最近 Codex 用户也挺多的,联网搜索被卡住之后 Codex 默认转 curl 抓取,慢得难受。求个修复! @Calcium-Ion 辛苦大佬 |
这个项目不是逆向项目,不可能为了一个订阅逆向单独加接口,如果openai把这个作为标准开放newapi会立刻加上,目前这个情况,如果真的需要请二开 |
|
@Calcium-Ion 至少做个选项也行吧,给这个选项单独加路由,又不影响别的功能 现在是一刀切完全不兼容,也并不合理,对于需要这个功能的用户来说,这是p1~p0级事故 |
目前考虑的做法是和相关项目合作,针对某个渠道类型做兼容,可能会在几个版本后上线 |
|
@Calcium-Ion 感谢。请问大概要多久呢,月内可以实现吗? |
|
@Calcium-Ion 你好,大大,同样需要这个功能,增加一个功能选项是否可行? |
|
该功能已在 v1.0.0-rc.22 中支持,请升级后使用。因此关闭此 Issue。 |
Important
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
为Codex渠道增加/v1/alpha/search支持
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
Summary by CodeRabbit
New Features
POST /v1/alpha/search.Bug Fixes
Tests