fix: pass ownerTenantId to LLMLabel and related components for improved model fetching (#16800)

This commit is contained in:
chanx
2026-07-10 13:27:14 +08:00
committed by GitHub
parent eca8e87f44
commit 868e524f29
6 changed files with 33 additions and 10 deletions

View File

@@ -1,16 +1,30 @@
import { useFetchAllAddedModels } from '@/hooks/use-llm-request';
import { parseModelValue } from '@/utils/llm-util';
import { memo } from 'react';
import { LlmIcon } from '../svg-icon';
interface IProps {
value?: string;
ownerTenantId?: string;
}
export const LLMLabel = ({ value }: IProps) => {
export const LLMLabel = ({ value, ownerTenantId }: IProps) => {
const { data: models } = useFetchAllAddedModels(undefined, ownerTenantId);
const parsed = value ? parseModelValue(value) : null;
const modelName = parsed?.model_name;
const instanceName = parsed?.model_instance;
const iconName = parsed ? parsed.model_provider : '';
let modelName = parsed?.model_name;
let instanceName = parsed?.model_instance;
let iconName = parsed ? parsed.model_provider : '';
if (!modelName && value) {
const model = models.find((m) => m.model_id === value);
if (model) {
modelName = model.name;
instanceName = model.instance_name;
iconName = model.provider_name;
}
}
if (!modelName) return null;

View File

@@ -66,7 +66,7 @@ const NextInnerLLMSelect = forwardRef<
data-testid={triggerTestId}
>
<SelectValue placeholder={t('common.pleaseSelect')}>
<LLMLabel value={value} />
<LLMLabel value={value} ownerTenantId={ownerTenantId} />
</SelectValue>
</SelectTrigger>
</PopoverTrigger>