feat: lora route
This commit is contained in:
@@ -18,6 +18,16 @@ export interface ListItem {
|
|||||||
enable_model_route?: boolean;
|
enable_model_route?: boolean;
|
||||||
replicas: number;
|
replicas: number;
|
||||||
s3Address: string;
|
s3Address: string;
|
||||||
|
lora_list: Array<{
|
||||||
|
huggingface_filename: string;
|
||||||
|
local_path: string;
|
||||||
|
lora_name: string;
|
||||||
|
lora_repo_name: string;
|
||||||
|
model_file_id: string;
|
||||||
|
model_scope_file_path: string;
|
||||||
|
path: string;
|
||||||
|
source: string;
|
||||||
|
}>;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
id: number;
|
id: number;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export interface FormData {
|
|||||||
provider_model_name?: string;
|
provider_model_name?: string;
|
||||||
model_id?: number;
|
model_id?: number;
|
||||||
provider_id?: number;
|
provider_id?: number;
|
||||||
|
lora_module_name?: string;
|
||||||
fallback_status_codes?: string[];
|
fallback_status_codes?: string[];
|
||||||
};
|
};
|
||||||
targets: {
|
targets: {
|
||||||
@@ -15,6 +16,7 @@ export interface FormData {
|
|||||||
weight?: number | null;
|
weight?: number | null;
|
||||||
model_id?: number;
|
model_id?: number;
|
||||||
provider_id?: number;
|
provider_id?: number;
|
||||||
|
lora_module_name?: string;
|
||||||
fallback_status_codes?: string[];
|
fallback_status_codes?: string[];
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
@@ -46,5 +48,6 @@ export interface RouteTarget {
|
|||||||
provider_id: number;
|
provider_id: number;
|
||||||
provider_model_name: string;
|
provider_model_name: string;
|
||||||
fallback_status_codes: string[];
|
fallback_status_codes: string[];
|
||||||
|
lora_module_name?: string;
|
||||||
state: string;
|
state: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,10 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
|||||||
if (fallbackTarget) {
|
if (fallbackTarget) {
|
||||||
const exsitinged = targetList.find((ep) => {
|
const exsitinged = targetList.find((ep) => {
|
||||||
if (fallbackTarget!.model_id) {
|
if (fallbackTarget!.model_id) {
|
||||||
return ep.model_id === fallbackTarget!.model_id;
|
return (
|
||||||
|
ep.model_id === fallbackTarget!.model_id &&
|
||||||
|
ep.lora_module_name === fallbackTarget!.lora_module_name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
ep.provider_id === fallbackTarget!.provider_id &&
|
ep.provider_id === fallbackTarget!.provider_id &&
|
||||||
@@ -104,7 +107,8 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
|||||||
if (exsitinged) {
|
if (exsitinged) {
|
||||||
targetList = targetList.map((ep) => {
|
targetList = targetList.map((ep) => {
|
||||||
if (
|
if (
|
||||||
ep.model_id === fallbackTarget.model_id ||
|
(ep.model_id === fallbackTarget.model_id &&
|
||||||
|
ep.lora_module_name === fallbackTarget.lora_module_name) ||
|
||||||
ep.provider_model_name === fallbackTarget.provider_model_name
|
ep.provider_model_name === fallbackTarget.provider_model_name
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
@@ -150,6 +154,7 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
|||||||
model_id?: number;
|
model_id?: number;
|
||||||
provider_id?: number;
|
provider_id?: number;
|
||||||
provider_model_name?: string;
|
provider_model_name?: string;
|
||||||
|
lora_module_name?: string;
|
||||||
}[]
|
}[]
|
||||||
) => {
|
) => {
|
||||||
// init targets form list
|
// init targets form list
|
||||||
@@ -157,7 +162,12 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
|||||||
targets?.map((ep) => ({
|
targets?.map((ep) => ({
|
||||||
weight: ep.weight,
|
weight: ep.weight,
|
||||||
value: ep.model_id
|
value: ep.model_id
|
||||||
? ['deployments', ep.model_id]
|
? [
|
||||||
|
'deployments',
|
||||||
|
ep.lora_module_name
|
||||||
|
? `${ep.model_id}_lora_${ep.lora_module_name}`
|
||||||
|
: ep.model_id
|
||||||
|
]
|
||||||
: [ep.provider_id, ep.provider_model_name]
|
: [ep.provider_id, ep.provider_model_name]
|
||||||
})) || []
|
})) || []
|
||||||
);
|
);
|
||||||
@@ -180,7 +190,12 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
|||||||
if (fallbackTarget) {
|
if (fallbackTarget) {
|
||||||
targetsRef.current?.initFallbackValues({
|
targetsRef.current?.initFallbackValues({
|
||||||
value: fallbackTarget.model_id
|
value: fallbackTarget.model_id
|
||||||
? ['deployments', fallbackTarget.model_id]
|
? [
|
||||||
|
'deployments',
|
||||||
|
fallbackTarget.lora_module_name
|
||||||
|
? `${fallbackTarget.model_id}_lora_${fallbackTarget.lora_module_name}`
|
||||||
|
: fallbackTarget.model_id
|
||||||
|
]
|
||||||
: [fallbackTarget.provider_id, fallbackTarget.provider_model_name]
|
: [fallbackTarget.provider_id, fallbackTarget.provider_model_name]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,18 @@ const OptionWrapper = styled.span`
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
.lora-tag {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 7px;
|
||||||
|
height: 18px;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 18px;
|
||||||
|
border: 1px solid var(--ant-color-split);
|
||||||
|
border-radius: 12px;
|
||||||
|
color: var(--ant-color-text-tertiary);
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const LabelWrapper = styled.div`
|
const LabelWrapper = styled.div`
|
||||||
@@ -214,6 +226,14 @@ const TargetsForm = forwardRef((props, ref) => {
|
|||||||
const { data } = option;
|
const { data } = option;
|
||||||
|
|
||||||
if (!data.isParent) {
|
if (!data.isParent) {
|
||||||
|
if (data.isLora) {
|
||||||
|
return (
|
||||||
|
<OptionWrapper>
|
||||||
|
<AutoTooltip ghost>{data.label}</AutoTooltip>
|
||||||
|
<span className="lora-tag">LoRA</span>
|
||||||
|
</OptionWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
return <AutoTooltip ghost>{data.label}</AutoTooltip>;
|
return <AutoTooltip ghost>{data.label}</AutoTooltip>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,15 +48,37 @@ const useTargetSourceModels = () => {
|
|||||||
parent: false,
|
parent: false,
|
||||||
isParent: true,
|
isParent: true,
|
||||||
children: _.uniqBy(
|
children: _.uniqBy(
|
||||||
models.items?.map?.((model: ModelListItem) => ({
|
models.items?.flatMap?.((model: ModelListItem) => {
|
||||||
label: model.name,
|
const items: any[] = [
|
||||||
value: model.id,
|
{
|
||||||
data: {
|
label: model.name,
|
||||||
model_id: model.id,
|
value: model.id,
|
||||||
parentId: 'deployments'
|
data: {
|
||||||
},
|
model_id: model.id,
|
||||||
source: 'deployment'
|
parentId: 'deployments'
|
||||||
})),
|
},
|
||||||
|
source: 'deployment'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
model.lora_list?.forEach?.((lora) => {
|
||||||
|
const loraName = lora.lora_name || lora.lora_repo_name;
|
||||||
|
if (!loraName) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
items.push({
|
||||||
|
label: loraName,
|
||||||
|
value: `${model.id}_lora_${loraName}`,
|
||||||
|
data: {
|
||||||
|
model_id: model.id,
|
||||||
|
parentId: 'deployments',
|
||||||
|
lora_module_name: loraName
|
||||||
|
},
|
||||||
|
source: 'deployment',
|
||||||
|
isLora: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return items;
|
||||||
|
}) || [],
|
||||||
'value'
|
'value'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user