修复设置
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");
|
||||
return runAgent({
|
||||
prompt,
|
||||
system: systemPrompt + "你可以使用如下XML格式写入工作区:\n<storySkeleton>故事骨架内容</storySkeleton>",
|
||||
system: systemPrompt + "\n你可以使用如下XML格式写入工作区:\n<storySkeleton>故事骨架内容</storySkeleton>",
|
||||
name: "编剧",
|
||||
memoryKey: "assistant:execution:storySkeleton",
|
||||
});
|
||||
@ -154,7 +154,7 @@ function createSubAgent(parentCtx: AgentContext) {
|
||||
const systemPrompt = await fs.promises.readFile(skill, "utf-8");
|
||||
return runAgent({
|
||||
prompt,
|
||||
system: systemPrompt + "你可以使用如下XML格式写入工作区:\n<adaptationStrategy>改编策略内容</adaptationStrategy>",
|
||||
system: systemPrompt + "\n你可以使用如下XML格式写入工作区:\n<adaptationStrategy>改编策略内容</adaptationStrategy>",
|
||||
name: "编剧",
|
||||
memoryKey: "assistant:execution:adaptationStrategy",
|
||||
});
|
||||
@ -171,7 +171,7 @@ function createSubAgent(parentCtx: AgentContext) {
|
||||
prompt,
|
||||
system:
|
||||
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: "编剧",
|
||||
memoryKey: "assistant:execution:script",
|
||||
});
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import express from "express";
|
||||
import { serializeError } from "serialize-error";
|
||||
import { success, error } from "@/lib/responseFormat";
|
||||
import { validateFields } from "@/middleware/middleware";
|
||||
import u from "@/utils";
|
||||
@ -29,14 +28,14 @@ const vendorConfigSchema = z.object({
|
||||
name: z.string(),
|
||||
modelName: z.string(),
|
||||
type: z.literal("text"),
|
||||
multimodal: z.boolean(),
|
||||
tool: z.boolean(),
|
||||
think: z.boolean(),
|
||||
}),
|
||||
z.object({
|
||||
name: z.string(),
|
||||
modelName: z.string(),
|
||||
type: z.literal("image"),
|
||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||
associationSkills:z.string().optional(),
|
||||
}),
|
||||
z.object({
|
||||
name: z.string(),
|
||||
@ -46,8 +45,6 @@ const vendorConfigSchema = z.object({
|
||||
z.union([
|
||||
z.enum([
|
||||
"singleImage",
|
||||
"multiImage",
|
||||
"gridImage",
|
||||
"startEndRequired",
|
||||
"endFrameOptional",
|
||||
"startFrameOptional",
|
||||
@ -55,7 +52,7 @@ const vendorConfigSchema = z.object({
|
||||
"audioReference",
|
||||
"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()]),
|
||||
|
||||
@ -29,14 +29,14 @@ const vendorConfigSchema = z.object({
|
||||
name: z.string(),
|
||||
modelName: z.string(),
|
||||
type: z.literal("text"),
|
||||
multimodal: z.boolean(),
|
||||
tool: z.boolean(),
|
||||
think: z.boolean(),
|
||||
}),
|
||||
z.object({
|
||||
name: z.string(),
|
||||
modelName: z.string(),
|
||||
type: z.literal("image"),
|
||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||
associationSkills:z.string().optional(),
|
||||
}),
|
||||
z.object({
|
||||
name: z.string(),
|
||||
@ -46,8 +46,6 @@ const vendorConfigSchema = z.object({
|
||||
z.union([
|
||||
z.enum([
|
||||
"singleImage",
|
||||
"multiImage",
|
||||
"gridImage",
|
||||
"startEndRequired",
|
||||
"endFrameOptional",
|
||||
"startFrameOptional",
|
||||
@ -55,9 +53,10 @@ const vendorConfigSchema = z.object({
|
||||
"audioReference",
|
||||
"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()]),
|
||||
durationResolutionMap: z.array(
|
||||
z.object({
|
||||
|
||||
@ -6,69 +6,6 @@ import { z } from "zod";
|
||||
import { transform } from "sucrase";
|
||||
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(
|
||||
"/",
|
||||
validateFields({
|
||||
@ -89,14 +26,14 @@ export default router.post(
|
||||
name: z.string(),
|
||||
modelName: z.string(),
|
||||
type: z.literal("text"),
|
||||
multimodal: z.boolean(),
|
||||
tool: z.boolean(),
|
||||
think: z.boolean(),
|
||||
}),
|
||||
z.object({
|
||||
name: z.string(),
|
||||
modelName: z.string(),
|
||||
type: z.literal("image"),
|
||||
mode: z.array(z.enum(["text", "singleImage", "multiReference"])),
|
||||
associationSkills: z.string().optional(),
|
||||
}),
|
||||
z.object({
|
||||
name: z.string(),
|
||||
@ -104,10 +41,11 @@ export default router.post(
|
||||
type: z.literal("video"),
|
||||
mode: z.array(
|
||||
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"])),
|
||||
]),
|
||||
),
|
||||
associationSkills: z.string().optional(),
|
||||
audio: z.union([z.literal("optional"), z.boolean()]),
|
||||
durationResolutionMap: z.array(
|
||||
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 {
|
||||
'content': string;
|
||||
'createTime': number;
|
||||
'embedding'?: string | null;
|
||||
'id'?: string;
|
||||
'isolationKey': string;
|
||||
'name'?: string | null;
|
||||
'relatedMessageIds'?: string | null;
|
||||
'role'?: string | null;
|
||||
'summarized'?: number | null;
|
||||
@ -96,6 +47,7 @@ export interface o_assets {
|
||||
'name'?: string | null;
|
||||
'projectId'?: number | null;
|
||||
'prompt'?: string | null;
|
||||
'promptState'?: string | null;
|
||||
'remark'?: string | null;
|
||||
'scriptId'?: number | null;
|
||||
'startTime'?: number | null;
|
||||
@ -177,6 +129,8 @@ export interface o_prompt {
|
||||
export interface o_script {
|
||||
'content'?: string | null;
|
||||
'createTime'?: number | null;
|
||||
'errorReason'?: string | null;
|
||||
'extractState'?: number | null;
|
||||
'id'?: number;
|
||||
'name'?: string | null;
|
||||
'projectId'?: number | null;
|
||||
@ -213,7 +167,7 @@ export interface o_storyboard {
|
||||
'filePath'?: string | null;
|
||||
'frameMode'?: string | null;
|
||||
'id'?: number;
|
||||
'index'?: string | null;
|
||||
'index'?: number | null;
|
||||
'lines'?: string | null;
|
||||
'mode'?: string | null;
|
||||
'model'?: string | null;
|
||||
@ -224,7 +178,6 @@ export interface o_storyboard {
|
||||
'sound'?: string | null;
|
||||
'state'?: string | null;
|
||||
'title'?: string | null;
|
||||
'videoPrompt'?: string | null;
|
||||
}
|
||||
export interface o_tasks {
|
||||
'describe'?: string | null;
|
||||
@ -279,9 +232,6 @@ export interface o_videoConfig {
|
||||
}
|
||||
|
||||
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;
|
||||
"o_agentDeploy": o_agentDeploy;
|
||||
"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);
|
||||
if (!selectedModel) throw new Error(`未找到模型 ${name} id=${id}`);
|
||||
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 (fnName == "textRequest") return fn(selectedModel);
|
||||
else return <T>(input: T) => fn(input, selectedModel);
|
||||
if (fnName == "textRequest") {
|
||||
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>(
|
||||
|
||||
@ -11,33 +11,39 @@ import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
||||
import { createXai } from "@ai-sdk/xai";
|
||||
import { createMinimax } from "vercel-minimax-ai-provider";
|
||||
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 sandbox: Record<string, any> = {
|
||||
createOpenAI,
|
||||
createDeepSeek,
|
||||
createZhipu,
|
||||
createQwen,
|
||||
createAnthropic,
|
||||
createOpenAICompatible,
|
||||
createXai,
|
||||
createMinimax,
|
||||
createGoogleGenerativeAI,
|
||||
zipImage,
|
||||
zipImageResolution,
|
||||
urlToBase64,
|
||||
mergeImages,
|
||||
pollTask,
|
||||
fetch,
|
||||
exports,
|
||||
axios,
|
||||
FormData,
|
||||
logger,
|
||||
jsonwebtoken,
|
||||
};
|
||||
if (vendor !== undefined) {
|
||||
sandbox.vendor = vendor;
|
||||
}
|
||||
const vm = new VM({
|
||||
timeout: 0,
|
||||
sandbox: {
|
||||
createOpenAI,
|
||||
createDeepSeek,
|
||||
createZhipu,
|
||||
createQwen,
|
||||
createAnthropic,
|
||||
createOpenAICompatible,
|
||||
createXai,
|
||||
createMinimax,
|
||||
createGoogleGenerativeAI,
|
||||
zipImage,
|
||||
zipImageResolution,
|
||||
urlToBase64,
|
||||
mergeImages,
|
||||
pollTask,
|
||||
fetch,
|
||||
exports,
|
||||
axios,
|
||||
FormData,
|
||||
logger,
|
||||
},
|
||||
sandbox,
|
||||
compiler: "javascript",
|
||||
eval: false,
|
||||
wasm: false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user