@blocklet/pages-kit-agents 0.5.12
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 +8 -0
- package/LICENSE +13 -0
- package/README.md +10 -0
- package/cli.ts +354 -0
- package/index.ts +14 -0
- package/lib/cjs/agents/multi-agent-page-writer.d.ts +48 -0
- package/lib/cjs/agents/multi-agent-page-writer.js +203 -0
- package/lib/cjs/agents/page-metadata-generator.d.ts +10 -0
- package/lib/cjs/agents/page-metadata-generator.js +43 -0
- package/lib/cjs/agents/page-structure-planner.d.ts +55 -0
- package/lib/cjs/agents/page-structure-planner.js +106 -0
- package/lib/cjs/agents/page-structure-validator.d.ts +30 -0
- package/lib/cjs/agents/page-structure-validator.js +124 -0
- package/lib/cjs/agents/sample-html-generator.d.ts +6 -0
- package/lib/cjs/agents/sample-html-generator.js +35 -0
- package/lib/cjs/agents/section-content-generator.d.ts +19 -0
- package/lib/cjs/agents/section-content-generator.js +97 -0
- package/lib/cjs/index.d.ts +7 -0
- package/lib/cjs/index.js +30 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/utils/agent-utils.d.ts +3 -0
- package/lib/cjs/utils/agent-utils.js +44 -0
- package/lib/cjs/utils/file-utils.d.ts +5 -0
- package/lib/cjs/utils/file-utils.js +90 -0
- package/lib/cjs/utils/index.d.ts +12 -0
- package/lib/cjs/utils/index.js +48 -0
- package/lib/cjs/utils/logger.d.ts +1 -0
- package/lib/cjs/utils/logger.js +4 -0
- package/lib/cjs/utils/template-utils.d.ts +28 -0
- package/lib/cjs/utils/template-utils.js +74 -0
- package/lib/esm/agents/multi-agent-page-writer.d.ts +48 -0
- package/lib/esm/agents/multi-agent-page-writer.js +199 -0
- package/lib/esm/agents/page-metadata-generator.d.ts +10 -0
- package/lib/esm/agents/page-metadata-generator.js +40 -0
- package/lib/esm/agents/page-structure-planner.d.ts +55 -0
- package/lib/esm/agents/page-structure-planner.js +103 -0
- package/lib/esm/agents/page-structure-validator.d.ts +30 -0
- package/lib/esm/agents/page-structure-validator.js +121 -0
- package/lib/esm/agents/sample-html-generator.d.ts +6 -0
- package/lib/esm/agents/sample-html-generator.js +32 -0
- package/lib/esm/agents/section-content-generator.d.ts +19 -0
- package/lib/esm/agents/section-content-generator.js +94 -0
- package/lib/esm/index.d.ts +7 -0
- package/lib/esm/index.js +8 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/lib/esm/utils/agent-utils.d.ts +3 -0
- package/lib/esm/utils/agent-utils.js +38 -0
- package/lib/esm/utils/file-utils.d.ts +5 -0
- package/lib/esm/utils/file-utils.js +61 -0
- package/lib/esm/utils/index.d.ts +12 -0
- package/lib/esm/utils/index.js +28 -0
- package/lib/esm/utils/logger.d.ts +1 -0
- package/lib/esm/utils/logger.js +1 -0
- package/lib/esm/utils/template-utils.d.ts +28 -0
- package/lib/esm/utils/template-utils.js +67 -0
- package/lib/types/agents/multi-agent-page-writer.d.ts +48 -0
- package/lib/types/agents/page-metadata-generator.d.ts +10 -0
- package/lib/types/agents/page-structure-planner.d.ts +55 -0
- package/lib/types/agents/page-structure-validator.d.ts +30 -0
- package/lib/types/agents/sample-html-generator.d.ts +6 -0
- package/lib/types/agents/section-content-generator.d.ts +19 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -0
- package/lib/types/utils/agent-utils.d.ts +3 -0
- package/lib/types/utils/file-utils.d.ts +5 -0
- package/lib/types/utils/index.d.ts +12 -0
- package/lib/types/utils/logger.d.ts +1 -0
- package/lib/types/utils/template-utils.d.ts +28 -0
- package/package.json +46 -0
- package/types.d.ts +4 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePageMetadataAgent = void 0;
|
|
4
|
+
const core_1 = require("@aigne/core");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const prompt = `您是一名专业的SEO和内容编辑专家,擅长创建有吸引力和描述性强的页面元数据。
|
|
7
|
+
|
|
8
|
+
您的职责
|
|
9
|
+
1. 基于已生成的页面内容,创建准确、吸引人的页面标题
|
|
10
|
+
2. 创建简洁而信息丰富的页面描述,适合在搜索结果和社交媒体分享中显示
|
|
11
|
+
3. 确保标题和描述准确反映页面内容
|
|
12
|
+
4. 优化元数据以提高页面的SEO价值
|
|
13
|
+
|
|
14
|
+
## 输入上下文:
|
|
15
|
+
{{context}}
|
|
16
|
+
|
|
17
|
+
## 用户指令:
|
|
18
|
+
{{question}}
|
|
19
|
+
|
|
20
|
+
## 已生成的页面内容:
|
|
21
|
+
{{sectionsData}}
|
|
22
|
+
|
|
23
|
+
## 要求
|
|
24
|
+
1. 页面标题:简洁有力,准确描述页面内容,长度在5-10个词之间
|
|
25
|
+
2. 页面描述:提供页面内容的简明概述,长度不超过160个字符
|
|
26
|
+
3. 标题和描述必须基于实际生成的页面内容
|
|
27
|
+
4. 标题和描述应使用 {{locale}} 语言
|
|
28
|
+
|
|
29
|
+
请为以上页面内容生成合适的标题和描述。`;
|
|
30
|
+
exports.generatePageMetadataAgent = core_1.AIAgent.from({
|
|
31
|
+
name: 'Page Metadata Generator',
|
|
32
|
+
instructions: prompt,
|
|
33
|
+
inputSchema: zod_1.z.object({
|
|
34
|
+
context: zod_1.z.string(),
|
|
35
|
+
question: zod_1.z.string(),
|
|
36
|
+
locale: zod_1.z.string(),
|
|
37
|
+
sectionsData: zod_1.z.string(),
|
|
38
|
+
}),
|
|
39
|
+
outputSchema: zod_1.z.object({
|
|
40
|
+
title: zod_1.z.string().describe('页面标题'),
|
|
41
|
+
description: zod_1.z.string().describe('页面描述'),
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { AIAgent } from '@aigne/core';
|
|
2
|
+
export interface PlanPageStructureInput {
|
|
3
|
+
context: string;
|
|
4
|
+
question: string;
|
|
5
|
+
initialStructurePlan?: Array<{
|
|
6
|
+
sectionName: string;
|
|
7
|
+
sectionContentPlan: string;
|
|
8
|
+
}>;
|
|
9
|
+
locale: string;
|
|
10
|
+
outputSchema: any;
|
|
11
|
+
validationFeedback?: {
|
|
12
|
+
isValid: boolean;
|
|
13
|
+
missingSections: string[];
|
|
14
|
+
duplicateContent: Array<{
|
|
15
|
+
sections: string[];
|
|
16
|
+
description: string;
|
|
17
|
+
}>;
|
|
18
|
+
feedback: Array<{
|
|
19
|
+
sectionName: string;
|
|
20
|
+
feedback: string;
|
|
21
|
+
}>;
|
|
22
|
+
generalFeedback: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface PageStructurePlannerOutput {
|
|
26
|
+
structurePlan: Array<{
|
|
27
|
+
sectionName: string;
|
|
28
|
+
sectionContentPlan: string;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
export declare const pageStructurePlannerAgent: AIAgent<{
|
|
32
|
+
outputSchema: string;
|
|
33
|
+
context: string;
|
|
34
|
+
question: string;
|
|
35
|
+
locale: string;
|
|
36
|
+
expectedSections: string;
|
|
37
|
+
initialStructurePlan: {
|
|
38
|
+
sectionName: string;
|
|
39
|
+
sectionContentPlan: string;
|
|
40
|
+
}[];
|
|
41
|
+
validationFeedback?: {
|
|
42
|
+
isValid: boolean;
|
|
43
|
+
missingSections: string[];
|
|
44
|
+
duplicateContent: {
|
|
45
|
+
description: string;
|
|
46
|
+
sections: string[];
|
|
47
|
+
score: number;
|
|
48
|
+
}[];
|
|
49
|
+
} | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
structurePlan: {
|
|
52
|
+
sectionName: string;
|
|
53
|
+
sectionContentPlan: string;
|
|
54
|
+
}[];
|
|
55
|
+
}>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pageStructurePlannerAgent = 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
|
+
*/
|
|
12
|
+
const prompt = `您是一名有着丰富经验且富有创意的页面结构规划师,擅长分析并规划产品站点的内容结构。
|
|
13
|
+
|
|
14
|
+
您的职责
|
|
15
|
+
1. 分析用户提供的上下文信息,理解产品的核心功能和价值
|
|
16
|
+
2. 分析输出模式的结构,了解页面可用的各个部分(section)
|
|
17
|
+
3. 为每个section规划合适的内容方向,避免内容重复
|
|
18
|
+
4. 针对不同类型的section提供合适的内容规划
|
|
19
|
+
|
|
20
|
+
请仔细阅读以下输入信息:
|
|
21
|
+
|
|
22
|
+
## 输入上下文:
|
|
23
|
+
{{context}}
|
|
24
|
+
|
|
25
|
+
## 输出结构模式:
|
|
26
|
+
{{outputSchema}}
|
|
27
|
+
|
|
28
|
+
## 用户指令:
|
|
29
|
+
{{question}}
|
|
30
|
+
|
|
31
|
+
请注意每个section的描述信息,这将帮助您理解每个section的目的和预期内容。
|
|
32
|
+
|
|
33
|
+
请按照以下流程工作:
|
|
34
|
+
1. 首先分析上下文,理解产品的核心功能、价值主张和目标用户
|
|
35
|
+
2. 分析输出模式中的sectionsData属性,了解页面包含哪些section
|
|
36
|
+
3. 为每个section规划内容方向,确保各section内容互补而不重复
|
|
37
|
+
4. 返回一个结构化的规划,清楚说明每个section应包含的内容
|
|
38
|
+
5. 如果 Section 中包含列表数据,根据输入上下文中包含的数据,明确指定列表数据的数量,尽可能全的展示上下文中提供的相关数据。
|
|
39
|
+
6. 如果初始结构规划中包含的section,请根据初始结构规划中的内容规划,保持初始结构规划中的内容规划。
|
|
40
|
+
|
|
41
|
+
针对不同类型的section,考虑以下内容:
|
|
42
|
+
- Hero Section: 应包含产品的核心价值主张和简短描述
|
|
43
|
+
- Feature Section: 应详细说明产品的关键功能和优势
|
|
44
|
+
- FAQ Section: 应包含用户可能提出的问题和相应答案
|
|
45
|
+
- 其他section: 根据section的描述规划合适内容
|
|
46
|
+
|
|
47
|
+
## 初始结构规划
|
|
48
|
+
{{initialStructurePlan}}
|
|
49
|
+
|
|
50
|
+
## 上一轮输出的结构规划
|
|
51
|
+
{{structurePlan}}
|
|
52
|
+
|
|
53
|
+
## 缺失的Section
|
|
54
|
+
{{validationFeedback.missingSections}}
|
|
55
|
+
|
|
56
|
+
## 内容重复
|
|
57
|
+
{{validationFeedback.duplicateContent}}
|
|
58
|
+
|
|
59
|
+
请根据上述反馈修改您的结构规划方案,确保:
|
|
60
|
+
1. 包含所有必要的section
|
|
61
|
+
2. 避免不同section之间内容重复
|
|
62
|
+
3. 明确区分各section的内容方向
|
|
63
|
+
4. 遵循section描述中的要求
|
|
64
|
+
|
|
65
|
+
请为页面的每个section返回一个内容规划,格式为section名称和内容描述, 使用 {{locale}} 语言返回。
|
|
66
|
+
`;
|
|
67
|
+
logger_js_1.logger.info('page structure planner prompt', prompt);
|
|
68
|
+
exports.pageStructurePlannerAgent = core_1.AIAgent.from({
|
|
69
|
+
name: 'Page Structure Planner',
|
|
70
|
+
subscribeTopic: [core_1.UserInputTopic, 'revision_request'],
|
|
71
|
+
publishTopic: (output) => {
|
|
72
|
+
logger_js_1.logger.info('page structure planner output', JSON.stringify(output.structurePlan));
|
|
73
|
+
return 'validation_request';
|
|
74
|
+
},
|
|
75
|
+
// publishTopic: UserOutputTopic,
|
|
76
|
+
instructions: prompt,
|
|
77
|
+
inputSchema: zod_1.z.object({
|
|
78
|
+
context: zod_1.z.string(),
|
|
79
|
+
question: zod_1.z.string(),
|
|
80
|
+
locale: zod_1.z.string(),
|
|
81
|
+
outputSchema: zod_1.z.string(),
|
|
82
|
+
expectedSections: zod_1.z.string(),
|
|
83
|
+
initialStructurePlan: zod_1.z.array(zod_1.z.object({
|
|
84
|
+
sectionName: zod_1.z.string(),
|
|
85
|
+
sectionContentPlan: zod_1.z.string(),
|
|
86
|
+
})),
|
|
87
|
+
validationFeedback: zod_1.z
|
|
88
|
+
.object({
|
|
89
|
+
isValid: zod_1.z.boolean(),
|
|
90
|
+
missingSections: zod_1.z.array(zod_1.z.string()),
|
|
91
|
+
duplicateContent: zod_1.z.array(zod_1.z.object({
|
|
92
|
+
sections: zod_1.z.array(zod_1.z.string()),
|
|
93
|
+
description: zod_1.z.string(),
|
|
94
|
+
score: zod_1.z.number(),
|
|
95
|
+
})),
|
|
96
|
+
})
|
|
97
|
+
.optional(),
|
|
98
|
+
}),
|
|
99
|
+
outputSchema: zod_1.z.object({
|
|
100
|
+
structurePlan: zod_1.z.array(zod_1.z.object({
|
|
101
|
+
sectionName: zod_1.z.string(),
|
|
102
|
+
sectionContentPlan: zod_1.z.string().describe('该section的内容规划描述'),
|
|
103
|
+
})),
|
|
104
|
+
}),
|
|
105
|
+
includeInputInOutput: true,
|
|
106
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
outputSchema: string;
|
|
13
|
+
context: string;
|
|
14
|
+
question: 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
|
+
}>;
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sampleHtmlGeneratorAgent = void 0;
|
|
4
|
+
const core_1 = require("@aigne/core");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const prompt = `
|
|
7
|
+
根据下面内容生成一个 HTML 静态网页
|
|
8
|
+
1. 原样展示 json 中文案,不要做任何修改
|
|
9
|
+
2. 强调超大字体或数字突出核心要点,画面中有超大视觉元素强调重点,与小元素的比例形成反差
|
|
10
|
+
3. 简洁的勾线图形化作为数据可视化或者配图元素
|
|
11
|
+
4. 运用高亮色自身透明度渐变制造科技感,但是不同高亮色不要互相渐变
|
|
12
|
+
5. 不需要动画效果
|
|
13
|
+
6. 尽可能少的为了样式添加依赖,只是需要直观将 json 中文案通过合适的布局展示出来
|
|
14
|
+
7. 使用HTML5、TailwindCSS 3.0+(通过CDN引入)和必要的JavaScript
|
|
15
|
+
8. 使用专业图标库如Font Awesome或Material Icons(通过CDN引入)
|
|
16
|
+
9. 避免使用emoji作为主要图标
|
|
17
|
+
10. json 中的所有内容都要展示,不要有遗漏
|
|
18
|
+
11. json 中 sectionsData 对象里的每个属性,对应 html 中的一块内容
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
JSON 数据:
|
|
22
|
+
<<<
|
|
23
|
+
{{jsonData}}
|
|
24
|
+
>>>
|
|
25
|
+
`;
|
|
26
|
+
exports.sampleHtmlGeneratorAgent = core_1.AIAgent.from({
|
|
27
|
+
name: 'Sample HTML Generator',
|
|
28
|
+
instructions: prompt,
|
|
29
|
+
inputSchema: zod_1.z.object({
|
|
30
|
+
jsonData: zod_1.z.string(),
|
|
31
|
+
}),
|
|
32
|
+
outputSchema: zod_1.z.object({
|
|
33
|
+
html: zod_1.z.string(),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AIAgent } from '@aigne/core';
|
|
2
|
+
interface GenerateSectionContentInput {
|
|
3
|
+
context: string;
|
|
4
|
+
question: string;
|
|
5
|
+
locale: string;
|
|
6
|
+
sectionName: string;
|
|
7
|
+
sectionSchema: any;
|
|
8
|
+
sectionPlan: string;
|
|
9
|
+
generatedSections: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function createSectionContentAgent(input: GenerateSectionContentInput): Promise<AIAgent<{
|
|
12
|
+
context: string;
|
|
13
|
+
question: string;
|
|
14
|
+
locale: string;
|
|
15
|
+
sectionName: string;
|
|
16
|
+
sectionPlan: string;
|
|
17
|
+
generatedSections: string;
|
|
18
|
+
}, import("@aigne/core").Message>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSectionContentAgent = createSectionContentAgent;
|
|
4
|
+
const core_1 = require("@aigne/core");
|
|
5
|
+
const zod_utils_1 = require("@blocklet/pages-kit-block-studio/zod-utils");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const logger_js_1 = require("../utils/logger.js");
|
|
8
|
+
async function createSectionContentAgent(input) {
|
|
9
|
+
const prompt = `您是一名有着丰富经验且富有创意的设计师,擅长产品站点的内容创作。
|
|
10
|
+
|
|
11
|
+
您的职责
|
|
12
|
+
1. 为页面中生成高质量内容
|
|
13
|
+
2. 严格按照提供的数据格式生成内容
|
|
14
|
+
3. 保持语气、风格和术语的一致性
|
|
15
|
+
4. 生成引人入胜、信息丰富的内容
|
|
16
|
+
5. 避免与已生成的其他section内容重复
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
针对不同类型的 section,考虑以下内容:
|
|
20
|
+
|
|
21
|
+
## Hero Section
|
|
22
|
+
|
|
23
|
+
Hero Section 中的标题必须能充分描述上下文中的产品,标题应该是描述,而不是口号,让用户打开网页第一眼就知道了产品是什么,能帮助用户做什么。
|
|
24
|
+
|
|
25
|
+
HeroSection 中的描述可以包含两点信息:
|
|
26
|
+
- 我们的产品如何工作的
|
|
27
|
+
- 支撑标题中的描述,让它更可信
|
|
28
|
+
|
|
29
|
+
## Feature Section
|
|
30
|
+
|
|
31
|
+
功能的信息应该和 Hero 中的信息相关,能支撑 Hero 中描述能为用户提供的价值。
|
|
32
|
+
功能区域的标题应该是简短的价值主张,不要使用模糊的语言。
|
|
33
|
+
功能区域的描述应该简明扼要地描述该功能,并可选择解决异议(如果这些异议很重要,通常会阻止人们购买)
|
|
34
|
+
如果需要展示功能的示例代码或 flowchart 信息,请使用 markdown 格式展示,并返回 context 中完整的代码块,不要删减。
|
|
35
|
+
|
|
36
|
+
FAQ 中的问答应该包含用户常关心的问题,并给出答案,如果有相关的链接也请以 markdown 格式返回这些链接。
|
|
37
|
+
最少显示 4 个问答
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## 输入上下文:
|
|
42
|
+
{{context}}
|
|
43
|
+
|
|
44
|
+
## 用户指令:
|
|
45
|
+
{{question}}
|
|
46
|
+
|
|
47
|
+
## 当前section信息
|
|
48
|
+
Section名称: {{sectionName}}
|
|
49
|
+
Section计划: {{sectionPlan}}
|
|
50
|
+
|
|
51
|
+
注意:Section计划是对这个 section 需要展示的内容和风格的要求,您需要根据这个要求来生成面向用户,对用户阅读友好的内容,不要直接重复 section 计划中的要求。
|
|
52
|
+
|
|
53
|
+
## 数据格式要求
|
|
54
|
+
${JSON.stringify((0, zod_utils_1.zodSchemaToJsonSchema)(input.sectionSchema))}
|
|
55
|
+
|
|
56
|
+
## 已生成的其他section内容
|
|
57
|
+
{{generatedSections}}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## 内容生成要求
|
|
61
|
+
1. 仅生成当前指定section的内容
|
|
62
|
+
2. 避免与已生成的section内容重复
|
|
63
|
+
3. 内容要围绕section计划描述的主题展开
|
|
64
|
+
4. 上下文中有相关图片时返回图片链接,如果没有相关的图片不要随便使用其他图片
|
|
65
|
+
5. 如果数组类型确实没有数据,请返回空数组
|
|
66
|
+
6. 内容需符合提供的数据格式要求
|
|
67
|
+
|
|
68
|
+
## 内容质量要求
|
|
69
|
+
1. 采用清晰、有吸引力的表达方式,语言专业但不过度夸张
|
|
70
|
+
2. 使用文案技巧:价值驱动、问题导向、CTA 引导
|
|
71
|
+
3. 所有功能点请用主动语态、动词开头表达
|
|
72
|
+
4. 结合卖点与用户痛点
|
|
73
|
+
5. 文案不要太短,不少于 15 字每句,尽量细化内容亮点
|
|
74
|
+
6. 标题要简短、有吸引力,不要使用模糊的语言,在大部分屏幕中一行可以显示
|
|
75
|
+
7. 描述要简明扼要,不要使用模糊的语言,不要超过 100 个字
|
|
76
|
+
|
|
77
|
+
## output 数据要求
|
|
78
|
+
1. 上下文中有相关图片时返回图片链接,如果没有相关的图片不要随便使用其他图片,返回 undefined 即可。
|
|
79
|
+
2. 如果数组类型确实没有数据,请返回空数组。
|
|
80
|
+
|
|
81
|
+
请为 {{sectionName}} 生成符合上述要求的内容,使用 {{locale}} 语言。`;
|
|
82
|
+
logger_js_1.logger.info(`section content generator prompt for ${input.sectionName}`, prompt);
|
|
83
|
+
const agent = core_1.AIAgent.from({
|
|
84
|
+
name: 'Section Content Generator',
|
|
85
|
+
instructions: prompt,
|
|
86
|
+
inputSchema: zod_1.z.object({
|
|
87
|
+
context: zod_1.z.string(),
|
|
88
|
+
question: zod_1.z.string(),
|
|
89
|
+
locale: zod_1.z.string(),
|
|
90
|
+
sectionName: zod_1.z.string(),
|
|
91
|
+
sectionPlan: zod_1.z.string(),
|
|
92
|
+
generatedSections: zod_1.z.string(),
|
|
93
|
+
}),
|
|
94
|
+
outputSchema: input.sectionSchema,
|
|
95
|
+
});
|
|
96
|
+
return agent;
|
|
97
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
export { default as generatePageContentMultiAgent, generateSingleSectionContent, } from './agents/multi-agent-page-writer';
|
|
3
|
+
export * from './agents/page-metadata-generator';
|
|
4
|
+
export * from './agents/page-structure-planner';
|
|
5
|
+
export * from './agents/page-structure-validator';
|
|
6
|
+
export * from './agents/section-content-generator';
|
|
7
|
+
export * from './utils/index';
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.generateSingleSectionContent = exports.generatePageContentMultiAgent = void 0;
|
|
21
|
+
// Export all agents
|
|
22
|
+
var multi_agent_page_writer_1 = require("./agents/multi-agent-page-writer");
|
|
23
|
+
Object.defineProperty(exports, "generatePageContentMultiAgent", { enumerable: true, get: function () { return __importDefault(multi_agent_page_writer_1).default; } });
|
|
24
|
+
Object.defineProperty(exports, "generateSingleSectionContent", { enumerable: true, get: function () { return multi_agent_page_writer_1.generateSingleSectionContent; } });
|
|
25
|
+
__exportStar(require("./agents/page-metadata-generator"), exports);
|
|
26
|
+
__exportStar(require("./agents/page-structure-planner"), exports);
|
|
27
|
+
__exportStar(require("./agents/page-structure-validator"), exports);
|
|
28
|
+
__exportStar(require("./agents/section-content-generator"), exports);
|
|
29
|
+
// Export utilities that might be useful for consumers
|
|
30
|
+
__exportStar(require("./utils/index"), exports);
|