@@ -8,7 +8,7 @@ import { modelOptionName, normalizeModelOptionValue, resolveModelChannel, resolv
|
||||
import { canvasThemes } from "@/lib/canvas-theme";
|
||||
import { nanoid } from "nanoid";
|
||||
import { requestToolResponse, type ResponseFunctionTool, type ResponseInputMessage, type ResponseToolCall } from "@/services/api/image";
|
||||
import { createAgentSession, queryAgentSession } from "@/services/api/task-center";
|
||||
import { agentSessionFailureMessage, createAgentSession, queryAgentSession } from "@/services/api/task-center";
|
||||
import { imageToDataUrl } from "@/services/image-storage";
|
||||
import { useAssetStore } from "@/stores/use-asset-store";
|
||||
import { useThemeStore } from "@/stores/use-theme-store";
|
||||
@@ -1004,7 +1004,7 @@ async function createCinematicSessionOps(projectId: string, prompt: string, snap
|
||||
let detail = created;
|
||||
for (let attempt = 0; attempt < 120; attempt += 1) {
|
||||
if (detail.session.status === "completed") break;
|
||||
if (detail.session.status === "failed") throw new Error("后端影视 Agent 会话失败");
|
||||
if (detail.session.status === "failed") throw new Error(agentSessionFailureMessage(detail));
|
||||
await delay(2000);
|
||||
detail = await queryAgentSession(created.session.id);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { parseDocumentCharacterBreakdown, partitionCharacterBreakdowns, upsertCh
|
||||
import { createDocumentChapter } from "@/lib/canvas/canvas-document";
|
||||
import { createCanvasNode } from "@/lib/canvas/canvas-project-domain";
|
||||
import { backendProviderConfig, buildGenerationConfig, runBackendCanvasGenerationTask } from "@/lib/canvas/canvas-project-generation";
|
||||
import { createAgentSession, queryAgentSession } from "@/services/api/task-center";
|
||||
import { agentSessionFailureMessage, createAgentSession, queryAgentSession } from "@/services/api/task-center";
|
||||
import { resolveModelRequestConfig, useConfigStore, useEffectiveConfig } from "@/stores/use-config-store";
|
||||
import { CanvasNodeType, type CanvasConnection, type CanvasDocumentChapter, type CanvasNodeData, type CanvasNodeMetadata, type CanvasRichDocument, type Position, type ViewportTransform } from "@/types/canvas";
|
||||
|
||||
@@ -167,7 +167,7 @@ export function useCanvasDocumentWorkflow({
|
||||
let detail = created;
|
||||
for (let attempt = 0; attempt < 120; attempt += 1) {
|
||||
if (detail.session.status === "completed") break;
|
||||
if (detail.session.status === "failed") throw new Error("后端影视 Agent 会话失败");
|
||||
if (detail.session.status === "failed") throw new Error(agentSessionFailureMessage(detail));
|
||||
await new Promise<void>((resolve) => window.setTimeout(resolve, 2000));
|
||||
detail = await queryAgentSession(created.session.id);
|
||||
}
|
||||
|
||||
@@ -141,6 +141,18 @@ export function queryAgentSession(id: string) {
|
||||
return request<AgentSessionDetail>(api.get(`/query_session/${encodeURIComponent(id)}`));
|
||||
}
|
||||
|
||||
export function agentSessionFailureMessage(detail: AgentSessionDetail, fallback = "后端影视 Agent 会话失败") {
|
||||
for (let index = detail.tasks.length - 1; index >= 0; index -= 1) {
|
||||
const task = detail.tasks[index];
|
||||
if ((task.status === "failed" || task.status === "cancelled") && task.error?.trim()) return generationErrorMessage(task.error.trim());
|
||||
}
|
||||
for (let index = detail.messages.length - 1; index >= 0; index -= 1) {
|
||||
const message = detail.messages[index];
|
||||
if (message.role === "assistant" && message.content.trim()) return generationErrorMessage(message.content.trim());
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
export function downloadSessionResults(id: string) {
|
||||
return request<TaskResult[]>(api.get(`/download_results/${encodeURIComponent(id)}`));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user