feat: implement AI gateway phase one runtime
This commit is contained in:
+116
-32
@@ -311,9 +311,13 @@ AI Gateway 的外部接口必须以“兼容现有 EasyAI 路由、请求 DTO、
|
||||
| `POST` | `/api/v1/auth/register` | `public` | Gateway 本地账号注册,`invitationCode` 可选 |
|
||||
| `POST` | `/api/v1/auth/login` | `public` | Gateway 本地账号登录 |
|
||||
| `GET` | `/api/v1/me` | `basic` | 网关当前身份调试 |
|
||||
| `GET` | `/api/v1/public/catalog/providers` | `public` | 公开 provider 展示目录,供未登录模型页和 API 文档使用 |
|
||||
| `GET` | `/api/v1/public/catalog/base-models` | `public` | 公开基准模型展示目录,不包含平台凭证 |
|
||||
| `GET` | `/api/v1/catalog/providers` | `power` | 基准 provider 列表 |
|
||||
| `GET` | `/api/v1/catalog/base-models` | `power` | 基准模型库列表 |
|
||||
| `GET` | `/api/v1/catalog/base-models/:id` | `power` | 基准模型详情 |
|
||||
| `POST` | `/api/v1/catalog/base-models` | `manager` | 新增基准模型,支持写入能力、基准计费、默认限流和元数据 |
|
||||
| `PATCH` | `/api/v1/catalog/base-models/:id` | `manager` | 修改基准模型 |
|
||||
| `DELETE` | `/api/v1/catalog/base-models/:id` | `manager` | 删除基准模型 |
|
||||
| `GET` | `/api/v1/tenants` | `power` | 网关租户列表,支持本地租户和 server-main 同步租户 |
|
||||
| `GET` | `/api/v1/tenants/:id` | `power` | 租户详情、来源、策略和同步状态 |
|
||||
| `POST` | `/api/v1/tenants/sync` | `power` | 从 `server-main` 拉取或接收租户同步 |
|
||||
@@ -334,6 +338,10 @@ AI Gateway 的外部接口必须以“兼容现有 EasyAI 路由、请求 DTO、
|
||||
| `PATCH` | `/api/v1/api-keys/:id/disable` | `basic` | 禁用本地 API Key |
|
||||
| `POST` | `/api/v1/pricing/estimate` | `basic` | 使用 effective pricing resolver 做价格预估 |
|
||||
| `GET` | `/api/v1/pricing/rules` | `power` | 定价规则列表 |
|
||||
| `GET` | `/api/v1/pricing/rule-sets` | `power` | 定价规则集列表,包含规则集下的多条文本/图像/视频规则 |
|
||||
| `POST` | `/api/v1/pricing/rule-sets` | `manager` | 新增定价规则集 |
|
||||
| `PATCH` | `/api/v1/pricing/rule-sets/:id` | `manager` | 修改定价规则集和其下计价规则 |
|
||||
| `DELETE` | `/api/v1/pricing/rule-sets/:id` | `manager` | 删除定价规则集;已绑定平台/模型需先迁移或按外键策略清空绑定 |
|
||||
| `GET` | `/api/v1/tasks/:taskId` | `basic` | Gateway 任务详情 |
|
||||
| `GET` | `/api/v1/tasks/:taskId/events` | `basic` | SSE 任务进度 |
|
||||
| `GET` | `/api/v1/runtime/clients` | `power` | 客户端运行状态 |
|
||||
@@ -564,19 +572,23 @@ Gateway 需要支持三种身份运行模式,默认配置为 `IDENTITY_MODE=hy
|
||||
| 字段 | 类型 | 约束 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `id` | `uuid` | PK | 基准 provider ID |
|
||||
| `provider_key` | `text` | unique, not null | 稳定 provider key,如 `openai`、`runninghub`、`jimeng` |
|
||||
| `provider_key` | `text` | unique, not null | Gateway 内部稳定 provider key,如 `openai`、`gemini`、`runninghub` |
|
||||
| `provider_code` | `text` | unique, not null | 原 `server-main` `integration-platform.code`,如 `openai`、`google-gemini` |
|
||||
| `display_name` | `text` | not null | 展示名称 |
|
||||
| `provider_type` | `text` | not null | `openai_compatible`、`workflow_app`、`video_vendor`、`audio_vendor` |
|
||||
| `provider_type` | `text` | not null | 对应原 `integration-platform.spec_type`,如 `openai`、`google-gemini`、`runninghub`、`jimeng` |
|
||||
| `icon_path` | `text` | nullable | 原 `integration-platform.icon_path` 或 `Logos[code]` 解析后的图标地址 |
|
||||
| `source` | `text` | not null | `gateway`、`server-main.integration-platform`、`sync` |
|
||||
| `capability_schema` | `jsonb` | not null, default `{}` | provider 支持的能力字段定义 |
|
||||
| `default_rate_limit_policy` | `jsonb` | not null, default `{}` | provider 默认 TPM/RPM/并发模板 |
|
||||
| `status` | `text` | not null | `active`、`deprecated`、`hidden` |
|
||||
| `metadata` | `jsonb` | not null, default `{}` | 文档链接、logo、排序等 |
|
||||
| `metadata` | `jsonb` | not null, default `{}` | 原始同步字段、文档链接、排序等 |
|
||||
| `created_at` | `timestamptz` | not null | 创建时间 |
|
||||
| `updated_at` | `timestamptz` | not null | 更新时间 |
|
||||
|
||||
索引:
|
||||
|
||||
- `uniq_model_catalog_provider_key(provider_key)`
|
||||
- `idx_model_catalog_provider_code(provider_code)`
|
||||
- `idx_model_catalog_provider_status(status)`
|
||||
|
||||
#### 7.9.2 `base_model_catalog`
|
||||
@@ -590,7 +602,7 @@ Gateway 需要支持三种身份运行模式,默认配置为 `IDENTITY_MODE=hy
|
||||
| `provider_key` | `text` | not null | 冗余 provider key,方便查询 |
|
||||
| `canonical_model_key` | `text` | unique, not null | Gateway 内部标准模型 key |
|
||||
| `provider_model_name` | `text` | not null | 供应商原始模型名 |
|
||||
| `model_type` | `text` | not null | `chat`、`image`、`video`、`audio`、`embedding`、`music`、`digital_human`、`model_3d` |
|
||||
| `model_type` | `text` | not null | 原 `PlatformModelType` 主类型,如 `text_generate`、`image_generate`、`image_edit`、`video_generate`、`image_to_video`、`omni_video` 等 |
|
||||
| `display_name` | `text` | not null | 展示名称 |
|
||||
| `capabilities` | `jsonb` | not null, default `{}` | 上下文、多模态、参考图/视频/音频、尺寸、时长、质量等基准能力 |
|
||||
| `base_billing_config` | `jsonb` | not null, default `{}` | 基准计费配置 |
|
||||
@@ -607,21 +619,47 @@ Gateway 需要支持三种身份运行模式,默认配置为 `IDENTITY_MODE=hy
|
||||
- `idx_base_model_catalog_provider(provider_key, model_type, status)`
|
||||
- `idx_base_model_catalog_capabilities` 使用 `GIN(capabilities)`
|
||||
|
||||
#### 7.9.3 `model_pricing_rules`
|
||||
#### 7.9.3 `model_pricing_rule_sets` / `model_pricing_rules`
|
||||
|
||||
保存基准模型和平台模型的可版本化价格规则。平台模型没有自定义规则时,使用 `base_model_catalog.base_billing_config` 并应用折扣。
|
||||
定价规则从“单条规则散落在模型或平台上”调整为“规则集 + 多条计价规则”。规则集是可绑定对象,规则是具体资源维度的计算条目。默认规则集必须覆盖文本、图像、视频,后续新增音频、音乐、数字人、3D 等能力时只新增规则,不改变平台和模型绑定关系。
|
||||
|
||||
`model_pricing_rule_sets` 保存规则集:
|
||||
|
||||
| 字段 | 类型 | 约束 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `id` | `uuid` | PK | 规则集 ID |
|
||||
| `rule_set_key` | `text` | unique, not null | 稳定 key,如 `default-multimodal-v1` |
|
||||
| `name` | `text` | not null | 展示名称 |
|
||||
| `description` | `text` | nullable | 说明 |
|
||||
| `category` | `text` | not null, default `custom` | `default`、`custom`、`provider`、`model` |
|
||||
| `currency` | `text` | not null, default `resource` | 默认货币或资源单位 |
|
||||
| `status` | `text` | not null, default `active` | `active`、`deprecated`、`hidden` |
|
||||
| `metadata` | `jsonb` | not null, default `{}` | 来源、版本、同步信息、展示扩展 |
|
||||
| `created_at` | `timestamptz` | not null | 创建时间 |
|
||||
| `updated_at` | `timestamptz` | not null | 更新时间 |
|
||||
|
||||
`model_pricing_rules` 保存规则集下的计价规则:
|
||||
|
||||
| 字段 | 类型 | 约束 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `id` | `uuid` | PK | 价格规则 ID |
|
||||
| `scope_type` | `text` | not null | `base_model`、`platform`、`platform_model` |
|
||||
| `scope_id` | `uuid` | nullable | 对应基准模型、平台或平台模型 ID |
|
||||
| `rule_set_id` | `uuid` | FK nullable | 所属规则集;兼容旧数据时可为空 |
|
||||
| `rule_key` | `text` | not null | 规则集内稳定 key,如 `text_input_tokens` |
|
||||
| `display_name` | `text` | not null | 展示名称 |
|
||||
| `scope_type` | `text` | not null | 默认 `rule_set`;兼容旧数据可为 `base_model`、`platform`、`platform_model` |
|
||||
| `scope_id` | `uuid` | nullable | 旧 scope 兼容字段;新规则集模式通常为空 |
|
||||
| `resource_type` | `text` | not null | `text_input`、`text_output`、`image`、`video`、`audio`、`music`、`digital_human`、`model` |
|
||||
| `unit` | `text` | not null | `1k_tokens`、`image`、`5s`、`second`、`character_1k`、`item` |
|
||||
| `base_price` | `numeric` | not null | 基准单价,单位使用 EasyAI resource / credit |
|
||||
| `currency` | `text` | not null, default `resource` | `resource`、`credit`、`cny`、`usd` |
|
||||
| `base_weight` | `jsonb` | not null, default `{}` | 固定权重,如默认倍率 |
|
||||
| `dynamic_weight` | `jsonb` | not null, default `{}` | 分辨率、质量、时长、有无音频等动态权重 |
|
||||
| `dynamic_weight` | `jsonb` | not null, default `{}` | 分辨率、质量、时长、有无音频、有无参考视频等动态权重 |
|
||||
| `calculator_type` | `text` | not null, default `weighted_unit` | `token_usage`、`weighted_unit`、`duration_weighted`、`formula` |
|
||||
| `dimension_schema` | `jsonb` | not null, default `{}` | 本规则消费的维度定义,如 token、resolution、duration、hasAudio |
|
||||
| `formula_config` | `jsonb` | not null, default `{}` | 计算公式配置、单位换算和缺省值 |
|
||||
| `priority` | `int` | not null, default `100` | 规则执行顺序 |
|
||||
| `status` | `text` | not null, default `active` | `active`、`deprecated`、`hidden` |
|
||||
| `metadata` | `jsonb` | not null, default `{}` | provider 原始字段、价格版本、说明 |
|
||||
| `effective_from` | `timestamptz` | nullable | 生效开始 |
|
||||
| `effective_to` | `timestamptz` | nullable | 生效结束 |
|
||||
| `created_at` | `timestamptz` | not null | 创建时间 |
|
||||
@@ -630,6 +668,8 @@ Gateway 需要支持三种身份运行模式,默认配置为 `IDENTITY_MODE=hy
|
||||
索引:
|
||||
|
||||
- `idx_model_pricing_scope(scope_type, scope_id, resource_type)`
|
||||
- `idx_model_pricing_rule_set(rule_set_id, resource_type)`
|
||||
- `idx_model_pricing_rule_set_key(rule_set_id, rule_key)` 唯一
|
||||
- `idx_model_pricing_effective(effective_from, effective_to)`
|
||||
|
||||
#### 7.9.4 `gateway_tenants`
|
||||
@@ -881,6 +921,7 @@ Gateway 需要支持三种身份运行模式,默认配置为 `IDENTITY_MODE=hy
|
||||
| `tenant_key` | `text` | nullable | Gateway 租户 key |
|
||||
| `default_pricing_mode` | `text` | not null, default `inherit_discount` | 平台默认价格模式:`inherit`、`inherit_discount`、`custom` |
|
||||
| `default_discount_factor` | `numeric` | not null, default `1` | 平台默认折扣系数,创建平台时可统一基于基准模型打折 |
|
||||
| `pricing_rule_set_id` | `uuid` | FK nullable | 平台默认绑定的定价规则集;为空时 follow 基准模型或全局默认规则集 |
|
||||
| `retry_policy` | `jsonb` | not null, default `{}` | 平台级重试策略 |
|
||||
| `rate_limit_policy` | `jsonb` | not null, default `{}` | 平台级限流策略 |
|
||||
| `priority` | `int` | not null, default `100` | 静态优先级,越小越优先 |
|
||||
@@ -914,6 +955,7 @@ Gateway 需要支持三种身份运行模式,默认配置为 `IDENTITY_MODE=hy
|
||||
| `capabilities` | `jsonb` | not null, default `{}` | 解析后的有效能力,用于路由和前端展示 |
|
||||
| `pricing_mode` | `text` | not null, default `inherit_discount` | `inherit`、`inherit_discount`、`custom` |
|
||||
| `discount_factor` | `numeric` | nullable | 模型级折扣,空值时继承平台默认折扣 |
|
||||
| `pricing_rule_set_id` | `uuid` | FK nullable | 模型级定价规则集;优先级高于平台绑定规则集 |
|
||||
| `billing_config_override` | `jsonb` | not null, default `{}` | 自定义计费覆盖 |
|
||||
| `billing_config` | `jsonb` | not null, default `{}` | 解析后的有效计费配置,用于 estimated billing 和真实 billings |
|
||||
| `permission_config` | `jsonb` | not null, default `{}` | 平台维度权限过滤配置 |
|
||||
@@ -1285,7 +1327,17 @@ RPM 和并发的边界:
|
||||
|
||||
## 9. 基准模型库与定价体系
|
||||
|
||||
定价不直接散落在平台模型里。Gateway 先有一个基准模型库,基准模型库存所有 provider、模型、能力、默认限流模板和基准价格;平台创建和平台模型配置都基于这个库继承或覆盖。
|
||||
定价不直接散落在平台模型里。Gateway 先有一个基准模型库,基准模型库存所有 provider、模型、能力、默认限流模板和基准计价规则;平台创建和平台模型配置都通过“规则集绑定 + 折扣率”继承或覆盖。
|
||||
|
||||
新的定价核心是 `model_pricing_rule_sets`:
|
||||
|
||||
- 一个规则集可以包含多条计价规则,默认规则集覆盖文本、图像、视频。
|
||||
- 平台可绑定一个规则集,并设置 `default_discount_factor` 做整体价格调节。
|
||||
- 平台模型可绑定另一个规则集,并设置 `discount_factor` 做模型级整体调节。
|
||||
- 未绑定模型规则集时继承平台规则集;平台也未绑定时 follow 基准模型或全局默认规则集。
|
||||
- 折扣率只调整最终价格,不改变规则本身,便于后续对同一规则做不同平台、不同模型的商业策略。
|
||||
|
||||
Provider 目录从原 `easyai-server-main` 的 `integration-platform` 模块同步:`name` 映射为 `display_name`,`code` 映射为 `provider_code`,`icon_path` 优先使用平台配置,缺省时按原模块 `Logos[code]` 解析。Gateway 运行时仍保留 `provider_key` 作为内部路由 key,避免原平台 code 改名影响已有任务与平台模型配置。
|
||||
|
||||
### 9.1 基准模型库内容
|
||||
|
||||
@@ -1296,32 +1348,61 @@ RPM 和并发的边界:
|
||||
- provider model name:供应商真实请求模型名。
|
||||
- model type:`chat`、`image`、`video`、`audio`、`embedding`、`music`、`digital_human`、`model_3d`。
|
||||
- capabilities:上下文窗口、stream、多模态输入、参考图、参考视频、参考音频、支持尺寸、质量、时长、有无音频、最大 batch 等。
|
||||
- base billing config:文本、图像、视频、音频等不同能力的基准价格。
|
||||
- base billing config:兼容旧配置的价格快照;新价格以定价规则集为准。
|
||||
- default pricing rule set:推荐绑定的默认计价规则集,可覆盖文本、图像、视频等多种能力。
|
||||
- default rate limit policy:provider 或模型默认 TPM/RPM/并发模板。
|
||||
|
||||
### 9.2 平台价格继承与覆盖
|
||||
### 9.2 定价规则集与绑定
|
||||
|
||||
创建平台时有三种方式:
|
||||
创建平台或平台模型时不直接编辑散落的单价,而是选择定价规则集:
|
||||
|
||||
| 绑定位置 | 字段 | 生效范围 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| 基准模型 | `base_model_catalog.base_billing_config` / metadata | fallback | 兼容旧价格快照,也可记录推荐默认规则集 key |
|
||||
| 平台 | `integration_platforms.pricing_rule_set_id` | 平台下所有未覆盖模型 | 创建平台时选择规则集,并用 `default_discount_factor` 做整体折扣 |
|
||||
| 平台模型 | `platform_models.pricing_rule_set_id` | 单个模型 | 模型单独选择规则集,并用 `discount_factor` 覆盖平台折扣 |
|
||||
|
||||
有效规则集解析顺序:
|
||||
|
||||
1. 平台模型 `pricing_rule_set_id`。
|
||||
2. 平台 `pricing_rule_set_id`。
|
||||
3. 基准模型推荐规则集或 `base_billing_config` 映射出的规则集。
|
||||
4. 全局默认规则集 `default-multimodal-v1`。
|
||||
|
||||
有效折扣解析顺序:
|
||||
|
||||
1. 平台模型 `discount_factor`。
|
||||
2. 平台 `default_discount_factor`。
|
||||
3. 用户组 `billing_discount_policy`,用于用户组级模型调用折扣。
|
||||
4. 租户、API Key 或促销策略的额外折扣,按策略优先级合并。
|
||||
|
||||
有效价计算:
|
||||
|
||||
```text
|
||||
effective price = rule price(request dimensions) * platform/model discount * user/group policy discount
|
||||
```
|
||||
|
||||
### 9.3 规则集模式
|
||||
|
||||
| 模式 | 配置 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `inherit` | 不填价格 | 完全 follow 基准模型价格和能力 |
|
||||
| `inherit_discount` | `default_discount_factor` 或模型级 `discount_factor` | 有效价 = 基准价 x 折扣系数;能力默认 follow 基准模型,可局部覆盖 |
|
||||
| `custom` | `billing_config_override` / `capability_override` | 平台模型完全自定义价格或能力,未覆盖字段仍从基准模型补齐 |
|
||||
| `inherit` | 不填规则集,不填折扣 | follow 上一级规则集和能力 |
|
||||
| `inherit_discount` | 继承规则集,只填平台或模型折扣 | 有效价 = 继承规则集价格 x 折扣系数;能力默认 follow 基准模型,可局部覆盖 |
|
||||
| `custom` | 绑定自定义规则集 / `capability_override` | 使用自定义规则集和能力覆盖;未覆盖能力仍从基准模型补齐 |
|
||||
|
||||
有效配置解析顺序:
|
||||
|
||||
1. 平台模型 `capability_override` / `billing_config_override`。
|
||||
2. 平台模型 `discount_factor`。
|
||||
3. 平台 `default_discount_factor`。
|
||||
4. 用户组 `billing_discount_policy`,用于用户组级模型调用折扣。
|
||||
5. 基准模型 `capabilities` / `base_billing_config`。
|
||||
1. 平台模型 `capability_override`。
|
||||
2. 平台模型 `pricing_rule_set_id` / `discount_factor`。
|
||||
3. 平台 `pricing_rule_set_id` / `default_discount_factor`。
|
||||
4. 用户组、租户、API Key 的折扣和配额策略。
|
||||
5. 基准模型 `capabilities` / 默认规则集。
|
||||
|
||||
如果没有配置平台模型价格,必须 follow 基准模型;不能出现空价格导致预估扣费为 0 的隐式行为。
|
||||
如果没有配置平台模型定价,必须 follow 上一级规则集;不能出现空价格导致预估扣费为 0 的隐式行为。
|
||||
|
||||
接入 `server-main` 时,充值折扣不在 Gateway 内直接变更余额。Gateway 只保存 `recharge_discount_policy` 并与主服务同步;充值订单、资源包发放、余额流水仍由 `server-main` 作为事实源执行。独立模式下,充值、余额、订单和钱包流水由 Gateway 本地账务模块闭环。
|
||||
|
||||
### 9.3 各能力计价模型
|
||||
### 9.4 各能力计价模型
|
||||
|
||||
文本类:
|
||||
|
||||
@@ -1329,6 +1410,7 @@ RPM 和并发的边界:
|
||||
- 输入和输出分开计价:`text_input`、`text_output`。
|
||||
- 如果模型只配置总价,可 fallback 到 `text_total`,但 resolver 对外仍展开成输入/输出明细。
|
||||
- 预估时用输入 token + 输出 token 预估值;最终结算用 provider usage 或 Gateway tokenizer 回填。
|
||||
- 规则维度:`input_tokens`、`output_tokens`、`cached_tokens`、`reasoning_tokens`、`unitScale`。
|
||||
|
||||
图像类:
|
||||
|
||||
@@ -1337,6 +1419,7 @@ RPM 和并发的边界:
|
||||
- 分辨率示例:`512x512`、`1024x1024`、`1K`、`2K`、`4K`、`8K`。
|
||||
- 质量示例:`standard`、`hd`、`high`、`ultra`。
|
||||
- 公式示例:`count * basePrice * resolutionWeight * qualityWeight * modeWeight`。
|
||||
- 规则维度:`resolution`、`quality`、`count`、`mode`、`referenceImageCount`、`mask`。
|
||||
|
||||
视频类:
|
||||
|
||||
@@ -1344,6 +1427,7 @@ RPM 和并发的边界:
|
||||
- 动态权重至少支持:时长、分辨率、是否包含音频、是否使用参考视频、是否指定声音/音色、生成数量。
|
||||
- 分辨率示例:`480p`、`720p`、`1080p`、`2160p`。
|
||||
- 公式示例:`count * ceil(durationSeconds / unitSeconds) * basePrice * resolutionWeight * audioWeight * referenceWeight`。
|
||||
- 规则维度:`durationSeconds`、`resolution`、`count`、`hasAudio`、`hasReferenceVideo`、`hasReferenceImage`、`voice`。
|
||||
|
||||
音频、音乐、数字人、3D 模型:
|
||||
|
||||
@@ -1352,7 +1436,7 @@ RPM 和并发的边界:
|
||||
- 数字人可按时长、分辨率、音频驱动方式计费。
|
||||
- 3D / model 类按任务数、模型复杂度或 provider 返回的计费单位映射。
|
||||
|
||||
### 9.4 estimated billing 一致性
|
||||
### 9.5 estimated billing 一致性
|
||||
|
||||
`/integration-platform/models/estimatedBilling`、`/integration-platform/models/estimatedBilling/:workflowId` 和真实任务结算必须使用同一个 resolver:
|
||||
|
||||
@@ -1909,7 +1993,7 @@ type ServerMainUploadClient interface {
|
||||
| 全局模型配置 | `/admin/models/global` | `power` | 基准模型库、能力 schema、基准定价、默认限流模板 |
|
||||
| 基准 Provider | `/admin/catalog/providers` | `power` | provider 列表、协议类型、能力 schema、启停状态 |
|
||||
| 基准模型详情 | `/admin/catalog/base-models/:id` | `power` | 能力、价格版本、默认 TPM/RPM/并发、引用平台模型 |
|
||||
| 定价规则 | `/admin/pricing/rules` | `power` | 文本/图像/视频/音频价格、动态权重、版本生效时间 |
|
||||
| 定价规则 | `/admin/pricing/rules` | `power` | 定价规则集、文本/图像/视频规则、动态权重、平台/模型绑定引用 |
|
||||
| 平台管理 | `/admin/platforms` | `power` | 平台 CRUD、启停、优先级、凭证状态、复制、异常重置 |
|
||||
| 平台详情 | `/admin/platforms/:id` | `power` | 基础信息、凭证、模型、折扣、限流、重试、运行态、快照 |
|
||||
| 平台模型 | `/admin/platform-models` | `power` | 平台模型列表、基准映射、能力覆盖、价格覆盖、权限过滤 |
|
||||
@@ -1927,11 +2011,11 @@ type ServerMainUploadClient interface {
|
||||
|
||||
关键管理页面:
|
||||
|
||||
- 全局模型配置:维护 `model_catalog_providers`、`base_model_catalog`、`model_pricing_rules`,支持导入旧项目配置。
|
||||
- 全局模型配置:维护 `model_catalog_providers`、`base_model_catalog`、`model_pricing_rule_sets`、`model_pricing_rules`,支持从旧项目 `integration-platform` 同步 provider 名称、code、图标和全量模型基准配置。基准模型库在管理端以模型卡片呈现,可按厂商、能力、名称筛选,并通过弹窗新增、修改、删除模型。
|
||||
- 租户管理:维护 `gateway_tenants`,支持本地租户 CRUD、从 `server-main` 增量同步、禁用状态同步、租户策略和用量隔离审计。
|
||||
- 用户管理:维护 `gateway_users`,支持本地用户 CRUD、从 `server-main` 增量同步、禁用状态同步、角色同步和同步差异审计。
|
||||
- 用户组管理:维护 `gateway_user_groups`、`gateway_user_group_memberships`,支持从 `server-main` 同步成员关系;独立模式执行全部策略,接入模式下充值折扣由 `server-main` 执行,Gateway 执行调用折扣和并发/限流。
|
||||
- 平台管理:创建平台时选择基准 provider,配置默认折扣系数;平台模型可 follow 基准、按折扣继承或自定义覆盖。
|
||||
- 平台管理:创建平台时选择基准 provider、默认定价规则集和默认折扣系数;平台模型可继承平台规则集,或单独绑定规则集并配置模型折扣率。
|
||||
- 队列与限流:展示 TPM/RPM 窗口、预占值、并发 lease、cooldown、next run。
|
||||
- 回调 outbox:展示 Gateway 到进度回调目标的投递结果,支持按 task replay。
|
||||
|
||||
@@ -2038,15 +2122,15 @@ apps/web/src/
|
||||
- 建立 JWT / API Key 授权中间件骨架和 `standalone` / `server-main` / `hybrid` 身份模式配置,默认 `hybrid`。
|
||||
- 固化 API、事件、数据库设计。
|
||||
- 建立 simulation / dry-run 模式配置与安全开关,默认禁止生产环境普通用户随意开启。
|
||||
- 建立基准 provider、基准模型库、价格规则、用户、用户组策略、邀请码、本地 API Key、钱包、充值订单和 TPM/RPM/并发限流表结构。
|
||||
- 建立基准 provider、基准模型库、定价规则集、用户、用户组策略、邀请码、本地 API Key、钱包、充值订单和 TPM/RPM/并发限流表结构。
|
||||
|
||||
### Phase 1:模型库 + 首批生成能力
|
||||
|
||||
第一阶段只做可落地的核心闭环:模型库、大模型对话、生图、图像编辑。Client 只迁移 OpenAI 和 Gemini 两个,视频和其他 provider 后移。
|
||||
|
||||
- 导入 OpenAI、Gemini 的基准 provider、基准模型、能力 schema、默认限流模板,形成首批 `base_model_catalog`。
|
||||
- 建立全局模型配置:模型类型、上下文、多模态能力、图片输入/输出能力、stream 支持、价格规则。
|
||||
- 平台创建支持选择基准模型、设置默认折扣系数;平台模型支持 follow 基准模型、折扣继承和自定义覆盖。
|
||||
- 默认导入原 `integration-platform` 的全量 provider 和基准模型,完整保留模型 `types`、`capabilities`、图标、计费和限流元数据;Phase 1 只迁移 OpenAI、Gemini 两个 Client 的真实调用实现。
|
||||
- 建立全局模型配置:模型类型、上下文、多模态能力、图片输入/输出能力、stream 支持、定价规则集。
|
||||
- 平台创建支持选择基准 provider、默认定价规则集、默认折扣系数;平台模型支持 follow 平台规则集、模型级规则集覆盖、折扣继承和自定义覆盖。
|
||||
- 建立 `gateway_users` 同步副本和 `gateway_user_groups` 策略解析,支持本地用户与 `server-main` 用户在同一套策略链路里命中不同折扣和限流。
|
||||
- 建立本地账号闭环:普通注册可选邀请码,独立模式支持本地 API Key、余额、充值订单和钱包流水。
|
||||
- 迁移大模型对话路由:`/chat/completions`、`/v1/chat/completions`,并为 `/responses` / `/v1/responses` 保留兼容契约。
|
||||
|
||||
Reference in New Issue
Block a user