Conversation
Greptile SummaryThis PR updates documentation for adding a new AI provider channel, correcting stale file references and expanding the workflow steps to match the current codebase structure.
Confidence Score: 5/5Documentation-only update; no runtime code changed. All referenced file names, exported symbols, and line ranges were verified against the live codebase — buildChannelWithTransformer, defaultEndpointsForChannelType, CHANNEL_CONFIGS, PROVIDER_CONFIGS, channelTypeSchema, getAPIKeyProvider, and the field.Enum type block all exist exactly where the docs say they do. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Add new AI provider channel] --> B[1. Backend: Ent Schema]
B --> B1["Add type to field.Enum in channel.go:37-92"]
B1 --> B2["Run make generate"]
B2 --> B3["Add entry to defaultEndpointsForChannelType\nchannel_endpoint.go:90-156"]
B3 --> B4{"New API format?"}
B4 -- Yes --> B5["Add to SupportedAPIFormats"]
B4 -- No --> B6["Add case to buildChannelWithTransformer\nchannel_llm.go:348-951"]
B5 --> B6
B6 --> B7{"New credential variant?"}
B7 -- Yes --> B8["Add validation above switch\nchannel_llm.go:320-343"]
B7 -- No --> C
B8 --> C[2. Frontend: Schema, Config & i18n]
C --> C1["Append to channelTypeSchema\nschema.ts:48-102"]
C1 --> C2["Add CHANNEL_CONFIGS entry\nconfig_channels.ts"]
C2 --> C3["Add/extend PROVIDER_CONFIGS\nconfig_providers.ts"]
C3 --> C4["Add translation keys\nen.json & zh.json"]
C4 --> D[3. Finalize]
D --> D1["Run make generate again"]
D1 --> D2["Verify build: make build-backend"]
Reviews (2): Last reviewed commit: "doc: update add channel doc" | Re-trigger Greptile |
97ad958 to
c2fb80d
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the workflow and development documentation for adding new AI provider channels, detailing specific backend and frontend integration steps. Feedback indicates that the guides should also explicitly mention updating the CHANNEL_TYPE_TO_PROVIDER mapping and registering new API formats in the frontend schema to ensure proper provider grouping and recognition.
|
|
||
| 1. **Zod schema** — add the new type value to `channelTypeSchema` enum in `frontend/src/features/channels/data/schema.ts:48-102`. | ||
| - If a new API format, add to `apiFormatSchema` and `configurableChannelEndpointApiFormats` in the same file. | ||
| 2. **Channel config** — add a `CHANNEL_CONFIGS` entry in `frontend/src/features/channels/data/config_channels.ts` (icon, baseURL, defaultModels, apiFormat, color). |
There was a problem hiding this comment.
When adding a new channel type, it is also necessary to update the CHANNEL_TYPE_TO_PROVIDER mapping in frontend/src/features/channels/data/config_channels.ts to ensure the channel is correctly associated with its provider group.
| 2. **Channel config** — add a `CHANNEL_CONFIGS` entry in `frontend/src/features/channels/data/config_channels.ts` (icon, baseURL, defaultModels, apiFormat, color). | |
| 2. **Channel config** — add a `CHANNEL_CONFIGS` entry and update `CHANNEL_TYPE_TO_PROVIDER` in `frontend/src/features/channels/data/config_channels.ts` (icon, baseURL, defaultModels, apiFormat, color). |
| - If adding a new transformer under `llm/transformer/`, import it and build config with `getAPIKeyProvider(ch)` | ||
|
|
||
| 4. **Sync the frontend schema and config** | ||
| - Append the enum value to `channelTypeSchema` in [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) |
There was a problem hiding this comment.
If the new channel introduces a new API format, it must also be added to apiFormatSchema and configurableChannelEndpointApiFormats in frontend/src/features/channels/data/schema.ts to be recognized by the frontend.
| - Append the enum value to `channelTypeSchema` in [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) | |
| - Append the enum value to `channelTypeSchema` in [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) | |
| - If a new API format is introduced, also add it to `apiFormatSchema` and `configurableChannelEndpointApiFormats` in the same file |
|
|
||
| 4. **Sync the frontend schema and config** | ||
| - Append the enum value to `channelTypeSchema` in [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) | ||
| - Add a `CHANNEL_CONFIGS` entry in [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) |
There was a problem hiding this comment.
Updating CHANNEL_TYPE_TO_PROVIDER in config_channels.ts is a required step when adding a new channel type to ensure proper provider grouping and type safety in the frontend.
| - Add a `CHANNEL_CONFIGS` entry in [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) | |
| - Add a `CHANNEL_CONFIGS` entry and update `CHANNEL_TYPE_TO_PROVIDER` in [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) |
| - 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) 的 Zod schema | ||
| - 在 [frontend/src/features/channels/data/constants.ts](../../../frontend/src/features/channels/data/constants.ts) 中添加渠道配置 | ||
| 4. **同步前端的 schema 与配置** | ||
| - 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) 的 `channelTypeSchema` |
There was a problem hiding this comment.
如果引入了新的 API 格式,必须同步更新前端的 apiFormatSchema 和 configurableChannelEndpointApiFormats,否则前端将无法识别该格式。
| - 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) 的 `channelTypeSchema` | |
| - 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) 的 `channelTypeSchema` | |
| - 如果引入了新的 API 格式,同步添加到该文件中的 `apiFormatSchema` 和 `configurableChannelEndpointApiFormats` |
| - 在 [frontend/src/features/channels/data/constants.ts](../../../frontend/src/features/channels/data/constants.ts) 中添加渠道配置 | ||
| 4. **同步前端的 schema 与配置** | ||
| - 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) 的 `channelTypeSchema` | ||
| - 在 [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) 中添加 `CHANNEL_CONFIGS` 条目 |
There was a problem hiding this comment.
在 config_channels.ts 中更新 CHANNEL_TYPE_TO_PROVIDER 是必不可少的步骤,用于确保新渠道类型能正确映射到对应的 Provider 分组。
| - 在 [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) 中添加 `CHANNEL_CONFIGS` 条目 | |
| - 在 [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) 中添加 `CHANNEL_CONFIGS` 条目并更新 `CHANNEL_TYPE_TO_PROVIDER` |
No description provided.