Skip to content

feat: add AGIone channel - #5333

Closed
KaiShaoCheng wants to merge 1 commit into
QuantumNous:mainfrom
KaiShaoCheng:provider-add-agione
Closed

feat: add AGIone channel#5333
KaiShaoCheng wants to merge 1 commit into
QuantumNous:mainfrom
KaiShaoCheng:provider-add-agione

Conversation

@KaiShaoCheng

@KaiShaoCheng KaiShaoCheng commented Jun 5, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

本 PR 新增 AGIone 渠道支持,使 New API 可以将请求转发到 AGIone 的 OpenAI-compatible API。

主要改动包括:

  • 新增 AGIone channel type 与 API type。
  • 新增 AGIone relay adaptor,复用现有 OpenAI-compatible 转发逻辑。
  • 默认接口地址设置为 https://agione.pro/hyperone/xapi/api/v1
  • 针对 New API 内部已带 /v1 的请求路径做了前缀处理,避免最终转发 URL 出现重复的 /v1/v1/...
  • 为 AGIone 单独处理模型列表同步路径:聊天接口使用 /v1 base URL,但模型列表接口使用 https://agione.pro/hyperone/xapi/api/models
  • 在 classic 与 default 两套前端 channel 配置中加入 AGIone,方便用户在渠道管理页面选择。

这样实现后,AGIone 可以作为一个标准 OpenAI-compatible 上游接入,同时兼容其模型列表接口与聊天补全接口路径不完全一致的情况。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

本地已运行 AGIone channel 单元测试:

go test ./relay/channel/agione

受影响后端包也做了编译级验证:

go test ./constant ./common ./relay/... ./controller -run 'TestNonExistent'

测试与变更范围截图如下:

AGIone channel unit test passed

AGIone channel unit test passed

Affected backend packages compile verification passed

Affected backend packages compile verification passed

Focused diff scope and single commit

Focused diff scope and single commit

补充说明:完整测试集中存在若干上游已有测试失败,主要集中在其他 channel/helper/controller 测试,和本次 AGIone 改动无关。

Summary by CodeRabbit

  • New Features

    • Added AGIone as a newly supported provider channel with complete platform integration.
    • Users can now select and configure AGIone as a channel option with pre-configured defaults.
    • Supports model fetching and streaming capabilities for AGIone connections.
    • Available in the channel selection interface across platform versions.
  • Tests

    • Added unit tests for AGIone channel integration.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7809d31-1a6a-4c18-8fba-e8998669d534

📥 Commits

Reviewing files that changed from the base of the PR and between 7517f01 and 8a951ce.

📒 Files selected for processing (12)
  • common/api_type.go
  • constant/api_type.go
  • constant/channel.go
  • controller/channel_upstream_update.go
  • relay/channel/agione/adaptor.go
  • relay/channel/agione/adaptor_test.go
  • relay/channel/agione/constant.go
  • relay/common/relay_info.go
  • relay/relay_adaptor.go
  • web/classic/src/constants/channel.constants.js
  • web/default/src/features/channels/constants.ts
  • web/default/src/features/channels/lib/channel-type-config.ts
✅ Files skipped from review due to trivial changes (2)
  • relay/common/relay_info.go
  • relay/channel/agione/constant.go
🚧 Files skipped from review as they are similar to previous changes (8)
  • constant/api_type.go
  • web/classic/src/constants/channel.constants.js
  • common/api_type.go
  • web/default/src/features/channels/constants.ts
  • controller/channel_upstream_update.go
  • web/default/src/features/channels/lib/channel-type-config.ts
  • relay/channel/agione/adaptor.go
  • relay/relay_adaptor.go

Walkthrough

Registers a new AGIone channel (id 58), adds APITypeAGIone, maps channel→API type, implements an agione relay adaptor (URL handling, models), wires it into the relay factory and stream support, updates upstream model URL logic, and adds frontend configuration and UI constants.

Changes

AGIone Channel Support

Layer / File(s) Summary
Channel and API type constants
constant/api_type.go, constant/channel.go
APITypeAGIone is added to the API type enumeration; ChannelTypeAGIone (value 58) is defined with base URL and display name in channel constants.
Channel-to-API type mapping
common/api_type.go
ChannelType2APIType function now recognizes ChannelTypeAGIone and maps it to APITypeAGIone.
AGIone adaptor with request handling and model list
relay/channel/agione/constant.go, relay/channel/agione/adaptor.go, relay/channel/agione/adaptor_test.go
AGIone adaptor embeds OpenAI adaptor and implements GetRequestURL (with base URL fallback and /v1 prefix trimming, special path for certain relay formats), GetModelList, and GetChannelName; unit test verifies URL trimming behavior.
Relay system wiring for AGIone
relay/relay_adaptor.go, relay/common/relay_info.go
GetAdaptor factory imports agione package and returns agione.Adaptor for APITypeAGIone; streamSupportedChannels is extended to enable streaming for AGIone.
Upstream model fetching for AGIone
controller/channel_upstream_update.go
fetchChannelUpstreamModelIDs adds ChannelTypeAGIone case to construct upstream model endpoint as baseURL/models with trailing /v1 removed.
Web UI constants and channel configuration
web/classic/src/constants/channel.constants.js, web/default/src/features/channels/constants.ts, web/default/src/features/channels/lib/channel-type-config.ts
Frontend UI updated with AGIone channel option (value 58, green color), display order, model-fetch eligibility, default base URL, and authentication/model hints.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • seefs001
  • creamlike1024

