feat: dynamic backends

This commit is contained in:
jialin
2025-10-13 14:40:26 +08:00
parent ee95fabc47
commit bca1e8140e
19 changed files with 325 additions and 177 deletions
+22 -3
View File
@@ -1,15 +1,16 @@
import { PageActionType } from '@/config/types';
import React from 'react';
import { DeployFormKey } from './types';
import { BackendOption, DeployFormKey } from './types';
interface FormContextProps {
isGGUF?: boolean;
formKey: DeployFormKey;
source?: string;
source: string;
pageAction: PageActionType;
gpuOptions?: any[];
backendOptions: BackendOption[];
onValuesChange?: (changedValues: any, allValues: any) => void;
onBackendChange?: (backend: string) => void;
onBackendChange: (backend: string) => void;
}
interface CatalogFormContextProps {
@@ -19,6 +20,10 @@ interface CatalogFormContextProps {
onQuantizationChange: (val: string) => void;
}
interface FormOuterContextProps {
sourceList?: Global.BaseOption<string>[];
}
export const FormContext = React.createContext<FormContextProps>(
{} as FormContextProps
);
@@ -27,6 +32,10 @@ export const CatalogFormContext = React.createContext<CatalogFormContextProps>(
{} as CatalogFormContextProps
);
export const FormOuterContext = React.createContext<FormOuterContextProps>(
{} as FormOuterContextProps
);
export const useFormContext = () => {
const context = React.useContext(FormContext);
if (!context) {
@@ -44,3 +53,13 @@ export const useCatalogFormContext = () => {
}
return context;
};
export const useFormOuterContext = () => {
const context = React.useContext(FormOuterContext);
if (!context) {
throw new Error(
'useFormOuterContext must be used within a FormOuterProvider'
);
}
return context;
};
+3 -1
View File
@@ -324,7 +324,9 @@ export const excludeFields = [
'scheduleType',
'placement_strategy',
'backend',
'gpu_selector'
'gpu_selector',
'run_command',
'image_name'
];
// ingore fields when compare old and new data
+10
View File
@@ -39,6 +39,8 @@ export type SourceType =
| 'ollama_library';
export interface FormData {
image_name?: string;
run_command?: string;
backend: string;
restart_on_error?: boolean;
env?: Record<string, any>;
@@ -242,3 +244,11 @@ export interface EvaluateResult {
};
};
}
export interface BackendOption {
value: string;
label: string;
default_backend_param: string[];
default_version: string;
versions: { label: string; value: string }[];
}