feat: add AvalAI channel type - #6618
Conversation
Adds AvalAI (api.avalai.ir) as a first-class channel, following the existing OpenAI-compatible-provider pattern used by LingYiWanWu and Xinference: a new ChannelType/APIType constant pair, an OpenAI-adaptor delegation in relay/relay_adaptor.go and relay/channel/openai/adaptor.go, a default base URL, stream-support registration, and the corresponding frontend channel dropdown/model-fetch entries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
WalkthroughAvalAI is added as channel type 61. Backend mappings route it through the OpenAI adaptor, with model metadata and stream support. The frontend adds its label, ordering, model-fetch capability, and OpenAI icon. ChangesAvalAI channel integration
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant AvalAIChannel
participant GetAdaptor
participant OpenAIAdaptor
participant Frontend
AvalAIChannel->>GetAdaptor: Provide APITypeAvalAI
GetAdaptor->>OpenAIAdaptor: Return openai.Adaptor
OpenAIAdaptor->>AvalAIChannel: Use ModelList and channel name
Frontend->>AvalAIChannel: Display channel 61 and fetch models
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.
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 `@web/src/features/channels/constants.ts`:
- Around line 84-85: Update the AvalAI label in CHANNEL_TYPE_OPTIONS to use a
translation key instead of raw user-facing text, then update the component
rendering CHANNEL_TYPES options to pass that key through the existing t() i18n
function. Preserve the current option value and behavior for all other channel
types.
🪄 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: 25bd08c0-e8c3-454d-a74b-a7b5d1562e78
📒 Files selected for processing (9)
common/api_type.goconstant/api_type.goconstant/channel.gorelay/channel/avalai/constants.gorelay/channel/openai/adaptor.gorelay/common/relay_info.gorelay/relay_adaptor.goweb/src/features/channels/constants.tsweb/src/features/channels/lib/channel-utils.ts
| 61: 'AvalAI', | ||
| } as const |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Translate the AvalAI channel label through i18n.
CHANNEL_TYPE_OPTIONS passes CHANNEL_TYPES labels directly to the UI. The new "AvalAI" value is therefore user-facing raw text. Store a translation key and translate it in the rendering component with t().
As per coding guidelines, frontend user-facing text must use i18n and React components must render it through t().
🤖 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/src/features/channels/constants.ts` around lines 84 - 85, Update the
AvalAI label in CHANNEL_TYPE_OPTIONS to use a translation key instead of raw
user-facing text, then update the component rendering CHANNEL_TYPES options to
pass that key through the existing t() i18n function. Preserve the current
option value and behavior for all other channel types.
Source: Coding guidelines
Summary
Adds AvalAI as a supported channel — an OpenAI-compatible AI gateway (
https://api.avalai.ir) fronting OpenAI, Anthropic, Google, DeepSeek and other vendor models behind one API key.Since AvalAI is fully OpenAI-compatible, this reuses the shared OpenAI relay adaptor (same approach as LingYiWanWu/Xinference/OpenRouter) rather than a bespoke adaptor:
constant/channel.go—ChannelTypeAvalAI = 61, default base URLhttps://api.avalai.ir, display name "AvalAI"constant/api_type.go/common/api_type.go—APITypeAvalAImappingrelay/channel/avalai/constants.go—ModelList/ChannelNamerelay/channel/openai/adaptor.go— switch cases for AvalAIrelay/relay_adaptor.go— routesAPITypeAvalAIto the OpenAI adaptorrelay/common/relay_info.go— added tostreamSupportedChannelsweb/src/features/channels/constants.ts+lib/channel-utils.ts— frontend dropdown entry + iconKnown gaps — please advise
go build ./...couldn't complete in the prep sandbox — all failures were network/module-proxy egress errors on unrelated pre-existing dependencies (clickhouse-go, expr-lang, modernc sqlite, etc.), not on any touched file.gofmt -lon all touched packages reported clean. Please let CI confirm a full build.Test plan
go build ./...passeshttps://api.avalai.irSummary by CodeRabbit