chore: test by api

This commit is contained in:
jialin
2025-10-13 14:40:26 +08:00
parent 54703c67c1
commit a5c1b8e15f
29 changed files with 683 additions and 298 deletions
+88 -26
View File
@@ -1,24 +1,47 @@
import MindIELogo from '@/assets/logo/ascend.png';
import SGLangLogo from '@/assets/logo/sglang.png';
import vLLMLogo from '@/assets/logo/vllm.png';
import icons from '@/components/icon-font/icons';
import jsYaml from 'js-yaml';
import { trim } from 'lodash';
const SealYamlType = new jsYaml.Type('!seal', {
kind: 'sequence', // See node kinds in YAML spec: http://www.yaml.org/spec/1.2/spec.html#kind//
construct(data: any) {
return data.map(function (str: string) {
return `seal${str}`;
});
}
});
const SEAL_SCHEMA = jsYaml.DEFAULT_SCHEMA.extend([SealYamlType]);
export const builtInBackends = {
SGLang: 'SGLang',
vLLM: 'vllm',
MindIE: 'mindie',
VoxBox: 'voxbox'
};
export const builtInBackendLogos: Record<string, string> = {
[builtInBackends.SGLang]: SGLangLogo,
[builtInBackends.vLLM]: vLLMLogo,
[builtInBackends.MindIE]: MindIELogo,
[builtInBackends.VoxBox]: ''
};
export const backendActions = [
{
label: 'Edit Versions',
value: 'version',
key: 'version',
icon: icons.EditContent,
locale: false
},
{
label: 'Edit Parameters',
value: 'parameter',
key: 'parameter',
icon: icons.Parameter,
locale: false
},
{
label: 'Edit by Yaml',
value: 'yaml',
label: 'Edit',
value: 'edit',
key: 'edit',
icon: icons.EditOutlined,
locale: false
},
{
label: 'Export YAML',
value: 'yaml',
key: 'export',
icon: icons.Yaml,
locale: false
},
@@ -32,20 +55,59 @@ export const backendActions = [
}
];
export const yamlTemplate = `
name: SGLang
export const json2Yaml = (obj: Record<string, any>) => {
if (!obj || !Object.keys(obj).length) return '';
const res = jsYaml.dump(JSON.parse(JSON.stringify(obj)));
return res;
};
export const yaml2Json = (input: string) => {
const str = trim(input);
const obj = jsYaml.load(str, { schema: SEAL_SCHEMA });
if (typeof obj !== 'object' || obj === null) {
return {};
}
const jsonStr = JSON.stringify(obj);
return JSON.parse(jsonStr);
};
export const customColors = [
'red',
'orange',
'gold',
'lime',
'volcano',
'green',
'magenta',
'cyan',
'purple',
'blue',
'geekblue'
];
export const customIcons = ['∑', '∏', '∫', '∂', '∞', 'θ', '∆', '∇'];
export const backendFields = [
'description',
'health_check_path',
'default_run_command',
'version_configs',
'default_backend_parameters'
];
export const yamlTemplate = `# backend configuration template
backend_name: SGLang
description: SGLang backend
default_version: v0.5.1
health_check_path: /health
allowed_proxy_uris:
- api/chat
- api/v1
versions:
default_run_command: run sglang
version_configs:
v0.0.1:
image: lm/sglang
command: run sglang
image_name: lm/sglang
run_command: run sglang
v0.0.2:
image: lm/sglang
command: run sglang
image_name: lm/sglang
run_command: run sglang
default_backend_parameters:
- --host
`;
@@ -1,42 +1,43 @@
{
"type": "object",
"properties": {
"name": {
"backend_name": {
"type": "string",
"description": "backend name",
"severity": "error"
},
"description": {
"type": ["string", "null"],
"description": "backend description"
},
"default_version": {
"type": "string",
"description": "default backend version"
},
"default_run_command": {
"type": ["string", "null"],
"description": "default start command"
},
"health_check_path": {
"type": "string",
"type": ["string", "null"],
"description": "health check path"
},
"allowed_proxy_uris": {
"type": "array",
"items": {
"type": "string"
},
"description": "allowed proxy URIs"
},
"versions": {
"version_configs": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9._-]+$": {
"type": "object",
"properties": {
"image": {
"image_name": {
"type": "string",
"description": "image name"
},
"command": {
"type": "string",
"run_command": {
"type": ["string", "null"],
"description": "start command"
}
},
"required": ["image", "command"],
"required": ["image_name", "run_command"],
"additionalProperties": false
}
},
@@ -51,6 +52,6 @@
"description": "default backend parameters"
}
},
"required": ["name", "default_version", "health_check_path", "versions"],
"required": ["backend_name", "default_version", "version_configs"],
"additionalProperties": false
}
@@ -0,0 +1,48 @@
{
"type": "object",
"properties": {
"description": {
"type": ["string", "null"],
"description": "backend description"
},
"default_run_command": {
"type": ["string", "null"],
"description": "default start command"
},
"health_check_path": {
"type": ["string", "null"],
"description": "health check path"
},
"version_configs": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9._-]+$": {
"type": "object",
"properties": {
"image_name": {
"type": "string",
"description": "image name"
},
"run_command": {
"type": ["string", "null"],
"description": "start command"
}
},
"required": ["image_name", "run_command"],
"additionalProperties": false
}
},
"additionalProperties": false,
"description": "multiple backend versions"
},
"default_backend_parameters": {
"type": "array",
"items": {
"type": "string"
},
"description": "default backend parameters"
}
},
"required": ["version_configs"],
"additionalProperties": false
}
@@ -0,0 +1,52 @@
{
"type": "object",
"properties": {
"description": {
"type": ["string", "null"],
"description": "backend description"
},
"default_version": {
"type": "string",
"description": "default backend version"
},
"default_run_command": {
"type": ["string", "null"],
"description": "default start command"
},
"health_check_path": {
"type": ["string", "null"],
"description": "health check path"
},
"version_configs": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9._-]+$": {
"type": "object",
"properties": {
"image_name": {
"type": "string",
"description": "image name"
},
"run_command": {
"type": ["string", "null"],
"description": "start command"
}
},
"required": ["image_name", "run_command"],
"additionalProperties": false
}
},
"additionalProperties": false,
"description": "multiple backend versions"
},
"default_backend_parameters": {
"type": "array",
"items": {
"type": "string"
},
"description": "default backend parameters"
}
},
"required": ["default_version", "version_configs"],
"additionalProperties": false
}
-54
View File
@@ -1,54 +0,0 @@
import lmDeployLogo from '@/assets/logo/lmdeploy.png';
import SGLangLogo from '@/assets/logo/sglang.png';
import vLLMLogo from '@/assets/logo/vllm.png';
export default [
{
id: 1,
backend_name: 'SGlang',
icon: SGLangLogo,
version_configs: {
'v1.0': {
image_name: 'example/image:v1.0',
run_command: 'run.sh'
}
},
compatibility_type: 'template_string',
health_check_path: '/v1/models',
default_version: 'v1.0',
default_backend_param: ['--param1', '--param2'],
description: 'sglang description'
},
{
id: 2,
backend_name: 'vLLM',
icon: vLLMLogo,
version_configs: {
'v1.0': {
image_name: 'example/image:v1.0',
run_command: 'run.sh'
}
},
compatibility_type: 'template_string',
health_check_path: '/v1/models',
default_version: 'v1.0',
default_backend_param: ['--param1', '--param2'],
description: 'vllm description'
},
{
id: 3,
backend_name: 'LMDeploy',
icon: lmDeployLogo,
version_configs: {
'v1.0': {
image_name: 'example/image:v1.0',
run_command: 'run.sh'
}
},
compatibility_type: 'template_string',
health_check_path: '/v1/models',
default_version: 'v1.0',
default_backend_param: ['--param1', '--param2'],
description: 'LMDeploy description'
}
];
+9 -8
View File
@@ -1,15 +1,15 @@
export interface VersionConfigs {
[key: string]: {
image_name: string;
run_command: string;
};
image_name: string;
run_command: string;
is_default: boolean;
version_no?: string;
}
export interface FormData {
backend_name?: string;
backend_name: string;
description?: string;
version_configs?: VersionConfigs;
compatibility_type?: string;
version_configs?: VersionConfigs[];
default_run_command?: string;
health_check_path?: string;
default_version?: string;
default_backend_param?: string[];
@@ -18,7 +18,8 @@ export interface FormData {
}
export interface ListItem extends FormData {
id?: number;
id: number;
is_build_in?: boolean;
created_at?: string;
updated_at?: string;
}