feat: lora route

This commit is contained in:
jialin
2026-05-25 13:56:44 +08:00
committed by jialin
parent 342583f8d1
commit 1e334903dd
5 changed files with 83 additions and 13 deletions
+19 -4
View File
@@ -94,7 +94,10 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
if (fallbackTarget) {
const exsitinged = targetList.find((ep) => {
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 (
ep.provider_id === fallbackTarget!.provider_id &&
@@ -104,7 +107,8 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
if (exsitinged) {
targetList = targetList.map((ep) => {
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
) {
return {
@@ -150,6 +154,7 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
model_id?: number;
provider_id?: number;
provider_model_name?: string;
lora_module_name?: string;
}[]
) => {
// init targets form list
@@ -157,7 +162,12 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
targets?.map((ep) => ({
weight: ep.weight,
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]
})) || []
);
@@ -180,7 +190,12 @@ const AccessForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
if (fallbackTarget) {
targetsRef.current?.initFallbackValues({
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]
});
}
+20
View File
@@ -25,6 +25,18 @@ const OptionWrapper = styled.span`
display: flex;
align-items: center;
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`
@@ -214,6 +226,14 @@ const TargetsForm = forwardRef((props, ref) => {
const { data } = option;
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>;
}