From bf577b8937a04ab3a634bced46be5c36a4fd1712 Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Fri, 4 Jul 2025 03:15:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8C=20feat(api):=20extend=20endpoint?= =?UTF-8?q?=20type=20support=20&=20expose=20in=20pricing=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * backend - constant/endpoint_type.go • Add EndpointTypeMidjourney, EndpointTypeSuno, EndpointTypeKling, EndpointTypeJimeng. - common/endpoint_type.go • Map Midjourney / MidjourneyPlus, SunoAPI, Kling, Jimeng channel types to the new endpoint types. * frontend - ModelPricing.js • Add “Supported Endpoint Type” column. • Implement renderSupportedEndpoints with `stringToColor` for consistent tag colors. These changes allow `/api/pricing` and model lists to return accurate `supported_endpoint_types` covering all non-OpenAI providers and display them clearly in the UI. No breaking changes. --- common/endpoint_type.go | 8 ++++++ constant/endpoint_type.go | 4 +++ web/src/components/table/ModelPricing.js | 31 ++++++++++++++++++++++-- web/src/i18n/locales/en.json | 4 ++- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/common/endpoint_type.go b/common/endpoint_type.go index 09174f23..58936eea 100644 --- a/common/endpoint_type.go +++ b/common/endpoint_type.go @@ -8,6 +8,14 @@ func GetEndpointTypesByChannelType(channelType int, modelName string) []constant switch channelType { case constant.ChannelTypeJina: endpointTypes = []constant.EndpointType{constant.EndpointTypeJinaRerank} + case constant.ChannelTypeMidjourney, constant.ChannelTypeMidjourneyPlus: + endpointTypes = []constant.EndpointType{constant.EndpointTypeMidjourney} + case constant.ChannelTypeSunoAPI: + endpointTypes = []constant.EndpointType{constant.EndpointTypeSuno} + case constant.ChannelTypeKling: + endpointTypes = []constant.EndpointType{constant.EndpointTypeKling} + case constant.ChannelTypeJimeng: + endpointTypes = []constant.EndpointType{constant.EndpointTypeJimeng} case constant.ChannelTypeAws: fallthrough case constant.ChannelTypeAnthropic: diff --git a/constant/endpoint_type.go b/constant/endpoint_type.go index a1b840db..323bf2d6 100644 --- a/constant/endpoint_type.go +++ b/constant/endpoint_type.go @@ -8,4 +8,8 @@ const ( EndpointTypeAnthropic EndpointType = "anthropic" EndpointTypeGemini EndpointType = "gemini" EndpointTypeJinaRerank EndpointType = "jina-rerank" + EndpointTypeMidjourney EndpointType = "midjourney-proxy" + EndpointTypeSuno EndpointType = "suno-proxy" + EndpointTypeKling EndpointType = "kling" + EndpointTypeJimeng EndpointType = "jimeng" ) diff --git a/web/src/components/table/ModelPricing.js b/web/src/components/table/ModelPricing.js index 56d40257..bf9df911 100644 --- a/web/src/components/table/ModelPricing.js +++ b/web/src/components/table/ModelPricing.js @@ -1,5 +1,5 @@ import React, { useContext, useEffect, useRef, useMemo, useState } from 'react'; -import { API, copy, showError, showInfo, showSuccess, getModelCategories, renderModelTag } from '../../helpers'; +import { API, copy, showError, showInfo, showSuccess, getModelCategories, renderModelTag, stringToColor } from '../../helpers'; import { useTranslation } from 'react-i18next'; import { @@ -106,6 +106,26 @@ const ModelPricing = () => { ) : null; } + function renderSupportedEndpoints(endpoints) { + if (!endpoints || endpoints.length === 0) { + return null; + } + return ( + + {endpoints.map((endpoint, idx) => ( + + {endpoint} + + ))} + + ); + } + const columns = [ { title: t('可用性'), @@ -120,6 +140,13 @@ const ModelPricing = () => { }, defaultSortOrder: 'descend', }, + { + title: t('可用端点类型'), + dataIndex: 'supported_endpoint_types', + render: (text, record, index) => { + return renderSupportedEndpoints(text); + }, + }, { title: t('模型名称'), dataIndex: 'model_name', @@ -499,7 +526,7 @@ const ModelPricing = () => {
- {t('未登录,使用默认分组倍率')}: {groupRatio['default']} + {t('未登录,使用默认分组倍率:')}{groupRatio['default']}
)} diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json index 9a0369e6..a5ac694f 100644 --- a/web/src/i18n/locales/en.json +++ b/web/src/i18n/locales/en.json @@ -1750,5 +1750,7 @@ "批量创建时会在名称后自动添加随机后缀": "When creating in batches, a random suffix will be automatically added to the name", "额度必须大于0": "Quota must be greater than 0", "生成数量必须大于0": "Generation quantity must be greater than 0", - "创建后可在编辑渠道时获取上游模型列表": "After creation, you can get the upstream model list when editing the channel" + "创建后可在编辑渠道时获取上游模型列表": "After creation, you can get the upstream model list when editing the channel", + "可用端点类型": "Supported endpoint types", + "未登录,使用默认分组倍率:": "Not logged in, using default group ratio: " } \ No newline at end of file