fix: lock workflow hidden models
This commit is contained in:
parent
35c4c02579
commit
83c274e8d4
@ -4,6 +4,7 @@ import {
|
|||||||
getDefaultAiModel,
|
getDefaultAiModel,
|
||||||
getEnabledAiModelsWithProvider,
|
getEnabledAiModelsWithProvider,
|
||||||
getSiteSettings,
|
getSiteSettings,
|
||||||
|
getSystemSetting,
|
||||||
getUserById,
|
getUserById,
|
||||||
} from "@/lib/db/queries";
|
} from "@/lib/db/queries";
|
||||||
import { buildVideoToolCapability } from "@/lib/ai/video-tool-capability";
|
import { buildVideoToolCapability } from "@/lib/ai/video-tool-capability";
|
||||||
@ -13,6 +14,11 @@ import {
|
|||||||
} from "@/lib/ai/model-classification";
|
} from "@/lib/ai/model-classification";
|
||||||
import { ChatSDKError } from "@/lib/errors";
|
import { ChatSDKError } from "@/lib/errors";
|
||||||
import { isAiModelAgentAuto, isAiModelMultimodal } from "@/lib/db/ai-model-flags";
|
import { isAiModelAgentAuto, isAiModelMultimodal } from "@/lib/db/ai-model-flags";
|
||||||
|
import {
|
||||||
|
AGENT_WORKFLOW_UI_CONFIG_KEY,
|
||||||
|
getAgentWorkflowBusinessModeSettings,
|
||||||
|
normalizeAgentWorkflowUiConfig,
|
||||||
|
} from "@/lib/agents/workflow-ui-config";
|
||||||
|
|
||||||
function isNanoBananaProModel(model: { displayName?: string | null; modelId?: string | null }) {
|
function isNanoBananaProModel(model: { displayName?: string | null; modelId?: string | null }) {
|
||||||
const displayName = String(model.displayName || "").toLowerCase();
|
const displayName = String(model.displayName || "").toLowerCase();
|
||||||
@ -39,6 +45,28 @@ function sortModelsForDisplay<T extends { sortOrder?: number | null; displayName
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWorkflowImageGenerationModel(model: {
|
||||||
|
providerType?: string | null;
|
||||||
|
modelId?: string | null;
|
||||||
|
capabilities?: unknown;
|
||||||
|
supportsImageGen?: boolean | null;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
isImageGenerationModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
}) &&
|
||||||
|
!isVideoModelDescriptor({
|
||||||
|
providerType: model.providerType,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// 获取前端可用的 AI 模型列表(需要登录但不需要管理员权限)
|
// 获取前端可用的 AI 模型列表(需要登录但不需要管理员权限)
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
@ -56,27 +84,12 @@ export async function GET() {
|
|||||||
const modelsWithProvider = await getEnabledAiModelsWithProvider(false, true);
|
const modelsWithProvider = await getEnabledAiModelsWithProvider(false, true);
|
||||||
const agentModelWithProvider = await getAgentAiModelWithProvider();
|
const agentModelWithProvider = await getAgentAiModelWithProvider();
|
||||||
const defaultModel = await getDefaultAiModel();
|
const defaultModel = await getDefaultAiModel();
|
||||||
const siteSettings = await getSiteSettings();
|
const [siteSettings, agentWorkflowUiConfigSetting] = await Promise.all([
|
||||||
const visibleModelsWithProvider = sortModelsForDisplay(
|
getSiteSettings(),
|
||||||
modelsWithProvider
|
getSystemSetting({ key: AGENT_WORKFLOW_UI_CONFIG_KEY }).catch(() => null),
|
||||||
.filter(
|
]);
|
||||||
({ model }) =>
|
type ModelWithProvider = (typeof modelsWithProvider)[number];
|
||||||
!isAiModelAgentAuto(model) &&
|
const serializeModel = ({ model, provider }: ModelWithProvider) => ({
|
||||||
(allowHiddenModels || !model.isHidden)
|
|
||||||
)
|
|
||||||
.map((item) => item.model)
|
|
||||||
);
|
|
||||||
const visibleModelIdSet = new Set(visibleModelsWithProvider.map((m) => m.id));
|
|
||||||
const visibleModelsWithProviderSorted = modelsWithProvider.filter(({ model }) =>
|
|
||||||
visibleModelIdSet.has(model.id)
|
|
||||||
).sort((a, b) => {
|
|
||||||
const left = visibleModelsWithProvider.findIndex((m) => m.id === a.model.id);
|
|
||||||
const right = visibleModelsWithProvider.findIndex((m) => m.id === b.model.id);
|
|
||||||
return left - right;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 转换为前端需要的格式
|
|
||||||
const models = visibleModelsWithProviderSorted.map(({ model, provider }) => ({
|
|
||||||
id: model.id,
|
id: model.id,
|
||||||
modelId: model.modelId,
|
modelId: model.modelId,
|
||||||
displayName: model.displayName,
|
displayName: model.displayName,
|
||||||
@ -101,7 +114,42 @@ export async function GET() {
|
|||||||
}),
|
}),
|
||||||
imageGenConfig: model.imageGenConfig,
|
imageGenConfig: model.imageGenConfig,
|
||||||
sortOrder: model.sortOrder ?? 0,
|
sortOrder: model.sortOrder ?? 0,
|
||||||
}));
|
});
|
||||||
|
const workflowImageModelById = new Map<string, ModelWithProvider>();
|
||||||
|
modelsWithProvider.forEach((entry) => {
|
||||||
|
const { model, provider } = entry;
|
||||||
|
if (
|
||||||
|
!isAiModelAgentAuto(model) &&
|
||||||
|
isWorkflowImageGenerationModel({
|
||||||
|
providerType: provider.type,
|
||||||
|
modelId: model.modelId,
|
||||||
|
capabilities: model.capabilities,
|
||||||
|
supportsImageGen: model.supportsImageGen,
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
workflowImageModelById.set(model.id, entry);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const visibleModelsWithProvider = sortModelsForDisplay(
|
||||||
|
modelsWithProvider
|
||||||
|
.filter(
|
||||||
|
({ model }) =>
|
||||||
|
!isAiModelAgentAuto(model) &&
|
||||||
|
(allowHiddenModels || !model.isHidden)
|
||||||
|
)
|
||||||
|
.map((item) => item.model)
|
||||||
|
);
|
||||||
|
const visibleModelIdSet = new Set(visibleModelsWithProvider.map((m) => m.id));
|
||||||
|
const visibleModelsWithProviderSorted = modelsWithProvider.filter(({ model }) =>
|
||||||
|
visibleModelIdSet.has(model.id)
|
||||||
|
).sort((a, b) => {
|
||||||
|
const left = visibleModelsWithProvider.findIndex((m) => m.id === a.model.id);
|
||||||
|
const right = visibleModelsWithProvider.findIndex((m) => m.id === b.model.id);
|
||||||
|
return left - right;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 转换为前端需要的格式
|
||||||
|
const models = visibleModelsWithProviderSorted.map(serializeModel);
|
||||||
const preferredNanoBananaModel = models.find(
|
const preferredNanoBananaModel = models.find(
|
||||||
(model) =>
|
(model) =>
|
||||||
isImageGenerationModelDescriptor({
|
isImageGenerationModelDescriptor({
|
||||||
@ -147,29 +195,43 @@ export async function GET() {
|
|||||||
const configuredAgentWorkflowModelId = String(
|
const configuredAgentWorkflowModelId = String(
|
||||||
siteSettings?.agentWorkflowDefaultModelId || ""
|
siteSettings?.agentWorkflowDefaultModelId || ""
|
||||||
).trim();
|
).trim();
|
||||||
const agentWorkflowDefaultModel = configuredAgentWorkflowModelId
|
const hasConfiguredAgentWorkflowModel = Boolean(
|
||||||
? models.find(
|
configuredAgentWorkflowModelId &&
|
||||||
(model) =>
|
configuredAgentWorkflowModelId !== "auto" &&
|
||||||
model.id === configuredAgentWorkflowModelId &&
|
configuredAgentWorkflowModelId !== "__auto"
|
||||||
isImageGenerationModelDescriptor({
|
);
|
||||||
providerType: model.providerType,
|
const agentWorkflowDefaultModel = hasConfiguredAgentWorkflowModel
|
||||||
modelId: model.modelId,
|
? workflowImageModelById.get(configuredAgentWorkflowModelId) || null
|
||||||
capabilities: model.capabilities,
|
|
||||||
supportsImageGen: model.supportsImageGen,
|
|
||||||
}) &&
|
|
||||||
!isVideoModelDescriptor({
|
|
||||||
providerType: model.providerType,
|
|
||||||
modelId: model.modelId,
|
|
||||||
capabilities: model.capabilities,
|
|
||||||
supportsImageGen: model.supportsImageGen,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
: null;
|
: null;
|
||||||
|
const workflowUiConfig = normalizeAgentWorkflowUiConfig(
|
||||||
|
agentWorkflowUiConfigSetting?.value
|
||||||
|
);
|
||||||
|
const workflowBusinessModeSettings = getAgentWorkflowBusinessModeSettings(
|
||||||
|
workflowUiConfig
|
||||||
|
);
|
||||||
|
const configuredWorkflowModelIds = new Set<string>();
|
||||||
|
if (agentWorkflowDefaultModel) {
|
||||||
|
configuredWorkflowModelIds.add(agentWorkflowDefaultModel.model.id);
|
||||||
|
}
|
||||||
|
workflowBusinessModeSettings.modes.forEach((mode) => {
|
||||||
|
const modelId = String(mode.defaultModelId || "").trim();
|
||||||
|
if (modelId && workflowImageModelById.has(modelId)) {
|
||||||
|
configuredWorkflowModelIds.add(modelId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const agentWorkflowConfiguredModels = Array.from(configuredWorkflowModelIds)
|
||||||
|
.map((id) => workflowImageModelById.get(id))
|
||||||
|
.filter((entry): entry is ModelWithProvider => Boolean(entry))
|
||||||
|
.map(serializeModel);
|
||||||
|
|
||||||
return Response.json({
|
return Response.json({
|
||||||
models,
|
models,
|
||||||
defaultModelId: resolvedDefaultModelId,
|
defaultModelId: resolvedDefaultModelId,
|
||||||
agentWorkflowDefaultModelId: agentWorkflowDefaultModel?.id || null,
|
agentWorkflowConfiguredDefaultModelId: hasConfiguredAgentWorkflowModel
|
||||||
|
? configuredAgentWorkflowModelId
|
||||||
|
: null,
|
||||||
|
agentWorkflowDefaultModelId: agentWorkflowDefaultModel?.model.id || null,
|
||||||
|
agentWorkflowConfiguredModels,
|
||||||
agentModel: agentModelWithProvider
|
agentModel: agentModelWithProvider
|
||||||
? {
|
? {
|
||||||
id: agentModelWithProvider.model.id,
|
id: agentModelWithProvider.model.id,
|
||||||
|
|||||||
@ -157,6 +157,15 @@ interface AgentGenerationWorkspaceDarkV2Props {
|
|||||||
workflowStylePanel?: ReactNode;
|
workflowStylePanel?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface AgentWorkflowModelOption {
|
||||||
|
id: string;
|
||||||
|
displayName: string;
|
||||||
|
providerType: string;
|
||||||
|
supportsImageGen?: boolean;
|
||||||
|
isMultimodal?: boolean;
|
||||||
|
imageGenConfig?: any;
|
||||||
|
}
|
||||||
|
|
||||||
interface PickedAttachment extends Attachment {}
|
interface PickedAttachment extends Attachment {}
|
||||||
|
|
||||||
const MAX_CHAT_TEXT_PART_LENGTH = 2000;
|
const MAX_CHAT_TEXT_PART_LENGTH = 2000;
|
||||||
@ -1210,16 +1219,11 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { data: modelsData } = useSWR<{
|
const { data: modelsData } = useSWR<{
|
||||||
models: Array<{
|
models: AgentWorkflowModelOption[];
|
||||||
id: string;
|
|
||||||
displayName: string;
|
|
||||||
providerType: string;
|
|
||||||
supportsImageGen?: boolean;
|
|
||||||
isMultimodal?: boolean;
|
|
||||||
imageGenConfig?: any;
|
|
||||||
}>;
|
|
||||||
defaultModelId?: string | null;
|
defaultModelId?: string | null;
|
||||||
|
agentWorkflowConfiguredDefaultModelId?: string | null;
|
||||||
agentWorkflowDefaultModelId?: string | null;
|
agentWorkflowDefaultModelId?: string | null;
|
||||||
|
agentWorkflowConfiguredModels?: AgentWorkflowModelOption[];
|
||||||
agentModel?: any;
|
agentModel?: any;
|
||||||
}>("/api/models", fetcher);
|
}>("/api/models", fetcher);
|
||||||
|
|
||||||
@ -1258,10 +1262,15 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
const activeBusinessModeDefaultModelId = !requiresPresetSelection
|
const activeBusinessModeDefaultModelId = !requiresPresetSelection
|
||||||
? String(activeBusinessMode?.defaultModelId || "").trim() || null
|
? String(activeBusinessMode?.defaultModelId || "").trim() || null
|
||||||
: null;
|
: null;
|
||||||
const effectiveDefaultModelId =
|
const lockedWorkflowModelId =
|
||||||
activeBusinessModeDefaultModelId ||
|
activeBusinessModeDefaultModelId ||
|
||||||
selectedAgentPreset?.defaultModelId ||
|
selectedAgentPreset?.defaultModelId ||
|
||||||
|
modelsData?.agentWorkflowConfiguredDefaultModelId ||
|
||||||
modelsData?.agentWorkflowDefaultModelId ||
|
modelsData?.agentWorkflowDefaultModelId ||
|
||||||
|
null;
|
||||||
|
const isWorkflowModelLocked = Boolean(lockedWorkflowModelId);
|
||||||
|
const effectiveDefaultModelId =
|
||||||
|
lockedWorkflowModelId ||
|
||||||
modelsData?.defaultModelId ||
|
modelsData?.defaultModelId ||
|
||||||
null;
|
null;
|
||||||
const presetDrivenResultModeType: AgentGenerationResultModeType =
|
const presetDrivenResultModeType: AgentGenerationResultModeType =
|
||||||
@ -1353,7 +1362,8 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
);
|
);
|
||||||
const workflowBrandName = getCurrentWorkflowBrandName();
|
const workflowBrandName = getCurrentWorkflowBrandName();
|
||||||
const shouldAllowModelOverride =
|
const shouldAllowModelOverride =
|
||||||
isDirectModelGenerationMode || !isSceneGenerationPreset || presetModeConfig.scene.allowModelOverride;
|
!isWorkflowModelLocked &&
|
||||||
|
(isDirectModelGenerationMode || !isSceneGenerationPreset || presetModeConfig.scene.allowModelOverride);
|
||||||
const brandModelAttachmentKeys = useMemo(() => {
|
const brandModelAttachmentKeys = useMemo(() => {
|
||||||
const keys = new Set<string>();
|
const keys = new Set<string>();
|
||||||
referenceImages
|
referenceImages
|
||||||
@ -1737,6 +1747,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
selectedAgentPresetId: string | null;
|
selectedAgentPresetId: string | null;
|
||||||
selectedAgentPresetType: AgentPreset["type"] | null;
|
selectedAgentPresetType: AgentPreset["type"] | null;
|
||||||
selectedModelId: string;
|
selectedModelId: string;
|
||||||
|
lockedWorkflowModelId: string | null;
|
||||||
imageParams: ImageGenerationParams;
|
imageParams: ImageGenerationParams;
|
||||||
isDetailReplacementPreset: boolean;
|
isDetailReplacementPreset: boolean;
|
||||||
isSkuReplacementPreset: boolean;
|
isSkuReplacementPreset: boolean;
|
||||||
@ -1754,6 +1765,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
selectedAgentPresetId: null,
|
selectedAgentPresetId: null,
|
||||||
selectedAgentPresetType: null,
|
selectedAgentPresetType: null,
|
||||||
selectedModelId: "auto",
|
selectedModelId: "auto",
|
||||||
|
lockedWorkflowModelId: null,
|
||||||
imageParams: {
|
imageParams: {
|
||||||
aspectRatio: "auto",
|
aspectRatio: "auto",
|
||||||
imageSize: "2K",
|
imageSize: "2K",
|
||||||
@ -1776,6 +1788,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
selectedAgentPresetId: selectedAgentPresetId || null,
|
selectedAgentPresetId: selectedAgentPresetId || null,
|
||||||
selectedAgentPresetType: selectedAgentPreset?.type || null,
|
selectedAgentPresetType: selectedAgentPreset?.type || null,
|
||||||
selectedModelId,
|
selectedModelId,
|
||||||
|
lockedWorkflowModelId,
|
||||||
imageParams,
|
imageParams,
|
||||||
isDetailReplacementPreset,
|
isDetailReplacementPreset,
|
||||||
isSkuReplacementPreset,
|
isSkuReplacementPreset,
|
||||||
@ -1807,10 +1820,40 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
return [autoOption, ...imageModels];
|
return [autoOption, ...imageModels];
|
||||||
}, [modelsData?.agentModel?.imageGenConfig, modelsData?.models]);
|
}, [modelsData?.agentModel?.imageGenConfig, modelsData?.models]);
|
||||||
|
|
||||||
const currentModel = useMemo(
|
const configuredWorkflowModels = useMemo(
|
||||||
() => selectableModels.find((model) => model.id === selectedModelId) || selectableModels[0],
|
() => modelsData?.agentWorkflowConfiguredModels || [],
|
||||||
[selectableModels, selectedModelId]
|
[modelsData?.agentWorkflowConfiguredModels]
|
||||||
);
|
);
|
||||||
|
const executableModelOptions = useMemo(() => {
|
||||||
|
const seen = new Set<string>();
|
||||||
|
return [...selectableModels, ...configuredWorkflowModels].filter((model) => {
|
||||||
|
if (seen.has(model.id)) return false;
|
||||||
|
seen.add(model.id);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}, [configuredWorkflowModels, selectableModels]);
|
||||||
|
const executableModelIdSet = useMemo(
|
||||||
|
() => new Set(executableModelOptions.map((model) => model.id)),
|
||||||
|
[executableModelOptions]
|
||||||
|
);
|
||||||
|
const lockedWorkflowModel = useMemo(
|
||||||
|
() =>
|
||||||
|
lockedWorkflowModelId
|
||||||
|
? executableModelOptions.find((model) => model.id === lockedWorkflowModelId) || null
|
||||||
|
: null,
|
||||||
|
[executableModelOptions, lockedWorkflowModelId]
|
||||||
|
);
|
||||||
|
const currentModel = useMemo(
|
||||||
|
() =>
|
||||||
|
lockedWorkflowModel ||
|
||||||
|
executableModelOptions.find((model) => model.id === selectedModelId) ||
|
||||||
|
selectableModels[0],
|
||||||
|
[executableModelOptions, lockedWorkflowModel, selectableModels, selectedModelId]
|
||||||
|
);
|
||||||
|
const lockedWorkflowModelLabel =
|
||||||
|
lockedWorkflowModel?.displayName ||
|
||||||
|
selectedAgentPreset?.defaultModel?.displayName ||
|
||||||
|
(lockedWorkflowModelId ? `配置模型不可用(${lockedWorkflowModelId})` : "未配置");
|
||||||
const [activeToolStep, setActiveToolStep] = useState<ToolStepKey>("settings");
|
const [activeToolStep, setActiveToolStep] = useState<ToolStepKey>("settings");
|
||||||
const hasBrandModelStep = Boolean(brandModelPanel) && modelSlotEnabled;
|
const hasBrandModelStep = Boolean(brandModelPanel) && modelSlotEnabled;
|
||||||
const hasBrandStoreStep = Boolean(brandStorePanel);
|
const hasBrandStoreStep = Boolean(brandStorePanel);
|
||||||
@ -1862,9 +1905,10 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
? transportState.selectedAgentPresetId || selectedAgentPresetId || undefined
|
? transportState.selectedAgentPresetId || selectedAgentPresetId || undefined
|
||||||
: undefined;
|
: undefined;
|
||||||
const resolvedSelectedModelId =
|
const resolvedSelectedModelId =
|
||||||
transportState.selectedModelId !== "auto"
|
transportState.lockedWorkflowModelId ||
|
||||||
|
(transportState.selectedModelId !== "auto"
|
||||||
? transportState.selectedModelId
|
? transportState.selectedModelId
|
||||||
: effectiveDefaultModelId || transportState.selectedModelId;
|
: effectiveDefaultModelId || transportState.selectedModelId);
|
||||||
const replacementModePayload =
|
const replacementModePayload =
|
||||||
transportState.isDetailReplacementPreset || transportState.isSkuReplacementPreset
|
transportState.isDetailReplacementPreset || transportState.isSkuReplacementPreset
|
||||||
? {
|
? {
|
||||||
@ -1958,6 +2002,10 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
}, [historyMessages, setMessages]);
|
}, [historyMessages, setMessages]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (isWorkflowModelLocked) {
|
||||||
|
setSelectedModelId((current) => (current === "auto" ? current : "auto"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (normalizedIncomingWorkspaceState.selectedModelId) {
|
if (normalizedIncomingWorkspaceState.selectedModelId) {
|
||||||
const nextModelId = normalizedIncomingWorkspaceState.selectedModelId;
|
const nextModelId = normalizedIncomingWorkspaceState.selectedModelId;
|
||||||
setSelectedModelId((current) =>
|
setSelectedModelId((current) =>
|
||||||
@ -1973,6 +2021,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
effectiveDefaultModelId,
|
effectiveDefaultModelId,
|
||||||
|
isWorkflowModelLocked,
|
||||||
normalizedIncomingWorkspaceState.selectedModelId,
|
normalizedIncomingWorkspaceState.selectedModelId,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -2625,7 +2674,9 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
return arePickedAttachmentsEqual(current, nextAttachments) ? current : nextAttachments;
|
return arePickedAttachmentsEqual(current, nextAttachments) ? current : nextAttachments;
|
||||||
});
|
});
|
||||||
setSelectedModelId((current) => {
|
setSelectedModelId((current) => {
|
||||||
const nextModelId = normalizedIncomingWorkspaceState.selectedModelId || "auto";
|
const nextModelId = isWorkflowModelLocked
|
||||||
|
? "auto"
|
||||||
|
: normalizedIncomingWorkspaceState.selectedModelId || "auto";
|
||||||
return current === nextModelId ? current : nextModelId;
|
return current === nextModelId ? current : nextModelId;
|
||||||
});
|
});
|
||||||
setImageParams((current) => {
|
setImageParams((current) => {
|
||||||
@ -2636,7 +2687,7 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
};
|
};
|
||||||
return areImageGenerationParamsEqual(current, nextParams) ? current : nextParams;
|
return areImageGenerationParamsEqual(current, nextParams) ? current : nextParams;
|
||||||
});
|
});
|
||||||
}, [normalizedIncomingWorkspaceState]);
|
}, [isWorkflowModelLocked, normalizedIncomingWorkspaceState]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const nextWorkspaceState = {
|
const nextWorkspaceState = {
|
||||||
@ -2987,16 +3038,17 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const resolvedModelId =
|
const resolvedModelId =
|
||||||
selectedModelId !== "auto"
|
lockedWorkflowModelId ||
|
||||||
|
(selectedModelId !== "auto"
|
||||||
? selectedModelId
|
? selectedModelId
|
||||||
: effectiveDefaultModelId || selectedModelId;
|
: effectiveDefaultModelId || selectedModelId);
|
||||||
if (!resolvedModelId) {
|
if (!resolvedModelId) {
|
||||||
toast.error("当前风格化未配置模型");
|
toast.error("当前风格化未配置模型");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
resolvedModelId !== "auto" &&
|
resolvedModelId !== "auto" &&
|
||||||
!selectableModels.some((model) => model.id === resolvedModelId)
|
!executableModelIdSet.has(resolvedModelId)
|
||||||
) {
|
) {
|
||||||
toast.error("当前风格化绑定的模型不存在或已停用,请重新编辑风格化模型配置");
|
toast.error("当前风格化绑定的模型不存在或已停用,请重新编辑风格化模型配置");
|
||||||
return;
|
return;
|
||||||
@ -3113,11 +3165,12 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
isSelectedBusinessModeUnavailable,
|
isSelectedBusinessModeUnavailable,
|
||||||
isSkuReplacementPreset,
|
isSkuReplacementPreset,
|
||||||
effectiveDefaultModelId,
|
effectiveDefaultModelId,
|
||||||
|
executableModelIdSet,
|
||||||
|
lockedWorkflowModelId,
|
||||||
requiredProductUploadCount,
|
requiredProductUploadCount,
|
||||||
requiresPresetSelection,
|
requiresPresetSelection,
|
||||||
selectedAgentPreset,
|
selectedAgentPreset,
|
||||||
selectedAgentPresetId,
|
selectedAgentPresetId,
|
||||||
selectableModels,
|
|
||||||
selectedModelId,
|
selectedModelId,
|
||||||
sendMessage,
|
sendMessage,
|
||||||
setPendingGeneration,
|
setPendingGeneration,
|
||||||
@ -3670,9 +3723,18 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
? "en"
|
? "en"
|
||||||
: "zh";
|
: "zh";
|
||||||
const resolvedModelId =
|
const resolvedModelId =
|
||||||
selectedModelId !== "auto"
|
lockedWorkflowModelId ||
|
||||||
|
(selectedModelId !== "auto"
|
||||||
? selectedModelId
|
? selectedModelId
|
||||||
: effectiveDefaultModelId || undefined;
|
: effectiveDefaultModelId || undefined);
|
||||||
|
if (
|
||||||
|
resolvedModelId &&
|
||||||
|
resolvedModelId !== "auto" &&
|
||||||
|
!executableModelIdSet.has(resolvedModelId)
|
||||||
|
) {
|
||||||
|
toast.error("当前风格化绑定的模型不存在或已停用,请重新编辑风格化模型配置");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
detailGenerationCancelRef.current = false;
|
detailGenerationCancelRef.current = false;
|
||||||
setDetailGenerationRunResults([]);
|
setDetailGenerationRunResults([]);
|
||||||
@ -4918,9 +4980,11 @@ export function AgentGenerationWorkspaceDarkV2({
|
|||||||
</Select>
|
</Select>
|
||||||
) : (
|
) : (
|
||||||
<div className="rounded-[24px] border border-white/10 bg-black/30 px-4 py-3 text-sm text-white/70">
|
<div className="rounded-[24px] border border-white/10 bg-black/30 px-4 py-3 text-sm text-white/70">
|
||||||
当前生图模式已锁定模型:
|
{isWorkflowModelLocked ? "后台已锁定生图模型:" : "当前生图模式使用默认模型:"}
|
||||||
<span className="ml-2 font-medium text-white">
|
<span className="ml-2 font-medium text-white">
|
||||||
{selectedAgentPreset?.defaultModel?.displayName || currentModel?.displayName || "未配置"}
|
{isWorkflowModelLocked
|
||||||
|
? lockedWorkflowModelLabel
|
||||||
|
: currentModel?.displayName || "自动选择"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user