Allow entering agent mode without preset
This commit is contained in:
parent
1f864294c9
commit
a219397344
@ -3220,28 +3220,27 @@ export function CanvasChatPanel({
|
|||||||
const [composerModeOverride, setComposerModeOverride] = useState<
|
const [composerModeOverride, setComposerModeOverride] = useState<
|
||||||
"agent" | "image" | "video" | "detail" | null
|
"agent" | "image" | "video" | "detail" | null
|
||||||
>(null);
|
>(null);
|
||||||
|
const activeComposerMode = composerModeOverride || computedComposerMode;
|
||||||
const agentSelectableModels = useMemo(
|
const agentSelectableModels = useMemo(
|
||||||
() => (agentEnabled ? [SMART_AUTO_MODEL, ...conversationOnlyModels] : conversationOnlyModels),
|
() => (agentEnabled ? [SMART_AUTO_MODEL, ...conversationOnlyModels] : conversationOnlyModels),
|
||||||
[SMART_AUTO_MODEL, agentEnabled, conversationOnlyModels]
|
[SMART_AUTO_MODEL, agentEnabled, conversationOnlyModels]
|
||||||
);
|
);
|
||||||
const selectableModels = useMemo(() => {
|
const selectableModels = useMemo(() => {
|
||||||
if (isDetailGenerationMode) {
|
if (activeComposerMode === "detail") {
|
||||||
return [SMART_AUTO_MODEL];
|
return [SMART_AUTO_MODEL];
|
||||||
}
|
}
|
||||||
if (isVideoModel) {
|
if (activeComposerMode === "video") {
|
||||||
return videoOnlyModels;
|
return videoOnlyModels;
|
||||||
}
|
}
|
||||||
if (isAgentModel) {
|
if (activeComposerMode === "agent") {
|
||||||
return agentSelectableModels;
|
return agentSelectableModels;
|
||||||
}
|
}
|
||||||
return imageOnlyModels;
|
return imageOnlyModels;
|
||||||
}, [
|
}, [
|
||||||
SMART_AUTO_MODEL,
|
SMART_AUTO_MODEL,
|
||||||
|
activeComposerMode,
|
||||||
agentSelectableModels,
|
agentSelectableModels,
|
||||||
imageOnlyModels,
|
imageOnlyModels,
|
||||||
isAgentModel,
|
|
||||||
isDetailGenerationMode,
|
|
||||||
isVideoModel,
|
|
||||||
videoOnlyModels,
|
videoOnlyModels,
|
||||||
]);
|
]);
|
||||||
const modelSelectValue = selectableModels.some((model) => model.id === selectedModelId)
|
const modelSelectValue = selectableModels.some((model) => model.id === selectedModelId)
|
||||||
@ -3259,7 +3258,6 @@ export function CanvasChatPanel({
|
|||||||
if (videoParams.mode === "first-frame") return ["首帧"] as string[];
|
if (videoParams.mode === "first-frame") return ["首帧"] as string[];
|
||||||
return [] as string[];
|
return [] as string[];
|
||||||
}, [isVideoModel, videoParams]);
|
}, [isVideoModel, videoParams]);
|
||||||
const activeComposerMode = composerModeOverride || computedComposerMode;
|
|
||||||
const activeComposerModeRef = useRef(activeComposerMode);
|
const activeComposerModeRef = useRef(activeComposerMode);
|
||||||
const agentUploadSlots = useMemo(() => {
|
const agentUploadSlots = useMemo(() => {
|
||||||
if (
|
if (
|
||||||
@ -3506,19 +3504,6 @@ export function CanvasChatPanel({
|
|||||||
activeComposerModeRef.current = activeComposerMode;
|
activeComposerModeRef.current = activeComposerMode;
|
||||||
}, [activeComposerMode]);
|
}, [activeComposerMode]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (composerModeOverride !== "agent") return;
|
|
||||||
if (agentEnabled && hasSelectedAgentPreset) return;
|
|
||||||
|
|
||||||
activeComposerModeRef.current = computedComposerMode;
|
|
||||||
setComposerModeOverride(null);
|
|
||||||
}, [
|
|
||||||
agentEnabled,
|
|
||||||
composerModeOverride,
|
|
||||||
computedComposerMode,
|
|
||||||
hasSelectedAgentPreset,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedModelId && siteSettings) {
|
if (!selectedModelId && siteSettings) {
|
||||||
const nextModelId = agentEnabled ? "auto" : firstImageModelId || firstVideoModelId || "";
|
const nextModelId = agentEnabled ? "auto" : firstImageModelId || firstVideoModelId || "";
|
||||||
@ -3764,11 +3749,6 @@ export function CanvasChatPanel({
|
|||||||
if (!agentEnabled) {
|
if (!agentEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!hasSelectedAgentPreset) {
|
|
||||||
toast.error("请先选择生图模式后再使用 Agent 模式");
|
|
||||||
activeComposerModeRef.current = computedComposerMode;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const preferredAgentModelId =
|
const preferredAgentModelId =
|
||||||
allModels.find(
|
allModels.find(
|
||||||
(model) =>
|
(model) =>
|
||||||
@ -8413,12 +8393,12 @@ export function CanvasChatPanel({
|
|||||||
!isLoading &&
|
!isLoading &&
|
||||||
!shouldShowImageLoading;
|
!shouldShowImageLoading;
|
||||||
const workspaceEmptyTitle = !selectedAgentPresetId
|
const workspaceEmptyTitle = !selectedAgentPresetId
|
||||||
? "请先在左侧选择生图模式"
|
? "请先在左侧选择智能体"
|
||||||
: hasAgentUploadSlots && attachments.length < agentRequiredUploadCount
|
: hasAgentUploadSlots && attachments.length < agentRequiredUploadCount
|
||||||
? `请先补齐图片槽位(${attachments.length}/${agentRequiredUploadCount})`
|
? `请先补齐图片槽位(${attachments.length}/${agentRequiredUploadCount})`
|
||||||
: "准备开始生成";
|
: "准备开始生成";
|
||||||
const workspaceEmptyDescription = !selectedAgentPresetId
|
const workspaceEmptyDescription = !selectedAgentPresetId
|
||||||
? "选择生图模式后,这里会显示生成结果。"
|
? "切换到 Agent 模式后,请先选择智能体,随后这里会显示生成结果。"
|
||||||
: hasAgentUploadSlots && attachments.length < agentRequiredUploadCount
|
: hasAgentUploadSlots && attachments.length < agentRequiredUploadCount
|
||||||
? "从左侧 SKU / SPU 获取图片,或在下方继续上传替换后,再点击开始生成。"
|
? "从左侧 SKU / SPU 获取图片,或在下方继续上传替换后,再点击开始生成。"
|
||||||
: "可在下方补充要求后点击开始生成,结果会显示在这里。";
|
: "可在下方补充要求后点击开始生成,结果会显示在这里。";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user