From 39932cee5133298be7170a30f9593795a976fac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BA=B2?= Date: Thu, 21 Aug 2025 15:36:28 +0800 Subject: [PATCH] fix: use ai model info from ModelKit repo --- ui/src/api/Model.ts | 4 +- ui/src/api/OpenAiv1.ts | 6 +- ui/src/api/types.ts | 375 ++++++++++++++---- ui/src/assets/fonts/iconfont.js | 2 +- ui/src/pages/model/components/modelCard.tsx | 15 +- .../model/components/services/modelService.ts | 33 +- ui/src/pages/model/constant.ts | 114 ------ ui/src/pages/model/index.tsx | 6 +- 8 files changed, 330 insertions(+), 225 deletions(-) delete mode 100644 ui/src/pages/model/constant.ts diff --git a/ui/src/api/Model.ts b/ui/src/api/Model.ts index c34dcd7..4cfb25a 100644 --- a/ui/src/api/Model.ts +++ b/ui/src/api/Model.ts @@ -14,7 +14,6 @@ import request, { ContentType, RequestParams } from "./httpClient"; import { DeleteDeleteModelParams, DomainAllModelResp, - DomainCheckModelReq, DomainCreateModelReq, DomainGetProviderModelListResp, DomainModel, @@ -23,6 +22,7 @@ import { GetGetProviderModelListParams, GetGetTokenUsageParams, GetMyModelListParams, + GithubComChaitinMonkeyCodeBackendDomainCheckModelReq, WebResp, } from "./types"; @@ -149,7 +149,7 @@ export const deleteDeleteModel = ( */ export const postCheckModel = ( - model: DomainCheckModelReq, + model: GithubComChaitinMonkeyCodeBackendDomainCheckModelReq, params: RequestParams = {}, ) => request< diff --git a/ui/src/api/OpenAiv1.ts b/ui/src/api/OpenAiv1.ts index 8ae838f..7459c2f 100644 --- a/ui/src/api/OpenAiv1.ts +++ b/ui/src/api/OpenAiv1.ts @@ -17,9 +17,9 @@ import { DomainListSecurityScanningBriefResp, DomainListSecurityScanningDetailResp, DomainListSecurityScanningReq, - DomainModelListResp, DomainReportReq, GetListSecurityScanningDetailParams, + GithubComChaitinMonkeyCodeBackendDomainModelListResp, WebResp, } from "./types"; @@ -130,7 +130,7 @@ export const getHealth = (params: RequestParams = {}) => * @summary 模型列表 * @request GET:/v1/models * @response `200` `(WebResp & { - data?: DomainModelListResp, + data?: GithubComChaitinMonkeyCodeBackendDomainModelListResp, })` OK */ @@ -138,7 +138,7 @@ export const getHealth = (params: RequestParams = {}) => export const getModelList = (params: RequestParams = {}) => request< WebResp & { - data?: DomainModelListResp; + data?: GithubComChaitinMonkeyCodeBackendDomainModelListResp; } >({ path: `/v1/models`, diff --git a/ui/src/api/types.ts b/ui/src/api/types.ts index 0ed2cee..69327a7 100644 --- a/ui/src/api/types.ts +++ b/ui/src/api/types.ts @@ -10,6 +10,35 @@ * --------------------------------------------------------------- */ +export enum GithubComChaitinMonkeyCodeBackendConstsModelType { + ModelTypeLLM = "llm", + ModelTypeCoder = "coder", + ModelTypeEmbedding = "embedding", + ModelTypeAudio = "audio", + ModelTypeReranker = "reranker", +} + +export enum GithubComChaitinMonkeyCodeBackendConstsModelStatus { + ModelStatusActive = "active", + ModelStatusInactive = "inactive", +} + +export enum GithubComChaitinMonkeyCodeBackendConstsModelProvider { + ModelProviderSiliconFlow = "SiliconFlow", + ModelProviderOpenAI = "OpenAI", + ModelProviderOllama = "Ollama", + ModelProviderDeepSeek = "DeepSeek", + ModelProviderMoonshot = "Moonshot", + ModelProviderAzureOpenAI = "AzureOpenAI", + ModelProviderBaiZhiCloud = "BaiZhiCloud", + ModelProviderHunyuan = "Hunyuan", + ModelProviderBaiLian = "BaiLian", + ModelProviderVolcengine = "Volcengine", + ModelProviderZhiPu = "ZhiPu", + ModelProviderGemini = "Gemini", + ModelProviderOther = "Other", +} + export enum DomainLicenseEdition { LicenseEditionFree = 0, LicenseEditionContributor = 1, @@ -97,30 +126,11 @@ export enum ConstsReportAction { ReportActionAbortTask = "abort_task", } -export enum ConstsModelType { - ModelTypeLLM = "llm", - ModelTypeCoder = "coder", - ModelTypeEmbedding = "embedding", - ModelTypeAudio = "audio", - ModelTypeReranker = "reranker", -} - -export enum ConstsModelStatus { - ModelStatusActive = "active", - ModelStatusInactive = "inactive", -} - -export enum ConstsModelProvider { - ModelProviderSiliconFlow = "SiliconFlow", - ModelProviderOpenAI = "OpenAI", - ModelProviderOllama = "Ollama", - ModelProviderDeepSeek = "DeepSeek", - ModelProviderMoonshot = "Moonshot", - ModelProviderAzureOpenAI = "AzureOpenAI", - ModelProviderBaiZhiCloud = "BaiZhiCloud", - ModelProviderHunyuan = "Hunyuan", - ModelProviderBaiLian = "BaiLian", - ModelProviderVolcengine = "Volcengine", +export enum ConstsRepoPlatform { + RepoPlatformGitHub = "GitHub", + RepoPlatformGitLab = "GitLab", + RepoPlatformGitee = "Gitee", + RepoPlatformGitea = "Gitea", } export enum ConstsLoginSource { @@ -139,6 +149,31 @@ export enum ConstsAdminStatus { AdminStatusInactive = "inactive", } +export enum ConstsAIEmployeePosition { + AIEmployeePositionEngineer = "研发工程师", + AIEmployeePositionProductManager = "产品经理", + AIEmployeePositionTester = "测试工程师", +} + +export interface DomainAIEmployee { + admin?: DomainAdminUser; + created_at?: number; + id?: string; + /** 是否在issue评论中@工程师 */ + issue_at_comment?: boolean; + /** 是否处理新Issues */ + issue_open?: boolean; + /** 是否mr/pr在评论中@工程师 */ + mr_pr_at_comment?: boolean; + /** 是否处理全部新增PR/MR */ + mr_pr_open?: boolean; + name?: string; + platform?: ConstsRepoPlatform; + position?: ConstsAIEmployeePosition; + repository_url?: string; + token?: string; +} + export interface DomainAcceptCompletionReq { /** 补全内容 */ completion?: string; @@ -240,20 +275,6 @@ export interface DomainChatRecord { work_mode?: string; } -export interface DomainCheckModelReq { - /** 接口地址 */ - api_base: string; - api_header?: string; - /** 接口密钥 */ - api_key?: string; - api_version?: string; - /** 模型名称 */ - model_name: string; - /** 提供商 */ - provider: ConstsModelProvider; - type: "llm" | "coder" | "embedding" | "rerank"; -} - export interface DomainCodeSnippet { /** 结构化信息 */ definition?: Record; @@ -366,6 +387,22 @@ export interface DomainCompletionRecord { user?: DomainUser; } +export interface DomainCreateAIEmployeeReq { + /** 是否在issue评论中@工程师 */ + issue_at_comment?: boolean; + /** 是否处理新Issues */ + issue_open?: boolean; + /** 是否mr/pr在评论中@工程师 */ + mr_pr_at_comment?: boolean; + /** 是否处理全部新增PR/MR */ + mr_pr_open?: boolean; + name?: string; + platform?: ConstsRepoPlatform; + position?: ConstsAIEmployeePosition; + repo_url?: string; + token?: string; +} + export interface DomainCreateAdminReq { /** 密码 */ password: string; @@ -385,7 +422,7 @@ export interface DomainCreateModelReq { /** 模型名称 如: deepseek-v3 */ model_name: string; /** 模型类型 llm:对话模型 coder:代码模型 */ - model_type?: ConstsModelType; + model_type?: GithubComChaitinMonkeyCodeBackendConstsModelType; /** 高级参数 */ param?: DomainModelParam; /** 提供商 */ @@ -400,6 +437,8 @@ export interface DomainCreateModelReq { | "Hunyuan" | "BaiLian" | "Volcengine" + | "ZhiPu" + | "Gemini" | "Other"; /** 模型显示名称 */ show_name?: string; @@ -616,6 +655,13 @@ export interface DomainLicenseResp { state?: number; } +export interface DomainListAIEmployeeResp { + has_next_page?: boolean; + items?: DomainAIEmployee[]; + next_token?: string; + total_count?: number; +} + export interface DomainListAdminLoginHistoryResp { has_next_page?: boolean; login_histories?: DomainAdminLoginHistory[]; @@ -670,11 +716,19 @@ export interface DomainListSecurityScanningReq { author?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; /** 项目名称 */ project_name?: string; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } @@ -749,17 +803,17 @@ export interface DomainModel { /** 模型名称 如: deepseek-v3 */ model_name?: string; /** 模型类型 llm:对话模型 coder:代码模型 */ - model_type?: ConstsModelType; + model_type?: GithubComChaitinMonkeyCodeBackendConstsModelType; /** 输出token数 */ output?: number; /** 高级参数 */ param?: DomainModelParam; /** 提供商 */ - provider?: ConstsModelProvider; + provider?: GithubComChaitinMonkeyCodeBackendConstsModelProvider; /** 模型显示名称 */ show_name?: string; /** 状态 active:启用 inactive:禁用 */ - status?: ConstsModelStatus; + status?: GithubComChaitinMonkeyCodeBackendConstsModelStatus; /** 更新时间 */ updated_at?: number; } @@ -781,6 +835,8 @@ export interface DomainModelBasic { | "Hunyuan" | "BaiLian" | "Volcengine" + | "ZhiPu" + | "Gemini" | "Other"; } @@ -796,11 +852,6 @@ export interface DomainModelData { type?: string; } -export interface DomainModelListResp { - data?: DomainModelData[]; - object?: string; -} - export interface DomainModelParam { context_window?: number; max_tokens?: number; @@ -1057,6 +1108,27 @@ export interface DomainTimeStat { total_users?: number; } +export interface DomainUUIDReq { + id?: string; +} + +export interface DomainUpdateAIEmployeeReq { + id?: string; + /** 是否在issue评论中@工程师 */ + issue_at_comment?: boolean; + /** 是否处理新Issues */ + issue_open?: boolean; + /** 是否mr/pr在评论中@工程师 */ + mr_pr_at_comment?: boolean; + /** 是否处理全部新增PR/MR */ + mr_pr_open?: boolean; + name?: string; + platform?: ConstsRepoPlatform; + position?: ConstsAIEmployeePosition; + repo_url?: string; + token?: string; +} + export interface DomainUpdateModelReq { /** 接口地址 如:https://api.qwen.com */ api_base?: string; @@ -1082,11 +1154,13 @@ export interface DomainUpdateModelReq { | "Hunyuan" | "BaiLian" | "Volcengine" + | "ZhiPu" + | "Gemini" | "Other"; /** 模型显示名称 */ show_name?: string; /** 状态 active:启用 inactive:禁用 */ - status?: ConstsModelStatus; + status?: GithubComChaitinMonkeyCodeBackendConstsModelStatus; } export interface DomainUpdateSettingReq { @@ -1274,6 +1348,25 @@ export interface DomainWorkspaceFile { workspace_id?: string; } +export interface GithubComChaitinMonkeyCodeBackendDomainCheckModelReq { + /** 接口地址 */ + api_base: string; + api_header?: string; + /** 接口密钥 */ + api_key?: string; + api_version?: string; + /** 模型名称 */ + model_name: string; + /** 提供商 */ + provider: GithubComChaitinMonkeyCodeBackendConstsModelProvider; + type: "llm" | "coder" | "embedding" | "rerank"; +} + +export interface GithubComChaitinMonkeyCodeBackendDomainModelListResp { + data?: DomainModelData[]; + object?: string; +} + export interface TypesPosition { col?: number; line?: number; @@ -1323,27 +1416,51 @@ export interface DeleteDeleteAdminParams { export interface GetListAdminUserParams { /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } export interface GetAdminLoginHistoryParams { /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } export interface GetListUserGroupParams { /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } @@ -1352,6 +1469,27 @@ export interface DeleteDeleteGroupParams { id: string; } +export interface GetAiemployeeListParams { + /** 下一页标识 */ + next_token?: string; + /** + * 分页 + * @min 1 + * @default 1 + */ + page?: number; + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ + size?: number; +} + +export interface GetAiemployeeInfoParams { + id?: string; +} + export interface GetChatInfoParams { /** 对话记录ID */ id: string; @@ -1366,9 +1504,17 @@ export interface GetListChatRecordParams { language?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; /** 工作模式 */ work_mode?: string; @@ -1388,9 +1534,17 @@ export interface GetListCompletionRecordParams { language?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; /** 工作模式 */ work_mode?: string; @@ -1532,7 +1686,10 @@ export interface GetGetProviderModelListParams { | "BaiZhiCloud" | "Hunyuan" | "BaiLian" - | "Volcengine"; + | "Volcengine" + | "ZhiPu" + | "Gemini" + | "Other"; type: "llm" | "coder" | "embedding" | "audio" | "reranker"; } @@ -1546,11 +1703,19 @@ export interface GetSecurityScanningListParams { author?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; /** 项目名称 */ project_name?: string; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } @@ -1573,9 +1738,17 @@ export interface GetUserListChatRecordParams { language?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; /** 工作模式 */ work_mode?: string; @@ -1595,9 +1768,17 @@ export interface GetUserListCompletionRecordParams { language?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; /** 工作模式 */ work_mode?: string; @@ -1645,18 +1826,34 @@ export interface DeleteDeleteUserParams { export interface GetListUserParams { /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } export interface GetLoginHistoryParams { /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } @@ -1686,11 +1883,19 @@ export interface GetUserSecurityScanningListParams { author?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; /** 项目名称 */ project_name?: string; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } @@ -1704,11 +1909,19 @@ export interface GetListWorkspaceFilesParams { language?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; /** 搜索关键词(文件路径) */ search?: string; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; /** 用户ID */ user_id?: string; @@ -1730,8 +1943,16 @@ export interface GetListSecurityScanningDetailParams { id?: string; /** 下一页标识 */ next_token?: string; - /** 分页 */ + /** + * 分页 + * @min 1 + * @default 1 + */ page?: number; - /** 每页多少条记录 */ + /** + * 每页多少条记录 + * @min 1 + * @default 10 + */ size?: number; } diff --git a/ui/src/assets/fonts/iconfont.js b/ui/src/assets/fonts/iconfont.js index 8c442a5..649f931 100644 --- a/ui/src/assets/fonts/iconfont.js +++ b/ui/src/assets/fonts/iconfont.js @@ -1 +1 @@ -window._iconfont_svg_string_4940939='',(l=>{var a=(c=(c=document.getElementsByTagName("script"))[c.length-1]).getAttribute("data-injectcss"),c=c.getAttribute("data-disable-injectsvg");if(!c){var h,t,i,o,m,e=function(a,c){c.parentNode.insertBefore(a,c)};if(a&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}h=function(){var a,c=document.createElement("div");c.innerHTML=l._iconfont_svg_string_4940939,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(a=document.body).firstChild?e(c,a.firstChild):a.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(h,0):(t=function(){document.removeEventListener("DOMContentLoaded",t,!1),h()},document.addEventListener("DOMContentLoaded",t,!1)):document.attachEvent&&(i=h,o=l.document,m=!1,s(),o.onreadystatechange=function(){"complete"==o.readyState&&(o.onreadystatechange=null,d())})}function d(){m||(m=!0,i())}function s(){try{o.documentElement.doScroll("left")}catch(a){return void setTimeout(s,50)}d()}})(window); \ No newline at end of file +window._iconfont_svg_string_4940939='',(l=>{var a=(c=(c=document.getElementsByTagName("script"))[c.length-1]).getAttribute("data-injectcss"),c=c.getAttribute("data-disable-injectsvg");if(!c){var h,t,i,o,m,z=function(a,c){c.parentNode.insertBefore(a,c)};if(a&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}h=function(){var a,c=document.createElement("div");c.innerHTML=l._iconfont_svg_string_4940939,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(a=document.body).firstChild?z(c,a.firstChild):a.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(h,0):(t=function(){document.removeEventListener("DOMContentLoaded",t,!1),h()},document.addEventListener("DOMContentLoaded",t,!1)):document.attachEvent&&(i=h,o=l.document,m=!1,p(),o.onreadystatechange=function(){"complete"==o.readyState&&(o.onreadystatechange=null,d())})}function d(){m||(m=!0,i())}function p(){try{o.documentElement.doScroll("left")}catch(a){return void setTimeout(p,50)}d()}})(window); \ No newline at end of file diff --git a/ui/src/pages/model/components/modelCard.tsx b/ui/src/pages/model/components/modelCard.tsx index d556ea5..0137ee7 100644 --- a/ui/src/pages/model/components/modelCard.tsx +++ b/ui/src/pages/model/components/modelCard.tsx @@ -4,14 +4,13 @@ import { deleteDeleteModel, putUpdateModel, } from '@/api/Model'; -import { DomainModel, ConstsModelStatus, ConstsModelType, } from '@/api/types'; -import { Stack, Box, Button, Grid2 as Grid, ButtonBase, ThemeProvider } from '@mui/material'; +import { DomainModel, GithubComChaitinMonkeyCodeBackendConstsModelStatus, GithubComChaitinMonkeyCodeBackendConstsModelType, } from '@/api/types'; +import { Stack, Box, Button, Grid2 as Grid, ButtonBase } from '@mui/material'; import StyledLabel from '@/components/label'; import { Icon, Modal, message } from '@c-x/ui'; import { addCommasToNumber } from '@/utils'; import NoData from '@/assets/images/nodata.png'; -import { ModelProvider } from '../constant'; -import { ModelModal, Model} from '@yokowu/modelkit-ui'; +import { ModelModal, Model, DEFAULT_MODEL_PROVIDERS} from '@yokowu/modelkit-ui'; import { localModelToModelKitModel, modelService } from '@/pages/model/components/services/modelService'; const ModelItem = ({ @@ -42,7 +41,7 @@ const ModelItem = ({ onOk: () => { putUpdateModel({ id: data.id, - status: ConstsModelStatus.ModelStatusInactive, + status: GithubComChaitinMonkeyCodeBackendConstsModelStatus.ModelStatusInactive, provider: data.provider!, }).then(() => { message.success('停用成功'); @@ -92,7 +91,7 @@ const ModelItem = ({ onOk: () => { putUpdateModel({ id: data.id, - status: ConstsModelStatus.ModelStatusActive, + status: GithubComChaitinMonkeyCodeBackendConstsModelStatus.ModelStatusActive, provider: data.provider!, }).then(() => { message.success('激活成功'); @@ -128,7 +127,7 @@ const ModelItem = ({ @@ -267,7 +266,7 @@ const ModelItem = ({ interface IModelCardProps { title: string; - modelType: ConstsModelType; + modelType: GithubComChaitinMonkeyCodeBackendConstsModelType; data: DomainModel[]; refreshModel: () => void; } diff --git a/ui/src/pages/model/components/services/modelService.ts b/ui/src/pages/model/components/services/modelService.ts index a100e6a..1345526 100644 --- a/ui/src/pages/model/components/services/modelService.ts +++ b/ui/src/pages/model/components/services/modelService.ts @@ -10,14 +10,13 @@ import type { import { DomainCreateModelReq as LocalCreateModelData, DomainUpdateModelReq as LocalUpdateModelData, - DomainCheckModelReq as LocalCheckModelData, + GithubComChaitinMonkeyCodeBackendDomainCheckModelReq as LocalCheckModelData, GetGetProviderModelListParams as LocalGetModelNameData, - ConstsModelType, - ConstsModelStatus, - ConstsModelProvider, + GithubComChaitinMonkeyCodeBackendConstsModelType, + GithubComChaitinMonkeyCodeBackendConstsModelStatus, + GithubComChaitinMonkeyCodeBackendConstsModelProvider, DomainModel, } from '@/api/types'; -import { ModelProvider } from '../../constant'; import { getGetProviderModelList, postCheckModel, postCreateModel, putUpdateModel } from '@/api/Model'; const localModelToModelKitModel = ( @@ -26,15 +25,15 @@ const localModelToModelKitModel = ( return { id: localModel.id || '', model_name: localModel.model_name || '', - provider: localModel.provider as ConstsModelProvider, - model_type: localModel.model_type as ConstsModelType, + provider: localModel.provider as GithubComChaitinMonkeyCodeBackendConstsModelProvider, + model_type: localModel.model_type as GithubComChaitinMonkeyCodeBackendConstsModelType, base_url: localModel.api_base || '', api_key: localModel.api_key || '', api_header: localModel.api_header || '', api_version: localModel.api_version || '', param: localModel.param || undefined, show_name: localModel.show_name || '', - status: localModel.status as ConstsModelStatus | undefined, + status: localModel.status as GithubComChaitinMonkeyCodeBackendConstsModelStatus | undefined, created_at: localModel.created_at || 0, updated_at: localModel.updated_at || 0, input: localModel.input || 0, @@ -46,10 +45,10 @@ const localModelToModelKitModel = ( const modelkitModelTypeToLocal = ( modelType: string, -): ConstsModelType => { - if (modelType === 'coder') return ConstsModelType.ModelTypeCoder; - if (modelType === 'code') return ConstsModelType.ModelTypeCoder; - return ConstsModelType.ModelTypeLLM; +): GithubComChaitinMonkeyCodeBackendConstsModelType => { + if (modelType === 'coder') return GithubComChaitinMonkeyCodeBackendConstsModelType.ModelTypeCoder; + if (modelType === 'code') return GithubComChaitinMonkeyCodeBackendConstsModelType.ModelTypeCoder; + return GithubComChaitinMonkeyCodeBackendConstsModelType.ModelTypeLLM; }; const modelkitModelTypeToLocalString = ( @@ -70,7 +69,7 @@ const convertUICreateToLocalCreate = ( ): LocalCreateModelData => { return { model_name: uiModel.model_name || '', - provider: uiModel.provider as keyof typeof ModelProvider, + provider: uiModel.provider as GithubComChaitinMonkeyCodeBackendConstsModelProvider, model_type: modelkitModelTypeToLocal(uiModel.model_type || ''), api_base: uiModel.base_url || '', api_key: uiModel.api_key || '', @@ -87,14 +86,14 @@ const convertUIUpdateToLocalUpdate = ( return { id: uiModel.id || '', model_name: uiModel.model_name || '', - provider: uiModel.provider as keyof typeof ModelProvider, + provider: uiModel.provider as GithubComChaitinMonkeyCodeBackendConstsModelProvider, api_base: uiModel.base_url || '', api_key: uiModel.api_key || '', api_header: uiModel.api_header || '', api_version: uiModel.api_version || '', param: uiModel.param || undefined, show_name: uiModel.show_name || '', - status: uiModel.status as ConstsModelStatus | undefined, + status: uiModel.status as GithubComChaitinMonkeyCodeBackendConstsModelStatus | undefined, }; }; @@ -104,7 +103,7 @@ const convertUICheckToLocalCheck = ( ): LocalCheckModelData => { return { model_name: uiCheck.model_name || '', - provider: uiCheck.provider as ConstsModelProvider, + provider: uiCheck.provider as GithubComChaitinMonkeyCodeBackendConstsModelProvider, type: modelkitModelTypeToLocalString(uiCheck.model_type || ''), api_base: uiCheck.base_url || '', api_key: uiCheck.api_key || '', @@ -118,7 +117,7 @@ const convertUIGetModelNameToLocal = ( uiData: UIGetModelNameData, ): LocalGetModelNameData => { return { - provider: uiData.provider as ConstsModelProvider, + provider: uiData.provider as GithubComChaitinMonkeyCodeBackendConstsModelProvider, type: modelkitModelTypeToLocal(uiData.model_type || ''), base_url: uiData.base_url || '', api_key: uiData.api_key || '', diff --git a/ui/src/pages/model/constant.ts b/ui/src/pages/model/constant.ts deleted file mode 100644 index 37f1b9a..0000000 --- a/ui/src/pages/model/constant.ts +++ /dev/null @@ -1,114 +0,0 @@ -export const ModelProvider = { - BaiZhiCloud: { - label: 'BaiZhiCloud', - cn: '百智云', - icon: 'icon-baizhiyunlogo', - urlWrite: false, - secretRequired: true, - customHeader: false, - modelDocumentUrl: 'https://model-square.app.baizhi.cloud/token', - defaultBaseUrl: 'https://model-square.app.baizhi.cloud/v1', - }, - DeepSeek: { - label: 'DeepSeek', - cn: '', - icon: 'icon-deepseek', - urlWrite: false, - secretRequired: true, - customHeader: false, - modelDocumentUrl: 'https://platform.deepseek.com/api_keys', - defaultBaseUrl: 'https://api.deepseek.com/v1', - }, - Hunyuan: { - label: 'Hunyuan', - cn: '腾讯混元', - icon: 'icon-tengxunhunyuan', - urlWrite: false, - secretRequired: true, - customHeader: false, - modelDocumentUrl: 'https://console.cloud.tencent.com/hunyuan/start', - defaultBaseUrl: 'https://api.hunyuan.cloud.tencent.com/v1', - }, - BaiLian: { - label: 'BaiLian', - cn: '阿里云百炼', - icon: 'icon-aliyunbailian', - urlWrite: false, - secretRequired: true, - customHeader: false, - modelDocumentUrl: 'https://bailian.console.aliyun.com/?tab=model#/api-key', - defaultBaseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1', - }, - Volcengine: { - label: 'Volcengine', - cn: '火山引擎', - icon: 'icon-huoshanyinqing', - urlWrite: false, - secretRequired: true, - customHeader: false, - modelDocumentUrl: - 'https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey', - defaultBaseUrl: 'https://ark.cn-beijing.volces.com/api/v3', - }, - OpenAI: { - label: 'OpenAI', - cn: '', - icon: 'icon-chatgpt', - urlWrite: false, - secretRequired: true, - customHeader: false, - modelDocumentUrl: 'https://platform.openai.com/api-keys', - defaultBaseUrl: 'https://api.openai.com/v1', - }, - Ollama: { - label: 'Ollama', - cn: '', - icon: 'icon-ollama', - urlWrite: true, - secretRequired: false, - customHeader: true, - modelDocumentUrl: '', - defaultBaseUrl: 'http://127.0.0.1:11434/v1', - }, - SiliconFlow: { - label: 'SiliconFlow', - cn: '硅基流动', - icon: 'icon-a-ziyuan2', - urlWrite: false, - secretRequired: true, - customHeader: false, - modelDocumentUrl: 'https://cloud.siliconflow.cn/account/ak', - defaultBaseUrl: 'https://api.siliconflow.cn/v1', - }, - Moonshot: { - label: 'Moonshot', - cn: '月之暗面', - icon: 'icon-Kim', - urlWrite: false, - secretRequired: true, - customHeader: false, - modelDocumentUrl: 'https://platform.moonshot.cn/console/api-keys', - defaultBaseUrl: 'https://api.moonshot.cn/v1', - }, - AzureOpenAI: { - label: 'AzureOpenAI', - cn: 'Azure OpenAI', - icon: 'icon-azure', - urlWrite: true, - secretRequired: true, - customHeader: false, - modelDocumentUrl: - 'https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI', - defaultBaseUrl: 'https://.openai.azure.com', - }, - Other: { - label: 'Other', - cn: '其他', - icon: 'icon-a-AIshezhi', - urlWrite: true, - secretRequired: true, - customHeader: false, - modelDocumentUrl: '', - defaultBaseUrl: '', - }, -}; diff --git a/ui/src/pages/model/index.tsx b/ui/src/pages/model/index.tsx index a8a771f..13862f9 100644 --- a/ui/src/pages/model/index.tsx +++ b/ui/src/pages/model/index.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react'; import TokenUsage from './components/tokenUsage'; import ModelCard from './components/modelCard'; import { Stack } from '@mui/material'; -import { ConstsModelType } from '@/api/types'; +import { GithubComChaitinMonkeyCodeBackendConstsModelType } from '@/api/types'; import { useCommonContext } from '@/hooks/context'; import { Modal } from '@c-x/ui'; @@ -43,13 +43,13 @@ const Model = () => { title='对话模型' data={llmModel} refreshModel={refreshModel} - modelType={ConstsModelType.ModelTypeLLM} + modelType={GithubComChaitinMonkeyCodeBackendConstsModelType.ModelTypeLLM} /> );