Poem

🐰 I found a new hop called AGIone,
constants set and routes now sewn.
Adaptors trimmed a /v1,
models fetched and UI spun,
a rabbit hops — the feature's grown!

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add AGIone channel' clearly and concisely summarizes the main change: adding support for a new AGIone channel type across backend and frontend components.
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.

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

✨ 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 and usage tips.

@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

🧹 Nitpick comments (1)
web/default/src/features/channels/lib/channel-type-config.ts (1)

132-136: ⚡ Quick win

Localize newly added AGIone hint text.

The new hints values are hardcoded strings; please switch these to i18n keys (or translated retrieval) like the rest of the localized channel UX path.

As per coding guidelines, “web/default/**/*.{tsx,ts}: All user-facing text content must support i18n using the t() function from useTranslation() in React components”.

🤖 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 `@web/default/src/features/channels/lib/channel-type-config.ts` around lines
132 - 136, The new AGIone channel config contains hardcoded user-facing hint
text (e.g., around the entry with key 'AGIone Auth Token' in
channel-type-config.ts) and must be converted to i18n keys; replace the literal
hint strings with i18n key identifiers (e.g., "channels.agione.hint.*") in the
config and ensure the React component that renders these hints calls t() from
useTranslation() to resolve them at runtime (update the component that reads the
channel config to call t(config.hintKey) or map keys to translated text). Keep
the config as data-only (keys, not t() calls) and perform translation only in
the UI layer where the hint is displayed.
🤖 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 `@web/default/src/features/channels/constants.ts`:
- Around line 79-84: MODEL_FETCHABLE_TYPES is missing the new AGIone channel
type (value 58) so it won't participate in the same upstream model-fetch flow;
update the MODEL_FETCHABLE_TYPES array/const to include the AGIone entry (the
same numeric id 58 used in CHANNEL_TYPE_DISPLAY_ORDER and the const that defines
'AGIone') so AGIone follows the default UI model-fetch behavior, ensuring you
add the same identifier used where CHANNEL_TYPE_DISPLAY_ORDER lists 58.

---

Nitpick comments:
In `@web/default/src/features/channels/lib/channel-type-config.ts`:
- Around line 132-136: The new AGIone channel config contains hardcoded
user-facing hint text (e.g., around the entry with key 'AGIone Auth Token' in
channel-type-config.ts) and must be converted to i18n keys; replace the literal
hint strings with i18n key identifiers (e.g., "channels.agione.hint.*") in the
config and ensure the React component that renders these hints calls t() from
useTranslation() to resolve them at runtime (update the component that reads the
channel config to call t(config.hintKey) or map keys to translated text). Keep
the config as data-only (keys, not t() calls) and perform translation only in
the UI layer where the hint is displayed.
🪄 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

Run ID: e9bb854b-0fa3-4b5e-a8d3-bcfe0b34177f

📥 Commits

Reviewing files that changed from the base of the PR and between 3280584 and 7517f01.

📒 Files selected for processing (12)
  • common/api_type.go
  • constant/api_type.go
  • constant/channel.go
  • controller/channel_upstream_update.go
  • relay/channel/agione/adaptor.go
  • relay/channel/agione/adaptor_test.go
  • relay/channel/agione/constant.go
  • relay/common/relay_info.go
  • relay/relay_adaptor.go
  • web/classic/src/constants/channel.constants.js
  • web/default/src/features/channels/constants.ts
  • web/default/src/features/channels/lib/channel-type-config.ts

Comment thread web/default/src/features/channels/constants.ts
@KaiShaoCheng
KaiShaoCheng force-pushed the provider-add-agione branch from 7517f01 to 8a951ce Compare June 5, 2026 10:38
@KaiShaoCheng

Copy link
Copy Markdown
Author

Addressed the CodeRabbit actionable comment by adding AGIone channel type 58 to MODEL_FETCHABLE_TYPES in the default frontend, so it follows the same upstream model-fetch flow there as in the classic UI.

Re-ran:

go test ./relay/channel/agione
go test ./constant ./common ./relay/... ./controller -run 'TestNonExistent'

The proof images in the PR body have also been refreshed for the updated single commit.

@seefs001

seefs001 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

不接受此类非知名供应商

@seefs001 seefs001 closed this Jun 5, 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.

2 participants