@blocklet/pages-kit-agents 0.5.47 → 0.5.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.local.example +7 -0
- package/cli.ts +1 -1
- package/index.ts +0 -1
- package/lib/cjs/agents/content-reviwer.d.ts +1 -1
- package/lib/cjs/agents/multi-agent-page-writer.js +3 -10
- package/lib/cjs/agents/orchestrator/index.d.ts +115 -0
- package/lib/cjs/agents/orchestrator/index.js +264 -0
- package/lib/cjs/agents/orchestrator/orchestrator-prompts.d.ts +130 -0
- package/lib/cjs/agents/orchestrator/orchestrator-prompts.js +135 -0
- package/lib/cjs/agents/page-metadata-generator.d.ts +1 -1
- package/lib/cjs/agents/page-metadata-generator.js +4 -1
- package/lib/cjs/agents/page-structure-planner.d.ts +59 -22
- package/lib/cjs/agents/page-structure-planner.js +108 -78
- package/lib/cjs/agents/router-datacache-generator.d.ts +24 -0
- package/lib/cjs/agents/router-datacache-generator.js +78 -0
- package/lib/cjs/agents/section-content-generator.js +11 -8
- package/lib/cjs/agents/template-designer.d.ts +7 -6
- package/lib/cjs/agents/template-designer.js +22 -17
- package/lib/cjs/agents/template-generator.d.ts +55 -7
- package/lib/cjs/agents/template-generator.js +99 -89
- package/lib/cjs/index.d.ts +0 -1
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/prompts/fs-memory-recorder.md +59 -0
- package/lib/cjs/prompts/fs-memory-retriever.md +30 -0
- package/lib/cjs/prompts/html-generator.md +91 -0
- package/lib/cjs/prompts/page-structure-planner-prompt.md +47 -0
- package/lib/cjs/prompts/page-structure-validator-prompt.md +78 -0
- package/lib/cjs/prompts/pages-kit-template-rule.md +491 -0
- package/lib/cjs/prompts/site-map-generator.md +126 -0
- package/lib/cjs/skill-agents/parse-component-list-agent.d.ts +100 -0
- package/lib/cjs/skill-agents/parse-component-list-agent.js +198 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/agent-utils.d.ts +4 -0
- package/lib/cjs/utils/agent-utils.js +106 -0
- package/lib/esm/agents/content-reviwer.d.ts +1 -1
- package/lib/esm/agents/multi-agent-page-writer.js +5 -12
- package/lib/esm/agents/orchestrator/index.d.ts +115 -0
- package/lib/esm/agents/orchestrator/index.js +243 -0
- package/lib/esm/agents/orchestrator/orchestrator-prompts.d.ts +130 -0
- package/lib/esm/agents/orchestrator/orchestrator-prompts.js +131 -0
- package/lib/esm/agents/page-metadata-generator.d.ts +1 -1
- package/lib/esm/agents/page-metadata-generator.js +4 -1
- package/lib/esm/agents/page-structure-planner.d.ts +59 -22
- package/lib/esm/agents/page-structure-planner.js +105 -78
- package/lib/esm/agents/router-datacache-generator.d.ts +24 -0
- package/lib/esm/agents/router-datacache-generator.js +72 -0
- package/lib/esm/agents/section-content-generator.js +11 -8
- package/lib/esm/agents/template-designer.d.ts +7 -6
- package/lib/esm/agents/template-designer.js +22 -14
- package/lib/esm/agents/template-generator.d.ts +55 -7
- package/lib/esm/agents/template-generator.js +98 -88
- package/lib/esm/index.d.ts +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/prompts/fs-memory-recorder.md +59 -0
- package/lib/esm/prompts/fs-memory-retriever.md +30 -0
- package/lib/esm/prompts/html-generator.md +91 -0
- package/lib/esm/prompts/page-structure-planner-prompt.md +47 -0
- package/lib/esm/prompts/page-structure-validator-prompt.md +78 -0
- package/lib/esm/prompts/pages-kit-template-rule.md +491 -0
- package/lib/esm/prompts/site-map-generator.md +126 -0
- package/lib/esm/skill-agents/parse-component-list-agent.d.ts +100 -0
- package/lib/esm/skill-agents/parse-component-list-agent.js +192 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/agent-utils.d.ts +4 -0
- package/lib/esm/utils/agent-utils.js +105 -0
- package/lib/types/agents/content-reviwer.d.ts +1 -1
- package/lib/types/agents/orchestrator/index.d.ts +115 -0
- package/lib/types/agents/orchestrator/orchestrator-prompts.d.ts +130 -0
- package/lib/types/agents/page-metadata-generator.d.ts +1 -1
- package/lib/types/agents/page-structure-planner.d.ts +59 -22
- package/lib/types/agents/router-datacache-generator.d.ts +24 -0
- package/lib/types/agents/template-designer.d.ts +7 -6
- package/lib/types/agents/template-generator.d.ts +55 -7
- package/lib/types/index.d.ts +0 -1
- package/lib/types/skill-agents/parse-component-list-agent.d.ts +100 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/agent-utils.d.ts +4 -0
- package/package.json +8 -3
- package/workflow-cli.ts +61 -41
- package/lib/cjs/agents/page-structure-validator.d.ts +0 -30
- package/lib/cjs/agents/page-structure-validator.js +0 -124
- package/lib/esm/agents/page-structure-validator.d.ts +0 -30
- package/lib/esm/agents/page-structure-validator.js +0 -121
- package/lib/types/agents/page-structure-validator.d.ts +0 -30
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { FSMemory, FSMemoryOptions } from '@aigne/agent-library/fs-memory/index.js';
|
|
1
2
|
import { AnthropicChatModel } from '@aigne/anthropic';
|
|
2
3
|
import { OpenAIChatModel } from '@aigne/openai';
|
|
3
4
|
export declare function getModel(modelName?: string): OpenAIChatModel | AnthropicChatModel | undefined;
|
|
5
|
+
export declare function getMemory({ projectId, ...rest }: Pick<FSMemoryOptions, 'autoUpdate'> & {
|
|
6
|
+
projectId?: string;
|
|
7
|
+
}): FSMemory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/pages-kit-agents",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.48",
|
|
4
4
|
"description": "AIGNE based agents for pages kit",
|
|
5
5
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
6
6
|
"homepage": "https://github.com/blocklet/pages-kit#readme",
|
|
@@ -32,22 +32,27 @@
|
|
|
32
32
|
"@aigne/xai": "^0.2.7",
|
|
33
33
|
"@types/js-yaml": "^4.0.9",
|
|
34
34
|
"@types/yargs": "^17.0.33",
|
|
35
|
+
"fastq": "^1.19.1",
|
|
35
36
|
"inquirer": "^12.5.2",
|
|
36
37
|
"js-yaml": "^4.1.0",
|
|
37
38
|
"open": "^10.1.2",
|
|
38
39
|
"yargs": "^17.7.2",
|
|
39
40
|
"zod": "^3.24.2",
|
|
40
|
-
"@blocklet/pages-kit-block-studio": "0.5.
|
|
41
|
+
"@blocklet/pages-kit-block-studio": "0.5.48"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"copyfiles": "^2.4.1"
|
|
41
45
|
},
|
|
42
46
|
"scripts": {
|
|
43
47
|
"start": "npx -y bun run cli.ts",
|
|
44
48
|
"workflow": "npx -y bun run workflow-cli.ts",
|
|
45
49
|
"lint": "eslint --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
46
50
|
"lint:fix": "npm run lint -- --fix",
|
|
47
|
-
"build": "run-
|
|
51
|
+
"build": "run-s build:* copy-prompts",
|
|
48
52
|
"build:cjs": "tsc --module commonjs --outDir lib/cjs",
|
|
49
53
|
"build:esm": "tsc --module es2022 --outDir lib/esm",
|
|
50
54
|
"build:types": "tsc --declaration --emitDeclarationOnly --outDir lib/types",
|
|
55
|
+
"copy-prompts": "copyfiles \"prompts/**/*\" lib/cjs/ && copyfiles \"prompts/**/*\" lib/esm/",
|
|
51
56
|
"dev": "run-p 'build:* -- -w'",
|
|
52
57
|
"clean": "rimraf lib"
|
|
53
58
|
}
|
package/workflow-cli.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { AIGNE
|
|
1
|
+
import { AIGNE } from '@aigne/core';
|
|
2
2
|
import { logger as aigneLogger, LogLevel } from '@aigne/core/utils/logger.js';
|
|
3
3
|
import yaml from 'js-yaml';
|
|
4
4
|
import fs from 'node:fs/promises';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { generatorAgentWithReflection, saveYamlAgent } from './agents/template-generator.js';
|
|
10
|
-
import { readFileByPath } from './utils/file-utils.js';
|
|
8
|
+
// import { OrchestratorAgent } from './agents/orchestrator/index.js';
|
|
11
9
|
import { getModel } from './utils/index.js';
|
|
12
10
|
import { logger } from './utils/logger.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { parseDataSourcesAgent } from './workflow-agents/parse-datasources.js';
|
|
16
|
-
import { UserFeedbackAgent } from './workflow-agents/user-feedback-agent.js';
|
|
11
|
+
// import { siteHtmlBatchGeneratorAgent } from './workflow-agents/site-html-batch-generator-agent.js';
|
|
12
|
+
import { siteMapGeneratorAgent } from './workflow-agents/site-map-generator.js';
|
|
17
13
|
|
|
18
14
|
aigneLogger.level = LogLevel.DEBUG;
|
|
19
15
|
|
|
20
16
|
const DEFAULT_LOCALE = 'zh';
|
|
21
|
-
const DEFAULT_MODEL_NAME = 'gpt-4o';
|
|
17
|
+
const DEFAULT_MODEL_NAME = 'gpt-4o-mini';
|
|
22
18
|
const DEFAULT_PROJECT_ID = 'DEFAULT_PROJECT_ID';
|
|
23
19
|
|
|
24
20
|
const ConfigSchema = z.object({
|
|
@@ -26,6 +22,7 @@ const ConfigSchema = z.object({
|
|
|
26
22
|
locale: z.string(),
|
|
27
23
|
modelName: z.string(),
|
|
28
24
|
projectId: z.string(),
|
|
25
|
+
question: z.string(),
|
|
29
26
|
});
|
|
30
27
|
|
|
31
28
|
type WorkflowConfig = z.infer<typeof ConfigSchema>;
|
|
@@ -47,11 +44,13 @@ async function runWorkflow({
|
|
|
47
44
|
locale,
|
|
48
45
|
modelName,
|
|
49
46
|
projectId,
|
|
47
|
+
question,
|
|
50
48
|
}: {
|
|
51
49
|
inputInfo: string;
|
|
52
50
|
locale: string;
|
|
53
51
|
modelName: string;
|
|
54
52
|
projectId: string;
|
|
53
|
+
question: string;
|
|
55
54
|
}) {
|
|
56
55
|
logger.info('inputInfo', inputInfo);
|
|
57
56
|
logger.info('locale', locale);
|
|
@@ -63,36 +62,58 @@ async function runWorkflow({
|
|
|
63
62
|
model,
|
|
64
63
|
});
|
|
65
64
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
65
|
+
// const agent = OrchestratorAgent.from({
|
|
66
|
+
// skills: [siteMapGeneratorAgent, siteHtmlBatchGeneratorAgent],
|
|
67
|
+
// maxIterations: 3,
|
|
68
|
+
// tasksConcurrency: 1,
|
|
69
|
+
// chainStepResults: true,
|
|
70
|
+
// });
|
|
71
|
+
|
|
72
|
+
// const result = await engine.invoke(
|
|
73
|
+
// agent,
|
|
74
|
+
// `请根据用户的提问,分析用户希望创建的站点的主题,生成这个主题相关的 SiteMap。
|
|
75
|
+
// 然后遍历这些页面,生成每个页面的 HTML 内容。
|
|
76
|
+
|
|
77
|
+
// 用户的问题是:${question}
|
|
78
|
+
// 用户希望创建的站点的语言是:${locale}
|
|
79
|
+
// 用户希望创建的站点的项目ID是:${projectId}
|
|
80
|
+
// `
|
|
81
|
+
// );
|
|
82
|
+
|
|
83
|
+
// const teamAgent = TeamAgent.from({
|
|
84
|
+
// name: 'generate web site',
|
|
85
|
+
// inputSchema: z.object({
|
|
86
|
+
// question: z.string(),
|
|
87
|
+
// locale: z.string(),
|
|
88
|
+
// projectId: z.string(),
|
|
89
|
+
// }),
|
|
90
|
+
// mode: ProcessMode.sequential,
|
|
91
|
+
// skills: [siteMapGeneratorAgent],
|
|
92
|
+
// });
|
|
93
|
+
|
|
94
|
+
const stream = await engine.invoke(
|
|
95
|
+
siteMapGeneratorAgent,
|
|
96
|
+
{
|
|
97
|
+
question,
|
|
98
|
+
locale,
|
|
99
|
+
projectId,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
streaming: true,
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
let response = '';
|
|
107
|
+
process.stdout.write('\n');
|
|
108
|
+
for await (const chunk of stream) {
|
|
109
|
+
if (chunk?.delta?.text?.$message) {
|
|
110
|
+
response += chunk.delta.text.$message;
|
|
111
|
+
process.stdout.write(chunk.delta.text.$message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
process.stdout.write('\n\n');
|
|
94
115
|
|
|
95
|
-
logger.info('result',
|
|
116
|
+
logger.info('result', response);
|
|
96
117
|
}
|
|
97
118
|
|
|
98
119
|
// 主函数
|
|
@@ -100,14 +121,13 @@ async function main() {
|
|
|
100
121
|
try {
|
|
101
122
|
logger.info('🔧 读取 workflow-config.yaml 配置...');
|
|
102
123
|
const config = await loadConfig();
|
|
103
|
-
logger.info('📚 读取原始信息...');
|
|
104
|
-
const inputInfo = await readFileByPath(config.inputInfoPath);
|
|
105
124
|
|
|
106
125
|
await runWorkflow({
|
|
107
|
-
inputInfo,
|
|
126
|
+
inputInfo: '',
|
|
108
127
|
locale: config.locale || DEFAULT_LOCALE,
|
|
109
128
|
modelName: config.modelName || DEFAULT_MODEL_NAME,
|
|
110
129
|
projectId: config.projectId || DEFAULT_PROJECT_ID,
|
|
130
|
+
question: config.question,
|
|
111
131
|
});
|
|
112
132
|
} catch (error) {
|
|
113
133
|
logger.error(`工作流执行失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AIAgent } from '@aigne/core';
|
|
2
|
-
export interface ValidatePageStructureInput {
|
|
3
|
-
context: string;
|
|
4
|
-
structurePlan: Array<{
|
|
5
|
-
sectionName: string;
|
|
6
|
-
sectionContentPlan: string;
|
|
7
|
-
}>;
|
|
8
|
-
expectedSections: string;
|
|
9
|
-
outputSchema: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const pageStructureValidatorAgent: AIAgent<{
|
|
12
|
-
context: string;
|
|
13
|
-
question: string;
|
|
14
|
-
outputSchema: string;
|
|
15
|
-
expectedSections: string;
|
|
16
|
-
structurePlan: {
|
|
17
|
-
sectionName: string;
|
|
18
|
-
sectionContentPlan: string;
|
|
19
|
-
}[];
|
|
20
|
-
}, {
|
|
21
|
-
validationFeedback: {
|
|
22
|
-
isValid: boolean;
|
|
23
|
-
missingSections: string[];
|
|
24
|
-
duplicateContent: {
|
|
25
|
-
description: string;
|
|
26
|
-
sections: string[];
|
|
27
|
-
score: number;
|
|
28
|
-
}[];
|
|
29
|
-
};
|
|
30
|
-
}>;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pageStructureValidatorAgent = void 0;
|
|
4
|
-
const core_1 = require("@aigne/core");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const logger_js_1 = require("../utils/logger.js");
|
|
7
|
-
/**
|
|
8
|
-
* 验证页面结构规划
|
|
9
|
-
* 检查是否包含所有必要section,以及是否存在信息重复
|
|
10
|
-
*/
|
|
11
|
-
const prompt = `您是一名页面结构规划审核专家,擅长分析内容规划的完整性和有效性。
|
|
12
|
-
|
|
13
|
-
您的职责
|
|
14
|
-
1. 检查页面结构规划是否涵盖了所有必要的section
|
|
15
|
-
2. 分析各section内容规划之间是否存在内容重复
|
|
16
|
-
3. 确保内容规划与section描述相符
|
|
17
|
-
4. 提出需要改进的具体方向
|
|
18
|
-
|
|
19
|
-
## 输入上下文:
|
|
20
|
-
{{context}}
|
|
21
|
-
|
|
22
|
-
## 用户指令:
|
|
23
|
-
{{question}}
|
|
24
|
-
|
|
25
|
-
## 初始结构规划
|
|
26
|
-
{{initialStructurePlan}}
|
|
27
|
-
|
|
28
|
-
## 页面结构规划
|
|
29
|
-
{{structurePlan}}
|
|
30
|
-
|
|
31
|
-
## 预期包含的Sections
|
|
32
|
-
{{expectedSections}}
|
|
33
|
-
|
|
34
|
-
## 输出模式(包含section描述)
|
|
35
|
-
{{outputSchema}}
|
|
36
|
-
|
|
37
|
-
请按照以下流程工作:
|
|
38
|
-
1. 缺失项检查:检查是否所有预期 section 都在结构规划中出现,若缺失,请列出具体缺失项
|
|
39
|
-
2. 重复项检查(请严格遵循以下判断标准):
|
|
40
|
-
仅当同时满足以下所有条件时,才应将两个 section 判定为重复:
|
|
41
|
-
|
|
42
|
-
- 两个 section 中的信息核心完全一致,所讲述的功能点在语义上为同一项;
|
|
43
|
-
- 内容的细节程度相近,未体现出明显的层级差异(如简要 vs. 深度展开);
|
|
44
|
-
- 两者目的用途相同(例如都是介绍某个功能,而不是一个概览一个详细讲解);
|
|
45
|
-
- 信息之间缺乏新增认知价值或应用角度。
|
|
46
|
-
|
|
47
|
-
否则,即使关键词或主题类似,也不应判定为重复。
|
|
48
|
-
|
|
49
|
-
- 以下情况 **不构成重复**,请避免误判:
|
|
50
|
-
2.1 Section A 是简要罗列某些信息,Section B 对该信息进行详细展开;
|
|
51
|
-
2.2 两个 section 提及了相同的信息,但该信息在两个 section 中都不是核心内容;
|
|
52
|
-
2.3 两个 section 使用了相同的信息或关键词,但服务于不同的核心功能或描述重点。
|
|
53
|
-
|
|
54
|
-
【重复示例】
|
|
55
|
-
- Section A: 简要展示 5 个工作流特性(并发、顺序、路由等)
|
|
56
|
-
- Section B: 逐一讲解这 5 个工作流的结构与代码
|
|
57
|
-
→ 非重复(简要 vs. 详细)
|
|
58
|
-
|
|
59
|
-
- Section A: 展示并发、顺序、路由工作流的用法
|
|
60
|
-
- Section B: 以不同方式再次展示这 3 个相同工作流及其用途
|
|
61
|
-
→ 可判定为重复(内容本质一致)
|
|
62
|
-
|
|
63
|
-
特别注意:
|
|
64
|
-
- 如 FeatureList 是特性的简要展示,而 FeatureDetailSection 是详细介绍该特性的实际应用场景,这种搭配为常见的“概览 + 深度讲解”模式,**属于结构合理、信息递进,不应视为重复**。
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
3. 检查上下文中主要的信息在规划中是否有缺失
|
|
68
|
-
4. 检查section规划是否与section描述(如果有)相符
|
|
69
|
-
5. 如果 section 中包含列表数据,检查描述中是否指定具体的数量,指定的数量是否尽可能包含了上下文中所有相关数据。
|
|
70
|
-
6. 如果初始结构规划中包含的section,请根据初始结构规划中的内容规划,保持初始结构规划中的内容规划。
|
|
71
|
-
|
|
72
|
-
请注意,您的职责是审核和提供反馈,而不是重写或修改结构规划。`;
|
|
73
|
-
logger_js_1.logger.info('page structure validator prompt', prompt);
|
|
74
|
-
exports.pageStructureValidatorAgent = core_1.AIAgent.from({
|
|
75
|
-
name: 'Page Structure Validator',
|
|
76
|
-
subscribeTopic: 'validation_request',
|
|
77
|
-
publishTopic: (output) => {
|
|
78
|
-
logger_js_1.logger.info('page structure validator feedback', JSON.stringify(output.validationFeedback));
|
|
79
|
-
const isInvalid = output.validationFeedback.missingSections?.length > 0 ||
|
|
80
|
-
(output.validationFeedback.duplicateContent?.length > 0 &&
|
|
81
|
-
output.validationFeedback.duplicateContent.some((item) => item.score > 75));
|
|
82
|
-
return isInvalid ? 'revision_request' : core_1.UserOutputTopic;
|
|
83
|
-
},
|
|
84
|
-
instructions: prompt,
|
|
85
|
-
inputSchema: zod_1.z.object({
|
|
86
|
-
structurePlan: zod_1.z.array(zod_1.z.object({
|
|
87
|
-
sectionName: zod_1.z.string(),
|
|
88
|
-
sectionContentPlan: zod_1.z.string(),
|
|
89
|
-
})),
|
|
90
|
-
expectedSections: zod_1.z.string(),
|
|
91
|
-
outputSchema: zod_1.z.string(),
|
|
92
|
-
context: zod_1.z.string(),
|
|
93
|
-
question: zod_1.z.string(),
|
|
94
|
-
}),
|
|
95
|
-
outputSchema: zod_1.z.object({
|
|
96
|
-
validationFeedback: zod_1.z.object({
|
|
97
|
-
isValid: zod_1.z.boolean().describe(`
|
|
98
|
-
当出现下面两种场景的时候返回 false:
|
|
99
|
-
1. 存在严重重复的内容,duplicateContent 中存在重复内容得分大于 75 的场景
|
|
100
|
-
2. 缺失了重要的 section,missingSections 中存在缺失的 section
|
|
101
|
-
|
|
102
|
-
请特别注意:
|
|
103
|
-
- 仅当重复评分超过 75 且符合所有重复标准时,才可将 isValid 设为 false。
|
|
104
|
-
|
|
105
|
-
其他场景都返回 true
|
|
106
|
-
`),
|
|
107
|
-
missingSections: zod_1.z.array(zod_1.z.string()).describe('缺失的section列表'),
|
|
108
|
-
duplicateContent: zod_1.z
|
|
109
|
-
.array(zod_1.z.object({
|
|
110
|
-
sections: zod_1.z.array(zod_1.z.string()).describe('存在内容重复的section列表'),
|
|
111
|
-
description: zod_1.z.string().describe('内容重复的描述'),
|
|
112
|
-
score: zod_1.z.number().describe(`
|
|
113
|
-
【重复判断参考评分】
|
|
114
|
-
0~30:结构或信息逻辑相近,但内容展开和聚焦点完全不同
|
|
115
|
-
31~60:存在信息重合,但表达方式和内容深度有明显差异
|
|
116
|
-
61~75:较大信息重叠但结构差异仍存在(注意此时仍不算“严重重复”)
|
|
117
|
-
76~100:表达几乎一致,属于严重重复内容
|
|
118
|
-
`),
|
|
119
|
-
}))
|
|
120
|
-
.describe('存在内容重复的section组'),
|
|
121
|
-
}),
|
|
122
|
-
}),
|
|
123
|
-
includeInputInOutput: true,
|
|
124
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AIAgent } from '@aigne/core';
|
|
2
|
-
export interface ValidatePageStructureInput {
|
|
3
|
-
context: string;
|
|
4
|
-
structurePlan: Array<{
|
|
5
|
-
sectionName: string;
|
|
6
|
-
sectionContentPlan: string;
|
|
7
|
-
}>;
|
|
8
|
-
expectedSections: string;
|
|
9
|
-
outputSchema: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const pageStructureValidatorAgent: AIAgent<{
|
|
12
|
-
context: string;
|
|
13
|
-
question: string;
|
|
14
|
-
outputSchema: string;
|
|
15
|
-
expectedSections: string;
|
|
16
|
-
structurePlan: {
|
|
17
|
-
sectionName: string;
|
|
18
|
-
sectionContentPlan: string;
|
|
19
|
-
}[];
|
|
20
|
-
}, {
|
|
21
|
-
validationFeedback: {
|
|
22
|
-
isValid: boolean;
|
|
23
|
-
missingSections: string[];
|
|
24
|
-
duplicateContent: {
|
|
25
|
-
description: string;
|
|
26
|
-
sections: string[];
|
|
27
|
-
score: number;
|
|
28
|
-
}[];
|
|
29
|
-
};
|
|
30
|
-
}>;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { AIAgent, UserOutputTopic } from '@aigne/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { logger } from '../utils/logger.js';
|
|
4
|
-
/**
|
|
5
|
-
* 验证页面结构规划
|
|
6
|
-
* 检查是否包含所有必要section,以及是否存在信息重复
|
|
7
|
-
*/
|
|
8
|
-
const prompt = `您是一名页面结构规划审核专家,擅长分析内容规划的完整性和有效性。
|
|
9
|
-
|
|
10
|
-
您的职责
|
|
11
|
-
1. 检查页面结构规划是否涵盖了所有必要的section
|
|
12
|
-
2. 分析各section内容规划之间是否存在内容重复
|
|
13
|
-
3. 确保内容规划与section描述相符
|
|
14
|
-
4. 提出需要改进的具体方向
|
|
15
|
-
|
|
16
|
-
## 输入上下文:
|
|
17
|
-
{{context}}
|
|
18
|
-
|
|
19
|
-
## 用户指令:
|
|
20
|
-
{{question}}
|
|
21
|
-
|
|
22
|
-
## 初始结构规划
|
|
23
|
-
{{initialStructurePlan}}
|
|
24
|
-
|
|
25
|
-
## 页面结构规划
|
|
26
|
-
{{structurePlan}}
|
|
27
|
-
|
|
28
|
-
## 预期包含的Sections
|
|
29
|
-
{{expectedSections}}
|
|
30
|
-
|
|
31
|
-
## 输出模式(包含section描述)
|
|
32
|
-
{{outputSchema}}
|
|
33
|
-
|
|
34
|
-
请按照以下流程工作:
|
|
35
|
-
1. 缺失项检查:检查是否所有预期 section 都在结构规划中出现,若缺失,请列出具体缺失项
|
|
36
|
-
2. 重复项检查(请严格遵循以下判断标准):
|
|
37
|
-
仅当同时满足以下所有条件时,才应将两个 section 判定为重复:
|
|
38
|
-
|
|
39
|
-
- 两个 section 中的信息核心完全一致,所讲述的功能点在语义上为同一项;
|
|
40
|
-
- 内容的细节程度相近,未体现出明显的层级差异(如简要 vs. 深度展开);
|
|
41
|
-
- 两者目的用途相同(例如都是介绍某个功能,而不是一个概览一个详细讲解);
|
|
42
|
-
- 信息之间缺乏新增认知价值或应用角度。
|
|
43
|
-
|
|
44
|
-
否则,即使关键词或主题类似,也不应判定为重复。
|
|
45
|
-
|
|
46
|
-
- 以下情况 **不构成重复**,请避免误判:
|
|
47
|
-
2.1 Section A 是简要罗列某些信息,Section B 对该信息进行详细展开;
|
|
48
|
-
2.2 两个 section 提及了相同的信息,但该信息在两个 section 中都不是核心内容;
|
|
49
|
-
2.3 两个 section 使用了相同的信息或关键词,但服务于不同的核心功能或描述重点。
|
|
50
|
-
|
|
51
|
-
【重复示例】
|
|
52
|
-
- Section A: 简要展示 5 个工作流特性(并发、顺序、路由等)
|
|
53
|
-
- Section B: 逐一讲解这 5 个工作流的结构与代码
|
|
54
|
-
→ 非重复(简要 vs. 详细)
|
|
55
|
-
|
|
56
|
-
- Section A: 展示并发、顺序、路由工作流的用法
|
|
57
|
-
- Section B: 以不同方式再次展示这 3 个相同工作流及其用途
|
|
58
|
-
→ 可判定为重复(内容本质一致)
|
|
59
|
-
|
|
60
|
-
特别注意:
|
|
61
|
-
- 如 FeatureList 是特性的简要展示,而 FeatureDetailSection 是详细介绍该特性的实际应用场景,这种搭配为常见的“概览 + 深度讲解”模式,**属于结构合理、信息递进,不应视为重复**。
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
3. 检查上下文中主要的信息在规划中是否有缺失
|
|
65
|
-
4. 检查section规划是否与section描述(如果有)相符
|
|
66
|
-
5. 如果 section 中包含列表数据,检查描述中是否指定具体的数量,指定的数量是否尽可能包含了上下文中所有相关数据。
|
|
67
|
-
6. 如果初始结构规划中包含的section,请根据初始结构规划中的内容规划,保持初始结构规划中的内容规划。
|
|
68
|
-
|
|
69
|
-
请注意,您的职责是审核和提供反馈,而不是重写或修改结构规划。`;
|
|
70
|
-
logger.info('page structure validator prompt', prompt);
|
|
71
|
-
export const pageStructureValidatorAgent = AIAgent.from({
|
|
72
|
-
name: 'Page Structure Validator',
|
|
73
|
-
subscribeTopic: 'validation_request',
|
|
74
|
-
publishTopic: (output) => {
|
|
75
|
-
logger.info('page structure validator feedback', JSON.stringify(output.validationFeedback));
|
|
76
|
-
const isInvalid = output.validationFeedback.missingSections?.length > 0 ||
|
|
77
|
-
(output.validationFeedback.duplicateContent?.length > 0 &&
|
|
78
|
-
output.validationFeedback.duplicateContent.some((item) => item.score > 75));
|
|
79
|
-
return isInvalid ? 'revision_request' : UserOutputTopic;
|
|
80
|
-
},
|
|
81
|
-
instructions: prompt,
|
|
82
|
-
inputSchema: z.object({
|
|
83
|
-
structurePlan: z.array(z.object({
|
|
84
|
-
sectionName: z.string(),
|
|
85
|
-
sectionContentPlan: z.string(),
|
|
86
|
-
})),
|
|
87
|
-
expectedSections: z.string(),
|
|
88
|
-
outputSchema: z.string(),
|
|
89
|
-
context: z.string(),
|
|
90
|
-
question: z.string(),
|
|
91
|
-
}),
|
|
92
|
-
outputSchema: z.object({
|
|
93
|
-
validationFeedback: z.object({
|
|
94
|
-
isValid: z.boolean().describe(`
|
|
95
|
-
当出现下面两种场景的时候返回 false:
|
|
96
|
-
1. 存在严重重复的内容,duplicateContent 中存在重复内容得分大于 75 的场景
|
|
97
|
-
2. 缺失了重要的 section,missingSections 中存在缺失的 section
|
|
98
|
-
|
|
99
|
-
请特别注意:
|
|
100
|
-
- 仅当重复评分超过 75 且符合所有重复标准时,才可将 isValid 设为 false。
|
|
101
|
-
|
|
102
|
-
其他场景都返回 true
|
|
103
|
-
`),
|
|
104
|
-
missingSections: z.array(z.string()).describe('缺失的section列表'),
|
|
105
|
-
duplicateContent: z
|
|
106
|
-
.array(z.object({
|
|
107
|
-
sections: z.array(z.string()).describe('存在内容重复的section列表'),
|
|
108
|
-
description: z.string().describe('内容重复的描述'),
|
|
109
|
-
score: z.number().describe(`
|
|
110
|
-
【重复判断参考评分】
|
|
111
|
-
0~30:结构或信息逻辑相近,但内容展开和聚焦点完全不同
|
|
112
|
-
31~60:存在信息重合,但表达方式和内容深度有明显差异
|
|
113
|
-
61~75:较大信息重叠但结构差异仍存在(注意此时仍不算“严重重复”)
|
|
114
|
-
76~100:表达几乎一致,属于严重重复内容
|
|
115
|
-
`),
|
|
116
|
-
}))
|
|
117
|
-
.describe('存在内容重复的section组'),
|
|
118
|
-
}),
|
|
119
|
-
}),
|
|
120
|
-
includeInputInOutput: true,
|
|
121
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AIAgent } from '@aigne/core';
|
|
2
|
-
export interface ValidatePageStructureInput {
|
|
3
|
-
context: string;
|
|
4
|
-
structurePlan: Array<{
|
|
5
|
-
sectionName: string;
|
|
6
|
-
sectionContentPlan: string;
|
|
7
|
-
}>;
|
|
8
|
-
expectedSections: string;
|
|
9
|
-
outputSchema: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const pageStructureValidatorAgent: AIAgent<{
|
|
12
|
-
context: string;
|
|
13
|
-
question: string;
|
|
14
|
-
outputSchema: string;
|
|
15
|
-
expectedSections: string;
|
|
16
|
-
structurePlan: {
|
|
17
|
-
sectionName: string;
|
|
18
|
-
sectionContentPlan: string;
|
|
19
|
-
}[];
|
|
20
|
-
}, {
|
|
21
|
-
validationFeedback: {
|
|
22
|
-
isValid: boolean;
|
|
23
|
-
missingSections: string[];
|
|
24
|
-
duplicateContent: {
|
|
25
|
-
description: string;
|
|
26
|
-
sections: string[];
|
|
27
|
-
score: number;
|
|
28
|
-
}[];
|
|
29
|
-
};
|
|
30
|
-
}>;
|