注释掉模型广场侧边栏和筛选弹窗中的 PricingTags 和 PricingEndpointTypes 组件, 添加 EndpointType 常量及相关组件的文档注释。 Co-Authored-By: Claude <noreply@anthropic.com>master
| @@ -1,17 +1,29 @@ | |||||
| package constant | package constant | ||||
| // EndpointType 标识模型支持的 API 端点类型 | |||||
| // 用于模型广场筛选、渠道定价配置、请求路由判断 | |||||
| // 前端筛选组件: web/src/components/table/model-pricing/filter/PricingEndpointTypes.jsx | |||||
| type EndpointType string | type EndpointType string | ||||
| const ( | 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" | 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" | //EndpointTypeMidjourney EndpointType = "midjourney-proxy" | ||||
| //EndpointTypeSuno EndpointType = "suno-proxy" | //EndpointTypeSuno EndpointType = "suno-proxy" | ||||
| //EndpointTypeKling EndpointType = "kling" | //EndpointTypeKling EndpointType = "kling" | ||||
| @@ -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 {string|'all'} filterEndpointType 当前值 | ||||
| * @param {Function} setFilterEndpointType setter | * @param {Function} setFilterEndpointType setter | ||||
| * @param {Array} models 模型列表 | * @param {Array} models 模型列表 | ||||
| @@ -65,6 +70,7 @@ const PricingEndpointTypes = ({ | |||||
| }; | }; | ||||
| // 端点类型显示名称映射 | // 端点类型显示名称映射 | ||||
| // 值对应后端 constant.EndpointType 常量,如 "openai" "anthropic" "gemini" 等 | |||||
| const getEndpointTypeLabel = (endpointType) => { | const getEndpointTypeLabel = (endpointType) => { | ||||
| return endpointType; | return endpointType; | ||||
| }; | }; | ||||
| @@ -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 {string|'all'} filterTag 当前选中的标签 | ||||
| * @param {Function} setFilterTag setter | * @param {Function} setFilterTag setter | ||||
| * @param {Array} models 当前过滤后模型列表(用于计数) | * @param {Array} models 当前过滤后模型列表(用于计数) | ||||
| @@ -113,14 +113,14 @@ const PricingSidebar = ({ | |||||
| t={t} | t={t} | ||||
| /> | /> | ||||
| <PricingTags | |||||
| {/* <PricingTags | |||||
| filterTag={filterTag} | filterTag={filterTag} | ||||
| setFilterTag={setFilterTag} | setFilterTag={setFilterTag} | ||||
| models={tagModels} | models={tagModels} | ||||
| allModels={categoryProps.models} | allModels={categoryProps.models} | ||||
| loading={loading} | loading={loading} | ||||
| t={t} | t={t} | ||||
| /> | |||||
| /> */} | |||||
| {/* <PricingGroups | {/* <PricingGroups | ||||
| filterGroup={filterGroup} | filterGroup={filterGroup} | ||||
| @@ -140,14 +140,14 @@ const PricingSidebar = ({ | |||||
| t={t} | t={t} | ||||
| /> | /> | ||||
| <PricingEndpointTypes | |||||
| {/* <PricingEndpointTypes | |||||
| filterEndpointType={filterEndpointType} | filterEndpointType={filterEndpointType} | ||||
| setFilterEndpointType={setFilterEndpointType} | setFilterEndpointType={setFilterEndpointType} | ||||
| models={endpointTypeModels} | models={endpointTypeModels} | ||||
| allModels={categoryProps.models} | allModels={categoryProps.models} | ||||
| loading={loading} | loading={loading} | ||||
| t={t} | t={t} | ||||
| /> | |||||
| /> */} | |||||
| </div> | </div> | ||||
| ); | ); | ||||
| }; | }; | ||||
| @@ -96,14 +96,14 @@ const FilterModalContent = ({ sidebarProps, t }) => { | |||||
| t={t} | t={t} | ||||
| /> | /> | ||||
| <PricingTags | |||||
| {/* <PricingTags | |||||
| filterTag={filterTag} | filterTag={filterTag} | ||||
| setFilterTag={setFilterTag} | setFilterTag={setFilterTag} | ||||
| models={tagModels} | models={tagModels} | ||||
| allModels={categoryProps.models} | allModels={categoryProps.models} | ||||
| loading={loading} | loading={loading} | ||||
| t={t} | t={t} | ||||
| /> | |||||
| /> */} | |||||
| {/* <PricingGroups | {/* <PricingGroups | ||||
| filterGroup={filterGroup} | filterGroup={filterGroup} | ||||
| @@ -123,14 +123,14 @@ const FilterModalContent = ({ sidebarProps, t }) => { | |||||
| t={t} | t={t} | ||||
| /> | /> | ||||
| <PricingEndpointTypes | |||||
| {/* <PricingEndpointTypes | |||||
| filterEndpointType={filterEndpointType} | filterEndpointType={filterEndpointType} | ||||
| setFilterEndpointType={setFilterEndpointType} | setFilterEndpointType={setFilterEndpointType} | ||||
| models={endpointTypeModels} | models={endpointTypeModels} | ||||
| allModels={categoryProps.models} | allModels={categoryProps.models} | ||||
| loading={loading} | loading={loading} | ||||
| t={t} | t={t} | ||||
| /> | |||||
| /> */} | |||||
| </> | </> | ||||
| ); | ); | ||||
| }; | }; | ||||
| @@ -147,7 +147,9 @@ const PricingCardView = ({ | |||||
| return record.description || ''; | return record.description || ''; | ||||
| }; | }; | ||||
| // 渲染标签 | |||||
| // 渲染标签(卡片底部) | |||||
| // 左侧: 计费类型标签(quota_type: 0=按量计费, 1=按次计费) | |||||
| // 右侧: 自定义标签(来自 Model.tags,逗号分隔,最多显示3个,颜色由 stringToColor 哈希生成) | |||||
| const renderTags = (record) => { | const renderTags = (record) => { | ||||
| // 计费类型标签(左边) | // 计费类型标签(左边) | ||||
| let billingTag = ( | let billingTag = ( | ||||
| @@ -169,7 +171,7 @@ const PricingCardView = ({ | |||||
| ); | ); | ||||
| } | } | ||||
| // 自定义标签(右边) | |||||
| // 自定义标签(右边),来源: Model.Meta.Tags (model_meta.go) | |||||
| const customTags = []; | const customTags = []; | ||||
| if (record.tags) { | if (record.tags) { | ||||
| const tagArr = record.tags.split(',').filter(Boolean); | const tagArr = record.tags.split(',').filter(Boolean); | ||||