diff --git a/config/config.ts b/config/config.ts index d0a82b8e..be103b95 100644 --- a/config/config.ts +++ b/config/config.ts @@ -1,9 +1,13 @@ import { defineConfig } from '@umijs/max'; -import theme from './theme'; -const CompressionWebpackPlugin = require('compression-webpack-plugin'); - import proxy from './proxy'; import routes from './routes'; +import theme from './theme'; +import { getBranchInfo } from './utils'; +const CompressionWebpackPlugin = require('compression-webpack-plugin'); + +const versionInfo = getBranchInfo(); +process.env.VERSION = JSON.stringify(versionInfo); + const env = process.env.NODE_ENV; const isProduction = env === 'production'; @@ -15,6 +19,7 @@ export default defineConfig({ history: { type: 'hash' }, + base: process.env.npm_config_base || '/', ...(isProduction ? { diff --git a/config/proxy.ts b/config/proxy.ts index 410b2205..1ffe62db 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -1,16 +1,16 @@ -const proxyTableList = ['cli', 'v1', 'auth', 'v1-openai']; +const proxyTableList = ['cli', 'v1', 'auth', 'v1-openai', 'version']; // @ts-ingore export default function createProxyTable(target?: string) { const proxyTable = proxyTableList.reduce( (obj: Record, api) => { const newTarget = target || 'http://localhost'; - obj[`/${api}/`] = { + obj[`/${api}`] = { target: newTarget, changeOrigin: true, secure: false, ws: true, - pathRewrite: (pth: string) => pth.replace(`/^/${api}/`, `/${api}`), + pathRewrite: (pth: string) => pth.replace(`/^/${api}`, `/${api}`), // onProxyRes: (proxyRes: any, req: any, res: any) => { // if (req.headers.accept === 'text/event-stream') { // res.writeHead(res.statusCode, { diff --git a/config/utils.ts b/config/utils.ts index 0f7147f1..3fce5dd3 100644 --- a/config/utils.ts +++ b/config/utils.ts @@ -9,5 +9,5 @@ export const getBranchInfo = () => { .execSync(`git tag --contains ${latestCommit}`) .toString() .trim(); - return { version: versionTag, commitId: latestCommit }; + return { version: versionTag || 'dev', commitId: latestCommit.slice(0, 7) }; }; diff --git a/plugin.ts b/plugin.ts index b1803031..8cfd507b 100644 --- a/plugin.ts +++ b/plugin.ts @@ -2,24 +2,15 @@ import { IApi } from '@umijs/max'; export default (api: IApi) => { api.modifyHTML(($) => { - console.log('pllugins=========modifyHTML', $); + const info = JSON.parse(process.env.VERSION || '{}'); + const env = process.env.NODE_ENV; + $('html').attr( + 'data-version', + env === 'production' ? info.version : `${info.version}-${info.commitId}` + ); return $; }); api.onStart(() => { - console.log('pllugins=========start'); + console.log('start'); }); - - // api.modifyConfig((memo: any) => { - // // some beautiful code - // console.log('pllugins=========memo', memo); - // return memo; - // }); - // api.addLayouts(() => { - // return [ - // { - // id: 'layout', - // file: require.resolve('./src/global-layouts/index.tsx') - // } - // ]; - // }); }; diff --git a/src/app.tsx b/src/app.tsx index 72853696..4a87bd6b 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,6 +1,11 @@ +import { GPUStackVersionAtom } from '@/atoms/user'; +import { setAtomStorage } from '@/atoms/utils'; import { RequestConfig, history } from '@umijs/max'; import { requestConfig } from './request-config'; -import { queryCurrentUserState } from './services/profile/apis'; +import { + queryCurrentUserState, + queryVersionInfo +} from './services/profile/apis'; const loginPath = '/login'; let currentUserInfo: any = {}; @@ -28,6 +33,18 @@ export async function getInitialState(): Promise<{ return {} as Global.UserInfo; }; + const getAppVersionInfo = async () => { + try { + const data = await queryVersionInfo(); + console.log('versioninfo=========', data); + setAtomStorage(GPUStackVersionAtom, data); + } catch (error) { + console.error('queryVersionInfo error', error); + } + }; + + getAppVersionInfo(); + if (![loginPath].includes(location.pathname)) { const userInfo = await fetchUserInfo(); currentUserInfo = { @@ -43,6 +60,8 @@ export async function getInitialState(): Promise<{ }; } +console.log('app.tsx'); + export const request: RequestConfig = { baseURL: ' /v1', ...requestConfig diff --git a/src/atoms/user.ts b/src/atoms/user.ts index 97166f54..7e9ff7be 100644 --- a/src/atoms/user.ts +++ b/src/atoms/user.ts @@ -1,7 +1,16 @@ +import { atom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; export const userAtom = atomWithStorage('userInfo', null); +export const GPUStackVersionAtom = atom<{ + version: string; + git_commit: string; +}>({ + version: '', + git_commit: '' +}); + export const initialPasswordAtom = atomWithStorage( 'initialPassword', '' diff --git a/src/atoms/utils/index.ts b/src/atoms/utils/index.ts index 1482f180..eca8f713 100644 --- a/src/atoms/utils/index.ts +++ b/src/atoms/utils/index.ts @@ -8,7 +8,14 @@ export const clearAtomStorage = (atom: any) => { store.set(atom, null); }; -export const getAtomStorage = (atom: any) => { +export const setAtomStorage = (atom: any, value: any) => { + if (!atom) { + return; + } + const store = getDefaultStore(); + store.set(atom, value); +}; +export const getAtomStorage = (atom: any): any => { if (!atom) { return null; } diff --git a/src/components/copy-button/index.tsx b/src/components/copy-button/index.tsx index bfeade4a..26cb9e8f 100644 --- a/src/components/copy-button/index.tsx +++ b/src/components/copy-button/index.tsx @@ -5,14 +5,20 @@ import { Button } from 'antd'; type CopyButtonProps = { text: string; disabled?: boolean; + fontSize?: string; type?: 'text' | 'primary' | 'dashed' | 'link' | 'default'; size?: 'small' | 'middle' | 'large'; + shape?: 'circle' | 'round' | 'default'; + style?: React.CSSProperties; }; const CopyButton: React.FC = ({ text, disabled, type = 'text', + shape = 'circle', + fontSize = '14px', + style, size = 'middle' }) => { const { copied, copyToClipboard } = useCopyToClipboard(); @@ -24,21 +30,20 @@ const CopyButton: React.FC = ({ return ( + icon={ + copied ? ( + + ) : ( + + ) + } + > ); }; diff --git a/src/components/editor-wrap/index.tsx b/src/components/editor-wrap/index.tsx index fc7e178e..80ae3c05 100644 --- a/src/components/editor-wrap/index.tsx +++ b/src/components/editor-wrap/index.tsx @@ -22,7 +22,7 @@ const EditorWrap: React.FC = ({ showHeader = true }) => { const handleChangeLang = (value: string) => { - onChangeLang && onChangeLang(value); + onChangeLang?.(value); }; const renderHeader = () => { if (header) { @@ -39,7 +39,13 @@ const EditorWrap: React.FC = ({ options={langOptions} onChange={handleChangeLang} > - + ); } diff --git a/src/components/footer/index.less b/src/components/footer/index.less index 50246350..a1d30e55 100644 --- a/src/components/footer/index.less +++ b/src/components/footer/index.less @@ -7,4 +7,10 @@ text-align: center; font-size: var(--font-size-middle); color: var(--color-text-2); + + .footer-content-left-text { + display: flex; + justify-content: center; + align-items: center; + } } diff --git a/src/components/footer/index.tsx b/src/components/footer/index.tsx index d2b04233..b2a74ea1 100644 --- a/src/components/footer/index.tsx +++ b/src/components/footer/index.tsx @@ -1,9 +1,23 @@ +import { GPUStackVersionAtom } from '@/atoms/user'; +import { getAtomStorage } from '@/atoms/utils'; +import VersionInfo from '@/components/version-info'; +import externalLinks from '@/config/external-links'; import { useIntl } from '@umijs/max'; -import { Space } from 'antd'; +import { Button, Modal, Space } from 'antd'; import './index.less'; const Footer: React.FC = () => { const intl = useIntl(); + + const showVersion = () => { + Modal.info({ + icon: null, + centered: false, + width: 500, + content: + }); + }; + return (
@@ -14,6 +28,19 @@ const Footer: React.FC = () => { {new Date().getFullYear()} {intl.formatMessage({ id: 'settings.company' })} + + + +
diff --git a/src/components/status-tag/index.tsx b/src/components/status-tag/index.tsx index f38356b4..a16c88c4 100644 --- a/src/components/status-tag/index.tsx +++ b/src/components/status-tag/index.tsx @@ -20,12 +20,17 @@ type StatusTagProps = { text: string; message?: string; }; + type?: 'tag' | 'circle'; download?: { percent: number; }; }; -const StatusTag: React.FC = ({ statusValue, download }) => { +const StatusTag: React.FC = ({ + statusValue, + download, + type = 'tag' +}) => { const { text, status } = statusValue; const [statusColor, setStatusColor] = useState<{ text: string; diff --git a/src/components/version-info/index.less b/src/components/version-info/index.less new file mode 100644 index 00000000..58b1a58d --- /dev/null +++ b/src/components/version-info/index.less @@ -0,0 +1,41 @@ +.version-box { + display: flex; + margin-bottom: 40px; + flex-direction: column; + align-items: center; + + .img { + margin-top: 16px; + text-align: center; + height: 30px; + + img { + height: 100%; + } + } + + .title { + font-weight: var(--font-weight-medium); + text-align: center; + font-size: var(--font-size-middle); + margin-block: 30px 10px; + } + + .ver { + line-height: 32px; + display: flex; + font-size: var(--font-size-middle); + + .label { + display: flex; + justify-content: flex-start; + width: 60px; + font-size: var(--font-size-middle); + font-weight: var(--font-weight-medium); + } + + .val { + color: var(--ant-color-text-secondary); + } + } +} diff --git a/src/components/version-info/index.tsx b/src/components/version-info/index.tsx new file mode 100644 index 00000000..2d33300f --- /dev/null +++ b/src/components/version-info/index.tsx @@ -0,0 +1,39 @@ +import Logo from '@/assets/images/gpustack-logo.png'; +import { GPUStackVersionAtom } from '@/atoms/user'; +import { getAtomStorage } from '@/atoms/utils'; +import React from 'react'; +import './index.less'; + +const VersionInfo: React.FC<{ intl: any }> = ({ intl }) => { + // get the data attr from html + const version = document.documentElement.getAttribute('data-version'); + + return ( +
+
+ logo +
+
+ {intl.formatMessage({ id: 'common.footer.version.title' })} +
+
+
+ + {' '} + {intl.formatMessage({ id: 'common.footer.version.server' })} + + + {getAtomStorage(GPUStackVersionAtom)?.version || + getAtomStorage(GPUStackVersionAtom)?.git_commit} + +
+
+ UI + {version} +
+
+
+ ); +}; + +export default VersionInfo; diff --git a/src/config/external-links.ts b/src/config/external-links.ts new file mode 100644 index 00000000..93390414 --- /dev/null +++ b/src/config/external-links.ts @@ -0,0 +1,6 @@ +export default { + documentation: 'https://docs.gpustack.ai/', + github: 'https://github.com/gpustack/gpustack', + discord: 'https://discord.gg/2ZvXuaYq', + site: 'https://seal.io/' +}; diff --git a/src/config/global.d.ts b/src/config/global.d.ts index 069f2052..3de61a93 100644 --- a/src/config/global.d.ts +++ b/src/config/global.d.ts @@ -21,4 +21,6 @@ declare namespace Global { require_password_change: boolean; id: number; } + + type SearchParams = Pagination & { search?: string }; } diff --git a/src/global.tsx b/src/global.tsx index 113a2a4d..c573fc4a 100644 --- a/src/global.tsx +++ b/src/global.tsx @@ -1 +1 @@ -// 应用前置、全局运行的逻辑时 会在这里执行 \ No newline at end of file +// 应用前置、全局运行的逻辑时 会在这里执行 diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 4b8c7620..1edc2a6b 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -1,10 +1,10 @@ // @ts-nocheck import { userAtom } from '@/atoms/user'; +import VersionInfo from '@/components/version-info'; import { logout } from '@/pages/login/apis'; import { useAccessMarkedRoutes } from '@@/plugin-access'; import { useModel } from '@@/plugin-model'; - import { ProLayout } from '@ant-design/pro-components'; import { Link, @@ -17,6 +17,7 @@ import { useNavigate, type IRoute } from '@umijs/max'; +import { Modal } from 'antd'; import { useAtom } from 'jotai'; import { useMemo, useState } from 'react'; import Exception from './Exception'; @@ -102,6 +103,15 @@ export default (props: any) => { return intl.formatMessage({ id: args.id }); }; + const showVersion = () => { + Modal.info({ + icon: null, + centered: false, + width: 500, + content: + }); + }; + const runtimeConfig = { ...initialInfo, logout: async (userInfo) => { @@ -109,6 +119,9 @@ export default (props: any) => { await logout(); navigate(loginPath); }, + showVersion: () => { + return showVersion(); + }, notFound: 404 not found }; diff --git a/src/layouts/rightRender.tsx b/src/layouts/rightRender.tsx index fc433ea2..07b215f1 100644 --- a/src/layouts/rightRender.tsx +++ b/src/layouts/rightRender.tsx @@ -1,6 +1,7 @@ // @ts-nocheck import avatarImg from '@/assets/images/avatar.png'; +import externalLinks from '@/config/external-links'; import langConfigMap from '@/locales/lang-config-map'; import { DiscordOutlined, @@ -27,6 +28,7 @@ export function getRightRenderContent(opts: { intl: any; }) { const { intl, collapsed, siderWidth } = opts; + const allLocals = getAllLocales(); if (opts.runtimeConfig.rightRender) { return opts.runtimeConfig.rightRender( @@ -73,22 +75,25 @@ export function getRightRenderContent(opts: { key: 'site', icon: , label: 'GPUStack', - url: 'https://gpustack.ai/' + url: externalLinks.site }, { key: 'github', icon: , - label: 'GitHub' + label: 'GitHub', + url: externalLinks.github }, { key: 'Discord', icon: , - label: 'Discord' + label: 'Discord', + url: externalLinks.discord }, { key: 'docs', icon: , - label: intl.formatMessage({ id: 'common.button.docs' }) + label: intl.formatMessage({ id: 'common.button.docs' }), + url: externalLinks.documentation }, { key: 'version', @@ -118,11 +123,26 @@ export function getRightRenderContent(opts: { label: ( {item.icon} - - {item.label} - + {item.key === 'version' ? ( + {item.label} + ) : ( + + {item.label} + + )} - ) + ), + onClick() { + if (item.key === 'version') { + // opts.runtimeConfig.showVersion(); + opts.runtimeConfig.showVersion(); + } + } })) } ] diff --git a/src/locales/en-US/playground.ts b/src/locales/en-US/playground.ts index 86272554..f2e6879a 100644 --- a/src/locales/en-US/playground.ts +++ b/src/locales/en-US/playground.ts @@ -22,7 +22,7 @@ export default { 'playground.params.topp.tips': 'Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered.', 'playground.params.seed.tips': - 'Specify a random seed to ensure deterministic sampling. Using the same seed and parameters will produce the same results for repeated requests.', + 'If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.', 'playground.params.stop.tips': 'A stop sequence is a predefined or user-specified text string that signals the AI to stop generating further tokens when these sequences appear.' }; diff --git a/src/locales/zh-CN/playground.ts b/src/locales/zh-CN/playground.ts index 89c21943..b4792c6e 100644 --- a/src/locales/zh-CN/playground.ts +++ b/src/locales/zh-CN/playground.ts @@ -20,9 +20,9 @@ export default { 'playground.params.maxtokens.tips': '生成的最大 token 数。输入标记和生成的标记的总长度受模型上下文长度的限制。', 'playground.params.topp.tips': - '通过核采样控制多样性:0.5 表示考虑所有基于概率权重选项的一半。', + '通过核心采样控制多样性:0.5 表示考虑所有基于概率权重选项的一半。', 'playground.params.seed.tips': - '指定随机种子以确保确定性采样。使用相同的种子和参数对于重复请求将产生相同的结果。', + '如果指定,我们的系统将尽最大努力进行确定性采样,以便使用相同种子和参数的重复请求应返回相同的结果。', 'playground.params.stop.tips': '停止序列是一个预定义或用户指定的文本字符串,当这些序列出现时,它会提示 AI 停止生成后续的标记。' }; diff --git a/src/pages/api-keys/apis/index.ts b/src/pages/api-keys/apis/index.ts index 1f8ddf0c..a339b379 100644 --- a/src/pages/api-keys/apis/index.ts +++ b/src/pages/api-keys/apis/index.ts @@ -3,9 +3,7 @@ import { FormData, ListItem } from '../config/types'; export const APIS_KEYS_API = '/api-keys'; -export async function queryApisKeysList( - params: Global.Pagination & { query?: string } -) { +export async function queryApisKeysList(params: Global.SearchParams) { return request>(`${APIS_KEYS_API}`, { method: 'GET', params diff --git a/src/pages/api-keys/index.tsx b/src/pages/api-keys/index.tsx index 172e65c3..b2c1514d 100644 --- a/src/pages/api-keys/index.tsx +++ b/src/pages/api-keys/index.tsx @@ -42,7 +42,7 @@ const Models: React.FC = () => { const [queryParams, setQueryParams] = useState({ page: 1, perPage: 10, - query: '' + search: '' }); const handleShowSizeChange = (page: number, size: number) => { @@ -90,7 +90,7 @@ const Models: React.FC = () => { const handleNameChange = (e: any) => { setQueryParams({ ...queryParams, - query: e.target.value + search: e.target.value }); }; diff --git a/src/pages/llmodels/apis/index.ts b/src/pages/llmodels/apis/index.ts index 524e1c1c..6c570cad 100644 --- a/src/pages/llmodels/apis/index.ts +++ b/src/pages/llmodels/apis/index.ts @@ -13,7 +13,7 @@ export const MODEL_INSTANCE_API = '/model-instances'; // ===================== Models ===================== export async function queryModelsList( - params: Global.Pagination & { query?: string }, + params: Global.SearchParams, options?: any ) { return request>(`${MODELS_API}`, { diff --git a/src/pages/llmodels/components/instance-item.tsx b/src/pages/llmodels/components/instance-item.tsx index 4054827a..fe74fe30 100644 --- a/src/pages/llmodels/components/instance-item.tsx +++ b/src/pages/llmodels/components/instance-item.tsx @@ -1,9 +1,13 @@ import DropdownButtons from '@/components/drop-down-buttons'; import RowChildren from '@/components/seal-table/components/row-children'; import StatusTag from '@/components/status-tag'; -import { DeleteOutlined, FieldTimeOutlined } from '@ant-design/icons'; +import { + DeleteOutlined, + FieldTimeOutlined, + InfoCircleOutlined +} from '@ant-design/icons'; import { useIntl } from '@umijs/max'; -import { Col, Row, Space } from 'antd'; +import { Col, Row, Space, Tooltip } from 'antd'; import dayjs from 'dayjs'; import _ from 'lodash'; import React from 'react'; @@ -59,35 +63,44 @@ const InstanceItem: React.FC = ({ }); }; - const getWorkerIp = (item: ModelInstanceListItem) => { + const renderWorkerInfo = (item: ModelInstanceListItem) => { + let workerIp = '-'; if (item.worker_ip) { - return item.port ? `${item.worker_ip}:${item.port}` : item.worker_ip; + workerIp = item.port ? `${item.worker_ip}:${item.port}` : item.worker_ip; } - return '-'; + return ( +
+
{item.worker_name}
+
{workerIp}
+
+ ); }; return ( {_.map(list, (item: ModelInstanceListItem, index: number) => { return (
- {item.name} - {item.worker_name || '-'} - - - {item.source === 'huggingface' - ? item.huggingface_filename - : item.ollama_library_model_name} - + + + {item.name} + + - - + + {item.state && ( @@ -107,11 +120,11 @@ const InstanceItem: React.FC = ({ - + {dayjs(item.updated_at).format('YYYY-MM-DD HH:mm:ss')} - +
= ({ dataIndex="name" key="name" width={400} - span={6} + span={5} /> { - return modelSourceMap[text] || '-'; + span={6} + render={(text, record: ListItem) => { + return ( + + {record.source === modelSourceMap.huggingface_value + ? `${modelSourceMap.huggingface} / ${record.huggingface_filename}` + : `${modelSourceMap.ollama_library} / ${record.ollama_library_model_name}`} + + ); }} /> = ({ }} /> { diff --git a/src/pages/llmodels/config/index.ts b/src/pages/llmodels/config/index.ts index c7f1b7b4..9ae996ae 100644 --- a/src/pages/llmodels/config/index.ts +++ b/src/pages/llmodels/config/index.ts @@ -15,7 +15,10 @@ export const ollamaModelOptions = [ export const modelSourceMap: Record = { huggingface: 'Hugging Face', ollama_library: 'Ollama Library', - s3: 'S3' + s3: 'S3', + huggingface_value: 'huggingface', + ollama_library_value: 'ollama_library', + s3_value: 's3' }; export const InstanceStatusMap = { diff --git a/src/pages/llmodels/config/types.ts b/src/pages/llmodels/config/types.ts index 59f5eab0..ce700bb0 100644 --- a/src/pages/llmodels/config/types.ts +++ b/src/pages/llmodels/config/types.ts @@ -2,6 +2,8 @@ export interface ListItem { source: string; huggingface_repo_id: string; huggingface_file_name: string; + huggingface_filename: string; + ollama_library_model_name: string; s3Address: string; name: string; description: string; diff --git a/src/pages/llmodels/index.tsx b/src/pages/llmodels/index.tsx index 99ea8770..1d1b1a31 100644 --- a/src/pages/llmodels/index.tsx +++ b/src/pages/llmodels/index.tsx @@ -24,7 +24,7 @@ const Models: React.FC = () => { const [queryParams, setQueryParams] = useState({ page: 1, perPage: 10, - query: '' + search: '' }); // request data @@ -110,7 +110,7 @@ const Models: React.FC = () => { (e: any) => { setQueryParams({ ...queryParams, - query: e.target.value + search: e.target.value }); }, [queryParams] diff --git a/src/pages/playground/components/message-item.tsx b/src/pages/playground/components/message-item.tsx index 436ecfd3..74400d80 100644 --- a/src/pages/playground/components/message-item.tsx +++ b/src/pages/playground/components/message-item.tsx @@ -122,13 +122,16 @@ const MessageItem: React.FC<{
{message.content && ( - + )} diff --git a/src/pages/playground/components/view-code-modal.tsx b/src/pages/playground/components/view-code-modal.tsx index 6df9d379..959b5afb 100644 --- a/src/pages/playground/components/view-code-modal.tsx +++ b/src/pages/playground/components/view-code-modal.tsx @@ -66,7 +66,7 @@ const ViewCodeModal: React.FC = (props) => { const systemList = systemMessage ? [{ role: 'system', content: systemMessage }] : []; - const code = `import OpenAI from "openai";\nconst openai = new OpenAI({\n"base_url": "/v1-openai", \n "gpustack_api_key": "$\{GPUSTACK_API_KEY}"\n });\n\nasync function main(){\nconst params = ${JSON.stringify( + const code = `import OpenAI from "openai";\nconst openai = new OpenAI();\n\nasync function main(){\nconst params = ${JSON.stringify( { ...parameters, messages: [...systemList, ...messageList] @@ -92,7 +92,7 @@ const ViewCodeModal: React.FC = (props) => { const systemList = systemMessage ? [{ role: 'system', content: systemMessage }] : []; - const code = `from openai import OpenAI\nclient = OpenAI({\n "base_url": "/v1-openai", \n "gpustack_api_key": "$\{GPUSTACK_API_KEY}"\n })\n\ncompletion = client.chat.completions.create(\n${formattedParams} messages=${JSON.stringify([...systemList, ...messageList], null, 2)})\nprint(completion.choices[0].message)`; + const code = `from openai import OpenAI\nclient = OpenAI()\n\ncompletion = client.chat.completions.create(\n${formattedParams} messages=${JSON.stringify([...systemList, ...messageList], null, 2)})\nprint(completion.choices[0].message)`; setCodeValue(code); } formatCode(); diff --git a/src/pages/resources/apis/index.ts b/src/pages/resources/apis/index.ts index e939528e..15c1c5af 100644 --- a/src/pages/resources/apis/index.ts +++ b/src/pages/resources/apis/index.ts @@ -4,18 +4,14 @@ import { GPUDeviceItem, ListItem } from '../config/types'; export const WORKERS_API = '/workers'; export const GPU_DEVICES_API = '/gpu-devices'; -export async function queryWorkersList( - params: Global.Pagination & { query?: string } -) { +export async function queryWorkersList(params: Global.SearchParams) { return request>(`${WORKERS_API}`, { methos: 'GET', params }); } -export async function queryGpuDevicesList( - params: Global.Pagination & { query?: string } -) { +export async function queryGpuDevicesList(params: Global.SearchParams) { return request>(`${GPU_DEVICES_API}`, { methos: 'GET', params diff --git a/src/pages/resources/components/gpus.tsx b/src/pages/resources/components/gpus.tsx index a84930c8..1b05fc2e 100644 --- a/src/pages/resources/components/gpus.tsx +++ b/src/pages/resources/components/gpus.tsx @@ -22,7 +22,7 @@ const GPUList: React.FC = () => { const [queryParams, setQueryParams] = useState({ page: 1, perPage: 10, - query: '' + search: '' }); const handleShowSizeChange = (current: number, size: number) => { setQueryParams({ @@ -67,7 +67,7 @@ const GPUList: React.FC = () => { const handleNameChange = (e: any) => { setQueryParams({ ...queryParams, - query: e.target.value + search: e.target.value }); }; diff --git a/src/pages/resources/components/workers.tsx b/src/pages/resources/components/workers.tsx index 38a7cd61..7b7d64c0 100644 --- a/src/pages/resources/components/workers.tsx +++ b/src/pages/resources/components/workers.tsx @@ -27,7 +27,7 @@ const Resources: React.FC = () => { const [queryParams, setQueryParams] = useState({ page: 1, perPage: 10, - query: '' + search: '' }); const fetchData = async () => { @@ -73,7 +73,7 @@ const Resources: React.FC = () => { const handleNameChange = (e: any) => { setQueryParams({ ...queryParams, - query: e.target.value + search: e.target.value }); }; diff --git a/src/pages/users/apis/index.ts b/src/pages/users/apis/index.ts index 9a73ab9d..a7148ee5 100644 --- a/src/pages/users/apis/index.ts +++ b/src/pages/users/apis/index.ts @@ -3,9 +3,7 @@ import { FormData, ListItem } from '../config/types'; export const USERS_API = '/users'; -export async function queryUsersList( - params: Global.Pagination & { query?: string } -) { +export async function queryUsersList(params: Global.SearchParams) { return request>(`${USERS_API}`, { methos: 'GET', params diff --git a/src/pages/users/index.tsx b/src/pages/users/index.tsx index 559dec16..69dcb29b 100644 --- a/src/pages/users/index.tsx +++ b/src/pages/users/index.tsx @@ -43,7 +43,7 @@ const Users: React.FC = () => { const [queryParams, setQueryParams] = useState({ page: 1, perPage: 10, - query: '' + search: '' }); const ActionList = [ @@ -104,7 +104,7 @@ const Users: React.FC = () => { const handleNameChange = (e: any) => { setQueryParams({ ...queryParams, - query: e.target.value + search: e.target.value }); }; diff --git a/src/request-config.ts b/src/request-config.ts index 30f36911..186f20f7 100644 --- a/src/request-config.ts +++ b/src/request-config.ts @@ -3,7 +3,7 @@ import { clearAtomStorage } from '@/atoms/utils'; import { RequestConfig, history } from '@umijs/max'; import { message } from 'antd'; -const NoBaseURLAPIs = ['/auth', '/v1-openai']; +const NoBaseURLAPIs = ['/auth', '/v1-openai', '/version']; export const requestConfig: RequestConfig = { errorConfig: { diff --git a/src/services/profile/apis.ts b/src/services/profile/apis.ts index 1e96bf4f..494a0a76 100644 --- a/src/services/profile/apis.ts +++ b/src/services/profile/apis.ts @@ -6,3 +6,9 @@ export async function queryCurrentUserState(opts?: Record) { ...opts }); } + +export async function queryVersionInfo() { + return request(`/version`, { + method: 'GET' + }); +}