修复设置
This commit is contained in:
parent
9158783918
commit
624e045552
@ -139,7 +139,7 @@ function createSubAgent(parentCtx: AgentContext) {
|
|||||||
const systemPrompt = await fs.promises.readFile(skill, "utf-8");
|
const systemPrompt = await fs.promises.readFile(skill, "utf-8");
|
||||||
return runAgent({
|
return runAgent({
|
||||||
prompt,
|
prompt,
|
||||||
system: systemPrompt + "你可以使用如下XML格式写入工作区:\n<storySkeleton>故事骨架内容</storySkeleton>",
|
system: systemPrompt + "\n你可以使用如下XML格式写入工作区:\n<storySkeleton>故事骨架内容</storySkeleton>",
|
||||||
name: "编剧",
|
name: "编剧",
|
||||||
memoryKey: "assistant:execution:storySkeleton",
|
memoryKey: "assistant:execution:storySkeleton",
|
||||||
});
|
});
|
||||||
@ -154,7 +154,7 @@ function createSubAgent(parentCtx: AgentContext) {
|
|||||||
const systemPrompt = await fs.promises.readFile(skill, "utf-8");
|
const systemPrompt = await fs.promises.readFile(skill, "utf-8");
|
||||||
return runAgent({
|
return runAgent({
|
||||||
prompt,
|
prompt,
|
||||||
system: systemPrompt + "你可以使用如下XML格式写入工作区:\n<adaptationStrategy>改编策略内容</adaptationStrategy>",
|
system: systemPrompt + "\n你可以使用如下XML格式写入工作区:\n<adaptationStrategy>改编策略内容</adaptationStrategy>",
|
||||||
name: "编剧",
|
name: "编剧",
|
||||||
memoryKey: "assistant:execution:adaptationStrategy",
|
memoryKey: "assistant:execution:adaptationStrategy",
|
||||||
});
|
});
|
||||||
@ -171,7 +171,7 @@ function createSubAgent(parentCtx: AgentContext) {
|
|||||||
prompt,
|
prompt,
|
||||||
system:
|
system:
|
||||||
systemPrompt +
|
systemPrompt +
|
||||||
`你可以使用如下XML格式写入工作区:\nXML不得添加任何额外标签<script><item name="剧本名称">剧本内容</item><item name="剧本名称">剧本内容</item><item name="剧本名称">剧本内容</item></script>`,
|
`\n你可以使用如下XML格式写入工作区:\nXML不得添加任何额外标签<script><item name="剧本名称">剧本内容</item><item name="剧本名称">剧本内容</item><item name="剧本名称">剧本内容</item></script>`,
|
||||||
name: "编剧",
|
name: "编剧",
|
||||||
memoryKey: "assistant:execution:script",
|
memoryKey: "assistant:execution:script",
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import { serializeError } from "serialize-error";
|
|
||||||
import { success, error } from "@/lib/responseFormat";
|
import { success, error } from "@/lib/responseFormat";
|
||||||
import { validateFields } from "@/middleware/middleware";
|
import { validateFields } from "@/middleware/middleware";
|
||||||
import u from "@/utils";
|
import u from "@/utils";
|
||||||
@ -29,14 +28,14 @@ const vendorConfigSchema = z.object({
|
|||||||
name: z.string(),
|
name: z.string(),
|
||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("text"),
|
type: z.literal("text"),
|
||||||
multimodal: z.boolean(),
|
think: z.boolean(),
|
||||||
tool: z.boolean(),
|
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("image"),
|
type: z.literal("image"),
|
||||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||||
|
associationSkills:z.string().optional(),
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
@ -46,8 +45,6 @@ const vendorConfigSchema = z.object({
|
|||||||
z.union([
|
z.union([
|
||||||
z.enum([
|
z.enum([
|
||||||
"singleImage",
|
"singleImage",
|
||||||
"multiImage",
|
|
||||||
"gridImage",
|
|
||||||
"startEndRequired",
|
"startEndRequired",
|
||||||
"endFrameOptional",
|
"endFrameOptional",
|
||||||
"startFrameOptional",
|
"startFrameOptional",
|
||||||
@ -55,7 +52,7 @@ const vendorConfigSchema = z.object({
|
|||||||
"audioReference",
|
"audioReference",
|
||||||
"videoReference",
|
"videoReference",
|
||||||
]),
|
]),
|
||||||
z.array(z.enum(["video", "image", "audio", "text"])),
|
z.array(z.enum(["videoReference", "imageReference", "audioReference", "textReference"])),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
audio: z.union([z.literal("optional"), z.boolean()]),
|
audio: z.union([z.literal("optional"), z.boolean()]),
|
||||||
|
|||||||
@ -29,14 +29,14 @@ const vendorConfigSchema = z.object({
|
|||||||
name: z.string(),
|
name: z.string(),
|
||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("text"),
|
type: z.literal("text"),
|
||||||
multimodal: z.boolean(),
|
think: z.boolean(),
|
||||||
tool: z.boolean(),
|
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("image"),
|
type: z.literal("image"),
|
||||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||||
|
associationSkills:z.string().optional(),
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
@ -46,8 +46,6 @@ const vendorConfigSchema = z.object({
|
|||||||
z.union([
|
z.union([
|
||||||
z.enum([
|
z.enum([
|
||||||
"singleImage",
|
"singleImage",
|
||||||
"multiImage",
|
|
||||||
"gridImage",
|
|
||||||
"startEndRequired",
|
"startEndRequired",
|
||||||
"endFrameOptional",
|
"endFrameOptional",
|
||||||
"startFrameOptional",
|
"startFrameOptional",
|
||||||
@ -55,9 +53,10 @@ const vendorConfigSchema = z.object({
|
|||||||
"audioReference",
|
"audioReference",
|
||||||
"videoReference",
|
"videoReference",
|
||||||
]),
|
]),
|
||||||
z.array(z.enum(["video", "image", "audio", "text"])),
|
z.array(z.enum(["audioReference", "videoReference", "textReference", "imageReference"])),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
associationSkills:z.string().optional(),
|
||||||
audio: z.union([z.literal("optional"), z.boolean()]),
|
audio: z.union([z.literal("optional"), z.boolean()]),
|
||||||
durationResolutionMap: z.array(
|
durationResolutionMap: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
|
|||||||
@ -6,69 +6,6 @@ import { z } from "zod";
|
|||||||
import { transform } from "sucrase";
|
import { transform } from "sucrase";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
const vendorConfigSchema = z.object({
|
|
||||||
id: z.string(),
|
|
||||||
author: z.string(),
|
|
||||||
description: z.string().optional(),
|
|
||||||
name: z.string(),
|
|
||||||
icon: z.string().optional(),
|
|
||||||
inputs: z.array(
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
label: z.string(),
|
|
||||||
type: z.enum(["text", "password", "url"]),
|
|
||||||
required: z.boolean(),
|
|
||||||
placeholder: z.string().optional(),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
inputValues: z.record(z.string(), z.string()),
|
|
||||||
models: z.array(
|
|
||||||
z.discriminatedUnion("type", [
|
|
||||||
z.object({
|
|
||||||
name: z.string(),
|
|
||||||
modelName: z.string(),
|
|
||||||
type: z.literal("text"),
|
|
||||||
multimodal: z.boolean(),
|
|
||||||
tool: z.boolean(),
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
name: z.string(),
|
|
||||||
modelName: z.string(),
|
|
||||||
type: z.literal("image"),
|
|
||||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
name: z.string(),
|
|
||||||
modelName: z.string(),
|
|
||||||
type: z.literal("video"),
|
|
||||||
mode: z.array(
|
|
||||||
z.union([
|
|
||||||
z.enum([
|
|
||||||
"singleImage",
|
|
||||||
"multiImage",
|
|
||||||
"gridImage",
|
|
||||||
"startEndRequired",
|
|
||||||
"endFrameOptional",
|
|
||||||
"startFrameOptional",
|
|
||||||
"text",
|
|
||||||
"audioReference",
|
|
||||||
"videoReference",
|
|
||||||
]),
|
|
||||||
z.array(z.enum(["video", "image", "audio", "text"])),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
audio: z.union([z.literal("optional"), z.boolean()]),
|
|
||||||
durationResolutionMap: z.array(
|
|
||||||
z.object({
|
|
||||||
duration: z.array(z.number()),
|
|
||||||
resolution: z.array(z.string()),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router.post(
|
export default router.post(
|
||||||
"/",
|
"/",
|
||||||
validateFields({
|
validateFields({
|
||||||
@ -89,14 +26,14 @@ export default router.post(
|
|||||||
name: z.string(),
|
name: z.string(),
|
||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("text"),
|
type: z.literal("text"),
|
||||||
multimodal: z.boolean(),
|
think: z.boolean(),
|
||||||
tool: z.boolean(),
|
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
modelName: z.string(),
|
modelName: z.string(),
|
||||||
type: z.literal("image"),
|
type: z.literal("image"),
|
||||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||||
|
associationSkills: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
@ -104,10 +41,11 @@ export default router.post(
|
|||||||
type: z.literal("video"),
|
type: z.literal("video"),
|
||||||
mode: z.array(
|
mode: z.array(
|
||||||
z.union([
|
z.union([
|
||||||
z.enum(["singleImage", "multiImage", "gridImage", "startEndRequired", "endFrameOptional", "startFrameOptional", "text"]),
|
z.enum(["singleImage", "startEndRequired", "endFrameOptional", "startFrameOptional", "text"]),
|
||||||
z.array(z.enum(["audioReference", "videoReference", "textReference", "imageReference"])),
|
z.array(z.enum(["audioReference", "videoReference", "textReference", "imageReference"])),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
associationSkills: z.string().optional(),
|
||||||
audio: z.union([z.literal("optional"), z.boolean()]),
|
audio: z.union([z.literal("optional"), z.boolean()]),
|
||||||
durationResolutionMap: z.array(
|
durationResolutionMap: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
|
|||||||
62
src/types/database.d.ts
vendored
62
src/types/database.d.ts
vendored
@ -1,62 +1,13 @@
|
|||||||
// @db-hash ea0c51ccb8c93a2f019139db9621721e
|
// @db-hash 93b2462070c45c2b449e9a18c4e88763
|
||||||
//该文件由脚本自动生成,请勿手动修改
|
//该文件由脚本自动生成,请勿手动修改
|
||||||
|
|
||||||
export interface _o_project_old_20260330 {
|
|
||||||
'artStyle'?: string | null;
|
|
||||||
'createTime'?: number | null;
|
|
||||||
'id'?: number | null;
|
|
||||||
'intro'?: string | null;
|
|
||||||
'name'?: string | null;
|
|
||||||
'projectType'?: string | null;
|
|
||||||
'type'?: string | null;
|
|
||||||
'userId'?: number | null;
|
|
||||||
'videoRatio'?: string | null;
|
|
||||||
}
|
|
||||||
export interface _o_storyboard_old_20260325 {
|
|
||||||
'camera'?: string | null;
|
|
||||||
'createTime'?: number | null;
|
|
||||||
'description'?: string | null;
|
|
||||||
'duration'?: string | null;
|
|
||||||
'filePath'?: string | null;
|
|
||||||
'frameMode'?: string | null;
|
|
||||||
'id'?: number;
|
|
||||||
'lines'?: string | null;
|
|
||||||
'mode'?: string | null;
|
|
||||||
'model'?: string | null;
|
|
||||||
'prompt'?: string | null;
|
|
||||||
'reason'?: string | null;
|
|
||||||
'resolution'?: string | null;
|
|
||||||
'scriptId'?: number | null;
|
|
||||||
'sound'?: string | null;
|
|
||||||
'state'?: string | null;
|
|
||||||
'title'?: string | null;
|
|
||||||
}
|
|
||||||
export interface _o_storyboard_old_20260330 {
|
|
||||||
'camera'?: string | null;
|
|
||||||
'createTime'?: number | null;
|
|
||||||
'description'?: string | null;
|
|
||||||
'duration'?: string | null;
|
|
||||||
'filePath'?: string | null;
|
|
||||||
'frameMode'?: string | null;
|
|
||||||
'id'?: number;
|
|
||||||
'index'?: string | null;
|
|
||||||
'lines'?: string | null;
|
|
||||||
'mode'?: string | null;
|
|
||||||
'model'?: string | null;
|
|
||||||
'prompt'?: string | null;
|
|
||||||
'reason'?: string | null;
|
|
||||||
'resolution'?: string | null;
|
|
||||||
'scriptId'?: number | null;
|
|
||||||
'sound'?: string | null;
|
|
||||||
'state'?: string | null;
|
|
||||||
'title'?: string | null;
|
|
||||||
}
|
|
||||||
export interface memories {
|
export interface memories {
|
||||||
'content': string;
|
'content': string;
|
||||||
'createTime': number;
|
'createTime': number;
|
||||||
'embedding'?: string | null;
|
'embedding'?: string | null;
|
||||||
'id'?: string;
|
'id'?: string;
|
||||||
'isolationKey': string;
|
'isolationKey': string;
|
||||||
|
'name'?: string | null;
|
||||||
'relatedMessageIds'?: string | null;
|
'relatedMessageIds'?: string | null;
|
||||||
'role'?: string | null;
|
'role'?: string | null;
|
||||||
'summarized'?: number | null;
|
'summarized'?: number | null;
|
||||||
@ -96,6 +47,7 @@ export interface o_assets {
|
|||||||
'name'?: string | null;
|
'name'?: string | null;
|
||||||
'projectId'?: number | null;
|
'projectId'?: number | null;
|
||||||
'prompt'?: string | null;
|
'prompt'?: string | null;
|
||||||
|
'promptState'?: string | null;
|
||||||
'remark'?: string | null;
|
'remark'?: string | null;
|
||||||
'scriptId'?: number | null;
|
'scriptId'?: number | null;
|
||||||
'startTime'?: number | null;
|
'startTime'?: number | null;
|
||||||
@ -177,6 +129,8 @@ export interface o_prompt {
|
|||||||
export interface o_script {
|
export interface o_script {
|
||||||
'content'?: string | null;
|
'content'?: string | null;
|
||||||
'createTime'?: number | null;
|
'createTime'?: number | null;
|
||||||
|
'errorReason'?: string | null;
|
||||||
|
'extractState'?: number | null;
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'name'?: string | null;
|
'name'?: string | null;
|
||||||
'projectId'?: number | null;
|
'projectId'?: number | null;
|
||||||
@ -213,7 +167,7 @@ export interface o_storyboard {
|
|||||||
'filePath'?: string | null;
|
'filePath'?: string | null;
|
||||||
'frameMode'?: string | null;
|
'frameMode'?: string | null;
|
||||||
'id'?: number;
|
'id'?: number;
|
||||||
'index'?: string | null;
|
'index'?: number | null;
|
||||||
'lines'?: string | null;
|
'lines'?: string | null;
|
||||||
'mode'?: string | null;
|
'mode'?: string | null;
|
||||||
'model'?: string | null;
|
'model'?: string | null;
|
||||||
@ -224,7 +178,6 @@ export interface o_storyboard {
|
|||||||
'sound'?: string | null;
|
'sound'?: string | null;
|
||||||
'state'?: string | null;
|
'state'?: string | null;
|
||||||
'title'?: string | null;
|
'title'?: string | null;
|
||||||
'videoPrompt'?: string | null;
|
|
||||||
}
|
}
|
||||||
export interface o_tasks {
|
export interface o_tasks {
|
||||||
'describe'?: string | null;
|
'describe'?: string | null;
|
||||||
@ -279,9 +232,6 @@ export interface o_videoConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface DB {
|
export interface DB {
|
||||||
"_o_project_old_20260330": _o_project_old_20260330;
|
|
||||||
"_o_storyboard_old_20260325": _o_storyboard_old_20260325;
|
|
||||||
"_o_storyboard_old_20260330": _o_storyboard_old_20260330;
|
|
||||||
"memories": memories;
|
"memories": memories;
|
||||||
"o_agentDeploy": o_agentDeploy;
|
"o_agentDeploy": o_agentDeploy;
|
||||||
"o_agentWorkData": o_agentWorkData;
|
"o_agentWorkData": o_agentWorkData;
|
||||||
|
|||||||
@ -25,10 +25,23 @@ async function getVendorTemplateFn(fnName: FnName, modelName: `${string}:${strin
|
|||||||
const selectedModel = modelList.find((i: any) => i.modelName == name);
|
const selectedModel = modelList.find((i: any) => i.modelName == name);
|
||||||
if (!selectedModel) throw new Error(`未找到模型 ${name} id=${id}`);
|
if (!selectedModel) throw new Error(`未找到模型 ${name} id=${id}`);
|
||||||
const jsCode = transform(vendorConfigData.code!, { transforms: ["typescript"] }).code;
|
const jsCode = transform(vendorConfigData.code!, { transforms: ["typescript"] }).code;
|
||||||
const fn = u.vm(jsCode)[fnName];
|
const running = u.vm(jsCode);
|
||||||
|
Object.assign(running.vendor.inputValues, JSON.parse(vendorConfigData.inputValues ?? "{}"));
|
||||||
|
running.vendor.models = modelList;
|
||||||
|
const fn = running[fnName];
|
||||||
if (!fn) throw new Error(`未找到供应商配置中的函数 ${fnName} id=${id}`);
|
if (!fn) throw new Error(`未找到供应商配置中的函数 ${fnName} id=${id}`);
|
||||||
if (fnName == "textRequest") return fn(selectedModel);
|
if (fnName == "textRequest") {
|
||||||
else return <T>(input: T) => fn(input, selectedModel);
|
const model = fn(selectedModel);
|
||||||
|
if (!model) throw new Error(`供应商 textRequest 返回无效模型 id=${id}`);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
return async <T>(input: T) => {
|
||||||
|
const result = await fn(input, selectedModel);
|
||||||
|
if (result === undefined || result === null) {
|
||||||
|
throw new Error(`供应商函数 ${fnName} 未返回有效结果 id=${id}`);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function withTaskRecord<T>(
|
async function withTaskRecord<T>(
|
||||||
|
|||||||
@ -11,13 +11,12 @@ import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|||||||
import { createXai } from "@ai-sdk/xai";
|
import { createXai } from "@ai-sdk/xai";
|
||||||
import { createMinimax } from "vercel-minimax-ai-provider";
|
import { createMinimax } from "vercel-minimax-ai-provider";
|
||||||
import FormData from "form-data";
|
import FormData from "form-data";
|
||||||
|
import jsonwebtoken from "jsonwebtoken";
|
||||||
|
|
||||||
export default function runCode(code: string) {
|
export default function runCode(code: string, vendor?: Record<string, any>) {
|
||||||
// 创建一个沙盒
|
// 创建一个沙盒
|
||||||
const exports = {};
|
const exports = {};
|
||||||
const vm = new VM({
|
const sandbox: Record<string, any> = {
|
||||||
timeout: 0,
|
|
||||||
sandbox: {
|
|
||||||
createOpenAI,
|
createOpenAI,
|
||||||
createDeepSeek,
|
createDeepSeek,
|
||||||
createZhipu,
|
createZhipu,
|
||||||
@ -37,7 +36,14 @@ export default function runCode(code: string) {
|
|||||||
axios,
|
axios,
|
||||||
FormData,
|
FormData,
|
||||||
logger,
|
logger,
|
||||||
},
|
jsonwebtoken,
|
||||||
|
};
|
||||||
|
if (vendor !== undefined) {
|
||||||
|
sandbox.vendor = vendor;
|
||||||
|
}
|
||||||
|
const vm = new VM({
|
||||||
|
timeout: 0,
|
||||||
|
sandbox,
|
||||||
compiler: "javascript",
|
compiler: "javascript",
|
||||||
eval: false,
|
eval: false,
|
||||||
wasm: false,
|
wasm: false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user