Skip to content

fix: detect GPT image models for automatic endpoint tests - #6423

Open
fengnian2025 wants to merge 3 commits into
QuantumNous:mainfrom
fengnian2025:codex/fix-gpt-image-2-endpoint
Open

fix: detect GPT image models for automatic endpoint tests#6423
fengnian2025 wants to merge 3 commits into
QuantumNous:mainfrom
fengnian2025:codex/fix-gpt-image-2-endpoint

Conversation

@fengnian2025

@fengnian2025 fengnian2025 commented Jul 23, 2026

Copy link
Copy Markdown

📝 变更描述 / Description

修正log日志优先级以及增加重要信息

gpt-image-2 属于 OpenAI 的 Image Generation 模型,但此前模型识别规则只覆盖 gpt-image-1。因此,gpt-image-2 会被当作普通 OpenAI Chat 模型处理,通道测试的“自动检测”也会错误地请求 /v1/chat/completions

本次修改将 GPT Image 模型识别扩展为 gpt-image-* 系列,并让通道测试的自动端点检测复用统一的图片模型判断逻辑。这样 gpt-image-2 会自动使用:

  • image-generation 端点类型
  • /v1/images/generations
  • OpenAI Image relay format
  • ImageRequest

用户显式指定端点时仍保持原有优先级。同时增加了模型识别、端点优先级、自动检测和显式端点覆盖的回归测试。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • 暂无关联 Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 如仓库要求 Bug fix 必须关联 Issue,请补充对应 Issue 编号。
  • 变更理解: 已确认模型分类和自动端点选择的完整逻辑。
  • 范围聚焦: 本 PR 仅包含 GPT Image 模型端点识别及相关回归测试。
  • 本地验证: 已完成全量 Go 测试和本地手动验证。
  • 安全合规: 未引入敏感凭据,符合项目代码规范。

📸 运行证明 / Proof of Work

全量测试通过:

go test ./... -count=1

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved recognition of GPT image-generation model variants, including newer model names and provider-prefixed or uppercase forms.
  * Image-generation requests are now routed to the appropriate image endpoint automatically.
  * Explicitly configured endpoints continue to be honored without being overridden.

* **Tests**
  * Added coverage for GPT image model detection, endpoint prioritization, automatic routing, and explicit endpoint preservation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

GPT image model matching now covers the broader gpt-image- family. Channel-test endpoint normalization recognizes these models as image-generation endpoints, with tests covering detection, endpoint ordering, normalization, and explicit endpoint preservation. Error logs also include richer context and error severity.

Changes

GPT image endpoint handling

Layer / File(s) Summary
GPT image model recognition
common/model.go, common/model_test.go
The response-only model match uses the gpt-image- prefix, with tests covering GPT image variants and image-generation endpoint prioritization.
Channel-test endpoint normalization
controller/channel-test.go, controller/channel_test_internal_test.go
Recognized GPT image models normalize to EndpointTypeImageGeneration, while explicitly supplied endpoint types remain unchanged.

Error logging updates

Layer / File(s) Summary
Error context and severity
controller/relay.go, model/log.go
Channel error logs include channel name, original model, and status code; recorded errors are logged at error level.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: calcium-ion

Poem

A rabbit hops through models bright,
GPT images find their route just right.
Errors now carry context too,
With proper levels shining through.
Tests guide each endpoint’s land—
thump, thump across the code so grand!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: broader GPT image model detection for automatic endpoint tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@model/log.go`:
- Line 284: Update the error message in the logging flow around logger.LogError
to stop including c.GetString("username"); retain userId as the user identifier
or use an approved redacted/hash-derived value, while preserving the other
diagnostic fields and the persisted Log record behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e8b4222-2bf1-41e1-8e36-e11ccc8592cf

📥 Commits

Reviewing files that changed from the base of the PR and between 595f316 and 1ddbc15.

📒 Files selected for processing (2)
  • controller/relay.go
  • model/log.go

Comment thread model/log.go
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.

2 participants