Skip to content

feat: add AvalAI channel type - #6618

Closed
m4tinbeigi-official wants to merge 1 commit into
QuantumNous:mainfrom
m4tinbeigi-official:feat/avalai-channel
Closed

feat: add AvalAI channel type#6618
m4tinbeigi-official wants to merge 1 commit into
QuantumNous:mainfrom
m4tinbeigi-official:feat/avalai-channel

Conversation

@m4tinbeigi-official

@m4tinbeigi-official m4tinbeigi-official commented Aug 2, 2026

Copy link
Copy Markdown

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.goChannelTypeAvalAI = 61, default base URL https://api.avalai.ir, display name "AvalAI"
  • constant/api_type.go / common/api_type.goAPITypeAvalAI mapping
  • relay/channel/avalai/constants.goModelList/ChannelName
  • relay/channel/openai/adaptor.go — switch cases for AvalAI
  • relay/relay_adaptor.go — routes APITypeAvalAI to the OpenAI adaptor
  • relay/common/relay_info.go — added to streamSupportedChannels
  • web/src/features/channels/constants.ts + lib/channel-utils.ts — frontend dropdown entry + icon

Known 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 -l on all touched packages reported clean. Please let CI confirm a full build.
  • Frontend build wasn't run locally.

Test plan

  • CI / go build ./... passes
  • Manual check: AvalAI appears in the channel type dropdown, test connection succeeds against https://api.avalai.ir

Summary by CodeRabbit

  • New Features
    • Added AvalAI as a supported channel.
    • Added AvalAI configuration with its service URL and supported models.
    • Enabled model retrieval and streaming options for AvalAI.
    • Added AvalAI to channel selection, display ordering, and icon support.
    • AvalAI uses the OpenAI-compatible integration for requests.

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>
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

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

Changes

AvalAI channel integration

Layer / File(s) Summary
Channel and API contracts
common/api_type.go, constant/api_type.go, constant/channel.go, relay/channel/avalai/constants.go
Defines AvalAI identifiers, endpoint metadata, display name, supported models, and API-type mapping.
Relay and adaptor integration
relay/relay_adaptor.go, relay/channel/openai/adaptor.go, relay/common/relay_info.go
Routes AvalAI through the OpenAI adaptor and adds model-list, channel-name, and stream-option handling.
Frontend channel registration
web/src/features/channels/constants.ts, web/src/features/channels/lib/channel-utils.ts
Adds AvalAI to channel display order, model fetching, and icon mappings.

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
Loading

Possibly related PRs

Suggested reviewers: calcium-ion

Poem

A rabbit hops where AvalAI flows,
Through OpenAI paths, the relay goes.
Models appear in a tidy line,
The frontend icons neatly shine.
Channel sixty-one joins the run—
“Sniff!” says the rabbit. “Integration done!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 clearly identifies the main change: adding AvalAI as a supported channel.
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.
✨ 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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between 0ab0202 and 86f5fee.

📒 Files selected for processing (9)
  • common/api_type.go
  • constant/api_type.go
  • constant/channel.go
  • relay/channel/avalai/constants.go
  • relay/channel/openai/adaptor.go
  • relay/common/relay_info.go
  • relay/relay_adaptor.go
  • web/src/features/channels/constants.ts
  • web/src/features/channels/lib/channel-utils.ts

Comment on lines +84 to 85
61: 'AvalAI',
} as const

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.

📐 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

@seefs001 seefs001 closed this Aug 3, 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