From 868e524f2994ed49bbb41f114ba03790ab6a4512 Mon Sep 17 00:00:00 2001
From: chanx <1243304602@qq.com>
Date: Fri, 10 Jul 2026 13:27:14 +0800
Subject: [PATCH] fix: pass ownerTenantId to LLMLabel and related components
for improved model fetching (#16800)
---
web/src/components/llm-select/llm-label.tsx | 22 +++++++++++++++----
web/src/components/llm-select/next.tsx | 2 +-
web/src/pages/agent/canvas/node/card.tsx | 12 +++++++---
.../agent/form/compilation-form/index.tsx | 4 +++-
.../chat/chat-box/next-multiple-chat-box.tsx | 1 +
.../pages/next-chats/chat/llm-select-form.tsx | 2 +-
6 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/web/src/components/llm-select/llm-label.tsx b/web/src/components/llm-select/llm-label.tsx
index 0dffcd75a4..875e94f974 100644
--- a/web/src/components/llm-select/llm-label.tsx
+++ b/web/src/components/llm-select/llm-label.tsx
@@ -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;
diff --git a/web/src/components/llm-select/next.tsx b/web/src/components/llm-select/next.tsx
index 0c18dcccf0..4a95e12429 100644
--- a/web/src/components/llm-select/next.tsx
+++ b/web/src/components/llm-select/next.tsx
@@ -66,7 +66,7 @@ const NextInnerLLMSelect = forwardRef<
data-testid={triggerTestId}
>
-
+
diff --git a/web/src/pages/agent/canvas/node/card.tsx b/web/src/pages/agent/canvas/node/card.tsx
index a11d33446b..180d95f6c7 100644
--- a/web/src/pages/agent/canvas/node/card.tsx
+++ b/web/src/pages/agent/canvas/node/card.tsx
@@ -21,6 +21,7 @@ import { useFetchAllAddedModels } from '@/hooks/use-llm-request';
import { cn } from '@/lib/utils';
import { parseModelValue } from '@/utils/llm-util';
import { PropsWithChildren, useMemo } from 'react';
+import { useOwnerTenantId } from '../../context';
export function CardWithForm() {
return (
@@ -81,7 +82,11 @@ export function LabelCard({ children, className, ...props }: LabelCardProps) {
}
export function LLMLabelCard({ llmId }: { llmId?: string }) {
- const { data: allAddedModels } = useFetchAllAddedModels();
+ const ownerTenantId = useOwnerTenantId();
+ const { data: allAddedModels } = useFetchAllAddedModels(
+ undefined,
+ ownerTenantId,
+ );
const isValidLlm = useMemo(() => {
if (!llmId) return false;
@@ -96,14 +101,15 @@ export function LLMLabelCard({ llmId }: { llmId?: string }) {
);
}
- return false;
+ // value is a plain model_id rather than the composite string
+ return allAddedModels.some((m) => m.model_id === llmId);
}, [allAddedModels, llmId]);
return (
-
+
);
}
diff --git a/web/src/pages/agent/form/compilation-form/index.tsx b/web/src/pages/agent/form/compilation-form/index.tsx
index f04c4d3547..f1b043c4b2 100644
--- a/web/src/pages/agent/form/compilation-form/index.tsx
+++ b/web/src/pages/agent/form/compilation-form/index.tsx
@@ -7,6 +7,7 @@ import { memo } from 'react';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
import { initialCompilationValues } from '../../constant/pipeline';
+import { useOwnerTenantId } from '../../context';
import { useFormValues } from '../../hooks/use-form-values';
import { useWatchFormChange } from '../../hooks/use-watch-form-change';
import { INextOperatorForm } from '../../interface';
@@ -25,6 +26,7 @@ const outputList = buildOutputList(initialCompilationValues.outputs);
const CompilationForm = ({ node }: INextOperatorForm) => {
const defaultValues = useFormValues(initialCompilationValues, node);
+ const ownerTenantId = useOwnerTenantId();
const form = useForm({
defaultValues,
@@ -36,7 +38,7 @@ const CompilationForm = ({ node }: INextOperatorForm) => {
return (
diff --git a/web/src/pages/next-chats/chat/llm-select-form.tsx b/web/src/pages/next-chats/chat/llm-select-form.tsx
index ff9d839f4d..072122170a 100644
--- a/web/src/pages/next-chats/chat/llm-select-form.tsx
+++ b/web/src/pages/next-chats/chat/llm-select-form.tsx
@@ -29,7 +29,7 @@ export function LLMSelectForm() {
return (
);
}