feat: dynamic backends
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 }[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user