From bae5c1faa5468f7c0bca647cb5d0819611700080 Mon Sep 17 00:00:00 2001 From: fengsilin Date: Mon, 11 May 2026 10:08:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(pricing):=20=E9=9A=90=E8=97=8F=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=B9=BF=E5=9C=BA=E6=A0=87=E7=AD=BE=E5=92=8C=E7=AB=AF?= =?UTF-8?q?=E7=82=B9=E7=B1=BB=E5=9E=8B=E7=AD=9B=E9=80=89=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 注释掉模型广场侧边栏和筛选弹窗中的 PricingTags 和 PricingEndpointTypes 组件, 添加 EndpointType 常量及相关组件的文档注释。 Co-Authored-By: Claude --- constant/endpoint_type.go | 28 +++++++++++++------ .../filter/PricingEndpointTypes.jsx | 6 ++++ .../model-pricing/filter/PricingTags.jsx | 3 ++ .../model-pricing/layout/PricingSidebar.jsx | 8 +++--- .../modal/components/FilterModalContent.jsx | 8 +++--- .../view/card/PricingCardView.jsx | 6 ++-- 6 files changed, 41 insertions(+), 18 deletions(-) diff --git a/constant/endpoint_type.go b/constant/endpoint_type.go index 8681bf0..0c642fa 100644 --- a/constant/endpoint_type.go +++ b/constant/endpoint_type.go @@ -1,17 +1,29 @@ package constant +// EndpointType 标识模型支持的 API 端点类型 +// 用于模型广场筛选、渠道定价配置、请求路由判断 +// 前端筛选组件: web/src/components/table/model-pricing/filter/PricingEndpointTypes.jsx type EndpointType string const ( - EndpointTypeOpenAI EndpointType = "openai" - EndpointTypeOpenAIResponse EndpointType = "openai-response" + // OpenAI Chat Completions 格式 (/v1/chat/completions) + EndpointTypeOpenAI EndpointType = "openai" + // OpenAI Responses API 格式 (/v1/responses),用于 o3/o4-mini 等仅支持 Responses 的模型 + EndpointTypeOpenAIResponse EndpointType = "openai-response" + // OpenAI Responses Compact 格式 (/v1/responses/compact),精简输出 EndpointTypeOpenAIResponseCompact EndpointType = "openai-response-compact" - EndpointTypeAnthropic EndpointType = "anthropic" - EndpointTypeGemini EndpointType = "gemini" - EndpointTypeJinaRerank EndpointType = "jina-rerank" - EndpointTypeImageGeneration EndpointType = "image-generation" - EndpointTypeEmbeddings EndpointType = "embeddings" - EndpointTypeOpenAIVideo EndpointType = "openai-video" + // Anthropic Messages API 格式 (/v1/messages) + EndpointTypeAnthropic EndpointType = "anthropic" + // Google Gemini 原生格式 (/v1beta/models/{model}:generateContent) + EndpointTypeGemini EndpointType = "gemini" + // Jina Rerank API 格式 (/v1/rerank) + EndpointTypeJinaRerank EndpointType = "jina-rerank" + // 图片生成 API (/v1/images/generations),如 DALL-E、Midjourney 代理 + EndpointTypeImageGeneration EndpointType = "image-generation" + // 向量嵌入 API (/v1/embeddings) + EndpointTypeEmbeddings EndpointType = "embeddings" + // OpenAI Video API,如 Sora 视频生成 + EndpointTypeOpenAIVideo EndpointType = "openai-video" //EndpointTypeMidjourney EndpointType = "midjourney-proxy" //EndpointTypeSuno EndpointType = "suno-proxy" //EndpointTypeKling EndpointType = "kling" diff --git a/web/src/components/table/model-pricing/filter/PricingEndpointTypes.jsx b/web/src/components/table/model-pricing/filter/PricingEndpointTypes.jsx index 0450f57..a19207c 100644 --- a/web/src/components/table/model-pricing/filter/PricingEndpointTypes.jsx +++ b/web/src/components/table/model-pricing/filter/PricingEndpointTypes.jsx @@ -22,6 +22,11 @@ import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup'; /** * 端点类型筛选组件 + * 端点类型来源: constant.EndpointType (endpoint_type.go) + * 常见值: openai(/v1/chat/completions), anthropic(/v1/messages), gemini, embeddings, + * openai-response(/v1/responses), image-generation, jina-rerank, openai-video 等 + * 模型支持的端点由渠道类型自动推断或管理员在「模型管理 → 编辑模型 → 端点」中自定义 + * 注意: 端点配置仅控制模型广场展示,不影响实际路由 * @param {string|'all'} filterEndpointType 当前值 * @param {Function} setFilterEndpointType setter * @param {Array} models 模型列表 @@ -65,6 +70,7 @@ const PricingEndpointTypes = ({ }; // 端点类型显示名称映射 + // 值对应后端 constant.EndpointType 常量,如 "openai" "anthropic" "gemini" 等 const getEndpointTypeLabel = (endpointType) => { return endpointType; }; diff --git a/web/src/components/table/model-pricing/filter/PricingTags.jsx b/web/src/components/table/model-pricing/filter/PricingTags.jsx index 2d61aa9..f0af7e1 100644 --- a/web/src/components/table/model-pricing/filter/PricingTags.jsx +++ b/web/src/components/table/model-pricing/filter/PricingTags.jsx @@ -22,6 +22,9 @@ import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup'; /** * 模型标签筛选组件 + * 标签来源: Model.Meta.Tags (model_meta.go),逗号/分号/竖线分隔的自由文本 + * 管理员在「模型管理 → 编辑模型 → 标签」中配置,用于模型广场的分类筛选 + * 卡片渲染: PricingCardView 的 renderTags(),最多显示 3 个,颜色由 stringToColor 哈希生成 * @param {string|'all'} filterTag 当前选中的标签 * @param {Function} setFilterTag setter * @param {Array} models 当前过滤后模型列表(用于计数) diff --git a/web/src/components/table/model-pricing/layout/PricingSidebar.jsx b/web/src/components/table/model-pricing/layout/PricingSidebar.jsx index 0b43a25..a1977aa 100644 --- a/web/src/components/table/model-pricing/layout/PricingSidebar.jsx +++ b/web/src/components/table/model-pricing/layout/PricingSidebar.jsx @@ -113,14 +113,14 @@ const PricingSidebar = ({ t={t} /> - + /> */} {/* - + /> */} ); }; diff --git a/web/src/components/table/model-pricing/modal/components/FilterModalContent.jsx b/web/src/components/table/model-pricing/modal/components/FilterModalContent.jsx index 530e0d0..a6fb454 100644 --- a/web/src/components/table/model-pricing/modal/components/FilterModalContent.jsx +++ b/web/src/components/table/model-pricing/modal/components/FilterModalContent.jsx @@ -96,14 +96,14 @@ const FilterModalContent = ({ sidebarProps, t }) => { t={t} /> - + /> */} {/* { t={t} /> - + /> */} ); }; diff --git a/web/src/components/table/model-pricing/view/card/PricingCardView.jsx b/web/src/components/table/model-pricing/view/card/PricingCardView.jsx index 8832f43..3df1966 100644 --- a/web/src/components/table/model-pricing/view/card/PricingCardView.jsx +++ b/web/src/components/table/model-pricing/view/card/PricingCardView.jsx @@ -147,7 +147,9 @@ const PricingCardView = ({ return record.description || ''; }; - // 渲染标签 + // 渲染标签(卡片底部) + // 左侧: 计费类型标签(quota_type: 0=按量计费, 1=按次计费) + // 右侧: 自定义标签(来自 Model.tags,逗号分隔,最多显示3个,颜色由 stringToColor 哈希生成) const renderTags = (record) => { // 计费类型标签(左边) let billingTag = ( @@ -169,7 +171,7 @@ const PricingCardView = ({ ); } - // 自定义标签(右边) + // 自定义标签(右边),来源: Model.Meta.Tags (model_meta.go) const customTags = []; if (record.tags) { const tagArr = record.tags.split(',').filter(Boolean);