persona-core 1.0.0
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/dist/db/client.d.ts +55 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +157 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/index.d.ts +7 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +7 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/repositories/executionRepository.d.ts +15 -0
- package/dist/db/repositories/executionRepository.d.ts.map +1 -0
- package/dist/db/repositories/executionRepository.js +41 -0
- package/dist/db/repositories/executionRepository.js.map +1 -0
- package/dist/db/repositories/index.d.ts +10 -0
- package/dist/db/repositories/index.d.ts.map +1 -0
- package/dist/db/repositories/index.js +10 -0
- package/dist/db/repositories/index.js.map +1 -0
- package/dist/db/repositories/nodeRepository.d.ts +15 -0
- package/dist/db/repositories/nodeRepository.d.ts.map +1 -0
- package/dist/db/repositories/nodeRepository.js +61 -0
- package/dist/db/repositories/nodeRepository.js.map +1 -0
- package/dist/db/repositories/personaRepository.d.ts +13 -0
- package/dist/db/repositories/personaRepository.d.ts.map +1 -0
- package/dist/db/repositories/personaRepository.js +42 -0
- package/dist/db/repositories/personaRepository.js.map +1 -0
- package/dist/db/repositories/planResultRepository.d.ts +13 -0
- package/dist/db/repositories/planResultRepository.d.ts.map +1 -0
- package/dist/db/repositories/planResultRepository.js +30 -0
- package/dist/db/repositories/planResultRepository.js.map +1 -0
- package/dist/db/repositories/scheduleRepository.d.ts +27 -0
- package/dist/db/repositories/scheduleRepository.d.ts.map +1 -0
- package/dist/db/repositories/scheduleRepository.js +187 -0
- package/dist/db/repositories/scheduleRepository.js.map +1 -0
- package/dist/db/repositories/types.d.ts +132 -0
- package/dist/db/repositories/types.d.ts.map +1 -0
- package/dist/db/repositories/types.js +5 -0
- package/dist/db/repositories/types.js.map +1 -0
- package/dist/db/schema.d.ts +742 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +85 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/capabilities.d.ts +56 -0
- package/dist/llm/capabilities.d.ts.map +1 -0
- package/dist/llm/capabilities.js +305 -0
- package/dist/llm/capabilities.js.map +1 -0
- package/dist/llm/index.d.ts +7 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +10 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/interfaces.d.ts +249 -0
- package/dist/llm/interfaces.d.ts.map +1 -0
- package/dist/llm/interfaces.js +5 -0
- package/dist/llm/interfaces.js.map +1 -0
- package/dist/llm/providers/anthropic-compatible.d.ts +48 -0
- package/dist/llm/providers/anthropic-compatible.d.ts.map +1 -0
- package/dist/llm/providers/anthropic-compatible.js +163 -0
- package/dist/llm/providers/anthropic-compatible.js.map +1 -0
- package/dist/llm/providers/index.d.ts +14 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/index.js +12 -0
- package/dist/llm/providers/index.js.map +1 -0
- package/dist/llm/providers/openai-compatible.d.ts +59 -0
- package/dist/llm/providers/openai-compatible.d.ts.map +1 -0
- package/dist/llm/providers/openai-compatible.js +207 -0
- package/dist/llm/providers/openai-compatible.js.map +1 -0
- package/dist/services/actionService.d.ts +132 -0
- package/dist/services/actionService.d.ts.map +1 -0
- package/dist/services/actionService.js +971 -0
- package/dist/services/actionService.js.map +1 -0
- package/dist/services/branchService.d.ts +19 -0
- package/dist/services/branchService.d.ts.map +1 -0
- package/dist/services/branchService.js +50 -0
- package/dist/services/branchService.js.map +1 -0
- package/dist/services/expressionEvaluator.d.ts +16 -0
- package/dist/services/expressionEvaluator.d.ts.map +1 -0
- package/dist/services/expressionEvaluator.js +70 -0
- package/dist/services/expressionEvaluator.js.map +1 -0
- package/dist/services/factory.d.ts +43 -0
- package/dist/services/factory.d.ts.map +1 -0
- package/dist/services/factory.js +30 -0
- package/dist/services/factory.js.map +1 -0
- package/dist/services/index.d.ts +15 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +17 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/interfaces.d.ts +117 -0
- package/dist/services/interfaces.d.ts.map +1 -0
- package/dist/services/interfaces.js +5 -0
- package/dist/services/interfaces.js.map +1 -0
- package/dist/services/loaders/fileLoader.d.ts +56 -0
- package/dist/services/loaders/fileLoader.d.ts.map +1 -0
- package/dist/services/loaders/fileLoader.js +161 -0
- package/dist/services/loaders/fileLoader.js.map +1 -0
- package/dist/services/loaders/index.d.ts +6 -0
- package/dist/services/loaders/index.d.ts.map +1 -0
- package/dist/services/loaders/index.js +6 -0
- package/dist/services/loaders/index.js.map +1 -0
- package/dist/services/loaders/transformers.d.ts +32 -0
- package/dist/services/loaders/transformers.d.ts.map +1 -0
- package/dist/services/loaders/transformers.js +78 -0
- package/dist/services/loaders/transformers.js.map +1 -0
- package/dist/services/mockAction.d.ts +65 -0
- package/dist/services/mockAction.d.ts.map +1 -0
- package/dist/services/mockAction.js +153 -0
- package/dist/services/mockAction.js.map +1 -0
- package/dist/services/mockBranch.d.ts +50 -0
- package/dist/services/mockBranch.d.ts.map +1 -0
- package/dist/services/mockBranch.js +75 -0
- package/dist/services/mockBranch.js.map +1 -0
- package/dist/services/mockThinking.d.ts +68 -0
- package/dist/services/mockThinking.d.ts.map +1 -0
- package/dist/services/mockThinking.js +89 -0
- package/dist/services/mockThinking.js.map +1 -0
- package/dist/services/thinkingService.d.ts +15 -0
- package/dist/services/thinkingService.d.ts.map +1 -0
- package/dist/services/thinkingService.js +117 -0
- package/dist/services/thinkingService.js.map +1 -0
- package/dist/temporal/activities/actionActivities.d.ts +15 -0
- package/dist/temporal/activities/actionActivities.d.ts.map +1 -0
- package/dist/temporal/activities/actionActivities.js +140 -0
- package/dist/temporal/activities/actionActivities.js.map +1 -0
- package/dist/temporal/activities/branchActivities.d.ts +13 -0
- package/dist/temporal/activities/branchActivities.d.ts.map +1 -0
- package/dist/temporal/activities/branchActivities.js +26 -0
- package/dist/temporal/activities/branchActivities.js.map +1 -0
- package/dist/temporal/activities/dbActivities.d.ts +14 -0
- package/dist/temporal/activities/dbActivities.d.ts.map +1 -0
- package/dist/temporal/activities/dbActivities.js +84 -0
- package/dist/temporal/activities/dbActivities.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +9 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +9 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/thinkingActivities.d.ts +17 -0
- package/dist/temporal/activities/thinkingActivities.d.ts.map +1 -0
- package/dist/temporal/activities/thinkingActivities.js +145 -0
- package/dist/temporal/activities/thinkingActivities.js.map +1 -0
- package/dist/temporal/activities/types.d.ts +100 -0
- package/dist/temporal/activities/types.d.ts.map +1 -0
- package/dist/temporal/activities/types.js +5 -0
- package/dist/temporal/activities/types.js.map +1 -0
- package/dist/temporal/client.d.ts +43 -0
- package/dist/temporal/client.d.ts.map +1 -0
- package/dist/temporal/client.js +75 -0
- package/dist/temporal/client.js.map +1 -0
- package/dist/temporal/index.d.ts +10 -0
- package/dist/temporal/index.d.ts.map +1 -0
- package/dist/temporal/index.js +12 -0
- package/dist/temporal/index.js.map +1 -0
- package/dist/temporal/personaCoreClient.d.ts +199 -0
- package/dist/temporal/personaCoreClient.d.ts.map +1 -0
- package/dist/temporal/personaCoreClient.js +233 -0
- package/dist/temporal/personaCoreClient.js.map +1 -0
- package/dist/temporal/personaWorker.d.ts +141 -0
- package/dist/temporal/personaWorker.d.ts.map +1 -0
- package/dist/temporal/personaWorker.js +93 -0
- package/dist/temporal/personaWorker.js.map +1 -0
- package/dist/temporal/worker.d.ts +66 -0
- package/dist/temporal/worker.d.ts.map +1 -0
- package/dist/temporal/worker.js +109 -0
- package/dist/temporal/worker.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +5 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +5 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/scheduleWorkflow.d.ts +31 -0
- package/dist/temporal/workflows/scheduleWorkflow.d.ts.map +1 -0
- package/dist/temporal/workflows/scheduleWorkflow.js +256 -0
- package/dist/temporal/workflows/scheduleWorkflow.js.map +1 -0
- package/dist/types/common.d.ts +81 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +5 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/nodes.d.ts +496 -0
- package/dist/types/nodes.d.ts.map +1 -0
- package/dist/types/nodes.js +5 -0
- package/dist/types/nodes.js.map +1 -0
- package/dist/types/persona.d.ts +59 -0
- package/dist/types/persona.d.ts.map +1 -0
- package/dist/types/persona.js +36 -0
- package/dist/types/persona.js.map +1 -0
- package/dist/types/schedule.d.ts +143 -0
- package/dist/types/schedule.d.ts.map +1 -0
- package/dist/types/schedule.js +155 -0
- package/dist/types/schedule.js.map +1 -0
- package/dist/utils/dateUtils.d.ts +31 -0
- package/dist/utils/dateUtils.d.ts.map +1 -0
- package/dist/utils/dateUtils.js +53 -0
- package/dist/utils/dateUtils.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/inputResolver.d.ts +43 -0
- package/dist/utils/inputResolver.d.ts.map +1 -0
- package/dist/utils/inputResolver.js +137 -0
- package/dist/utils/inputResolver.js.map +1 -0
- package/dist/utils/sharedDataUtils.d.ts +36 -0
- package/dist/utils/sharedDataUtils.d.ts.map +1 -0
- package/dist/utils/sharedDataUtils.js +84 -0
- package/dist/utils/sharedDataUtils.js.map +1 -0
- package/dist/utils/typeGuards.d.ts +33 -0
- package/dist/utils/typeGuards.d.ts.map +1 -0
- package/dist/utils/typeGuards.js +50 -0
- package/dist/utils/typeGuards.js.map +1 -0
- package/docs/add-llm-provider.md +353 -0
- package/docs/external/deepseek-v32.md +28 -0
- package/docs/quick-start.md +849 -0
- package/docs/suite-guide.md +148 -0
- package/docs/usage-guide.md +1487 -0
- package/package.json +80 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedDataUtils.d.ts","sourceRoot":"","sources":["../../src/utils/sharedDataUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/F;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACvC,kBAAkB,CAuBpB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,qBAAqB,GACjC,kBAAkB,CAiBpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACxC,WAAW,CAAC,EAAE,qBAAqB,GAClC,kBAAkB,CAcpB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SharedData 工具函数
|
|
3
|
+
* 提供共享数据更新的通用逻辑
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 更新共享数据
|
|
7
|
+
* 区分集合类型和普通类型:
|
|
8
|
+
* - 集合类型:追加到数组
|
|
9
|
+
* - 普通类型:直接覆盖
|
|
10
|
+
*
|
|
11
|
+
* @param current - 当前共享数据实例
|
|
12
|
+
* @param updates - 要更新的字段和值
|
|
13
|
+
* @returns 更新后的共享数据实例
|
|
14
|
+
*/
|
|
15
|
+
export function updateSharedData(current, updates) {
|
|
16
|
+
const result = {
|
|
17
|
+
data: { ...current.data },
|
|
18
|
+
fieldTypes: { ...current.fieldTypes },
|
|
19
|
+
};
|
|
20
|
+
for (const [key, value] of Object.entries(updates)) {
|
|
21
|
+
// 检查是否为集合类型
|
|
22
|
+
if (result.fieldTypes[key]) {
|
|
23
|
+
// 集合类型:追加
|
|
24
|
+
const existing = result.data[key];
|
|
25
|
+
if (Array.isArray(existing)) {
|
|
26
|
+
result.data[key] = [...existing, value];
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
result.data[key] = [value];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// 普通类型:覆盖
|
|
34
|
+
result.data[key] = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 应用共享数据声明
|
|
41
|
+
* 添加新的字段类型定义和初始值
|
|
42
|
+
*
|
|
43
|
+
* @param current - 当前共享数据实例
|
|
44
|
+
* @param declaration - 共享数据声明
|
|
45
|
+
* @returns 更新后的共享数据实例
|
|
46
|
+
*/
|
|
47
|
+
export function applySharedDataDeclaration(current, declaration) {
|
|
48
|
+
const result = {
|
|
49
|
+
data: { ...current.data },
|
|
50
|
+
fieldTypes: { ...current.fieldTypes },
|
|
51
|
+
};
|
|
52
|
+
for (const field of declaration.fields) {
|
|
53
|
+
// 只添加新字段,不覆盖已存在的
|
|
54
|
+
if (!(field.name in result.fieldTypes)) {
|
|
55
|
+
result.fieldTypes[field.name] = field.isCollection;
|
|
56
|
+
if (field.initialValue !== undefined) {
|
|
57
|
+
result.data[field.name] = field.initialValue;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 合并共享数据更新和声明
|
|
65
|
+
* 先应用声明,再应用更新
|
|
66
|
+
*
|
|
67
|
+
* @param current - 当前共享数据实例
|
|
68
|
+
* @param updates - 要更新的字段和值
|
|
69
|
+
* @param declaration - 可选的共享数据声明
|
|
70
|
+
* @returns 更新后的共享数据实例
|
|
71
|
+
*/
|
|
72
|
+
export function mergeSharedDataUpdates(current, updates, declaration) {
|
|
73
|
+
let result = current;
|
|
74
|
+
// 先应用声明
|
|
75
|
+
if (declaration) {
|
|
76
|
+
result = applySharedDataDeclaration(result, declaration);
|
|
77
|
+
}
|
|
78
|
+
// 再应用更新
|
|
79
|
+
if (Object.keys(updates).length > 0) {
|
|
80
|
+
result = updateSharedData(result, updates);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=sharedDataUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedDataUtils.js","sourceRoot":"","sources":["../../src/utils/sharedDataUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA2B,EAC3B,OAAwC;IAExC,MAAM,MAAM,GAAuB;QACjC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE;QACzB,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE;KACtC,CAAC;IAEF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,YAAY;QACZ,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,UAAU;YACV,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC1C,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,UAAU;YACV,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA2B,EAC3B,WAAkC;IAElC,MAAM,MAAM,GAAuB;QACjC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE;QACzB,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE;KACtC,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACvC,iBAAiB;QACjB,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YACvC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;YACnD,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBACrC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAA2B,EAC3B,OAAwC,EACxC,WAAmC;IAEnC,IAAI,MAAM,GAAG,OAAO,CAAC;IAErB,QAAQ;IACR,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,GAAG,0BAA0B,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED,QAAQ;IACR,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 类型守卫函数
|
|
3
|
+
* 用于替代类型断言,提高类型安全性
|
|
4
|
+
*/
|
|
5
|
+
import { NodeInstance, ThinkingNodeInstance, ActionNodeInstance, BranchNodeInstance } from '../types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* 检查节点是否为思考节点
|
|
8
|
+
*/
|
|
9
|
+
export declare function isThinkingNode(node: NodeInstance): node is ThinkingNodeInstance;
|
|
10
|
+
/**
|
|
11
|
+
* 检查节点是否为动作节点
|
|
12
|
+
*/
|
|
13
|
+
export declare function isActionNode(node: NodeInstance): node is ActionNodeInstance;
|
|
14
|
+
/**
|
|
15
|
+
* 检查节点是否为分支节点
|
|
16
|
+
*/
|
|
17
|
+
export declare function isBranchNode(node: NodeInstance): node is BranchNodeInstance;
|
|
18
|
+
/**
|
|
19
|
+
* 断言节点为思考节点
|
|
20
|
+
* @throws Error 如果节点不是思考节点
|
|
21
|
+
*/
|
|
22
|
+
export declare function assertThinkingNode(node: NodeInstance): asserts node is ThinkingNodeInstance;
|
|
23
|
+
/**
|
|
24
|
+
* 断言节点为动作节点
|
|
25
|
+
* @throws Error 如果节点不是动作节点
|
|
26
|
+
*/
|
|
27
|
+
export declare function assertActionNode(node: NodeInstance): asserts node is ActionNodeInstance;
|
|
28
|
+
/**
|
|
29
|
+
* 断言节点为分支节点
|
|
30
|
+
* @throws Error 如果节点不是分支节点
|
|
31
|
+
*/
|
|
32
|
+
export declare function assertBranchNode(node: NodeInstance): asserts node is BranchNodeInstance;
|
|
33
|
+
//# sourceMappingURL=typeGuards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../src/utils/typeGuards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,oBAAoB,CAE/E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,kBAAkB,CAE3E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,kBAAkB,CAE3E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,IAAI,oBAAoB,CAI3F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,IAAI,kBAAkB,CAIvF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,IAAI,kBAAkB,CAIvF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 类型守卫函数
|
|
3
|
+
* 用于替代类型断言,提高类型安全性
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 检查节点是否为思考节点
|
|
7
|
+
*/
|
|
8
|
+
export function isThinkingNode(node) {
|
|
9
|
+
return node.kind === 'thinking';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 检查节点是否为动作节点
|
|
13
|
+
*/
|
|
14
|
+
export function isActionNode(node) {
|
|
15
|
+
return node.kind === 'action';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 检查节点是否为分支节点
|
|
19
|
+
*/
|
|
20
|
+
export function isBranchNode(node) {
|
|
21
|
+
return node.kind === 'branch';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 断言节点为思考节点
|
|
25
|
+
* @throws Error 如果节点不是思考节点
|
|
26
|
+
*/
|
|
27
|
+
export function assertThinkingNode(node) {
|
|
28
|
+
if (!isThinkingNode(node)) {
|
|
29
|
+
throw new Error(`Expected thinking node, got ${node.kind}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 断言节点为动作节点
|
|
34
|
+
* @throws Error 如果节点不是动作节点
|
|
35
|
+
*/
|
|
36
|
+
export function assertActionNode(node) {
|
|
37
|
+
if (!isActionNode(node)) {
|
|
38
|
+
throw new Error(`Expected action node, got ${node.kind}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 断言节点为分支节点
|
|
43
|
+
* @throws Error 如果节点不是分支节点
|
|
44
|
+
*/
|
|
45
|
+
export function assertBranchNode(node) {
|
|
46
|
+
if (!isBranchNode(node)) {
|
|
47
|
+
throw new Error(`Expected branch node, got ${node.kind}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=typeGuards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../src/utils/typeGuards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAkB;IAC/C,OAAO,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAkB;IAC7C,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAkB;IAC7C,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAkB;IACnD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAkB;IACjD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAkB;IACjD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# 新增 LLM Provider 指南
|
|
2
|
+
|
|
3
|
+
本文档介绍如何为 PersonaCore 添加新的 LLM 提供者支持。
|
|
4
|
+
|
|
5
|
+
## 架构概述
|
|
6
|
+
|
|
7
|
+
PersonaCore 使用 LLM 抽象层来支持多种 LLM 提供者:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────────────┐
|
|
11
|
+
│ 服务层 (Services) │
|
|
12
|
+
│ DefaultThinkingService / DefaultActionService / ... │
|
|
13
|
+
└────────────────────────────┬────────────────────────────┘
|
|
14
|
+
│
|
|
15
|
+
┌────────────────────────────▼────────────────────────────┐
|
|
16
|
+
│ 能力层 (Capabilities) │
|
|
17
|
+
│ LLMPlanningCapability / LLMBranchDecisionCapability │
|
|
18
|
+
│ LLMContentGenerationCapability │
|
|
19
|
+
└────────────────────────────┬────────────────────────────┘
|
|
20
|
+
│
|
|
21
|
+
┌────────────────────────────▼────────────────────────────┐
|
|
22
|
+
│ 提供者层 (LLMProvider) │
|
|
23
|
+
│ DeepSeekProvider / OpenAIProvider / ClaudeProvider │
|
|
24
|
+
└─────────────────────────────────────────────────────────┘
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**你只需要实现 `LLMProvider` 接口**,系统会自动适配到所有服务。
|
|
28
|
+
|
|
29
|
+
## 实现步骤
|
|
30
|
+
|
|
31
|
+
### 1. 创建 Provider 文件
|
|
32
|
+
|
|
33
|
+
在 `src/llm/providers/` 目录下创建新文件,如 `openai.ts`:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import {
|
|
37
|
+
LLMProvider,
|
|
38
|
+
LLMMessage,
|
|
39
|
+
StructuredOutputConfig,
|
|
40
|
+
LLMCallOptions,
|
|
41
|
+
} from '../interfaces.js';
|
|
42
|
+
|
|
43
|
+
export interface OpenAIProviderConfig {
|
|
44
|
+
apiKey: string;
|
|
45
|
+
baseUrl?: string;
|
|
46
|
+
model?: string;
|
|
47
|
+
defaultTimeout?: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class OpenAIProvider implements LLMProvider {
|
|
51
|
+
readonly name = 'openai';
|
|
52
|
+
|
|
53
|
+
private config: Required<OpenAIProviderConfig>;
|
|
54
|
+
private endpoint: string;
|
|
55
|
+
|
|
56
|
+
constructor(config: OpenAIProviderConfig) {
|
|
57
|
+
this.config = {
|
|
58
|
+
apiKey: config.apiKey,
|
|
59
|
+
baseUrl: config.baseUrl ?? 'https://api.openai.com/v1',
|
|
60
|
+
model: config.model ?? 'gpt-4',
|
|
61
|
+
defaultTimeout: config.defaultTimeout ?? 60000,
|
|
62
|
+
};
|
|
63
|
+
this.endpoint = `${this.config.baseUrl}/chat/completions`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 实现 chat 方法
|
|
67
|
+
async chat(messages: LLMMessage[], options?: LLMCallOptions): Promise<string> {
|
|
68
|
+
// ... 实现 API 调用
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 实现 chatWithStructuredOutput 方法
|
|
72
|
+
async chatWithStructuredOutput<T>(
|
|
73
|
+
messages: LLMMessage[],
|
|
74
|
+
config: StructuredOutputConfig<T>,
|
|
75
|
+
options?: LLMCallOptions
|
|
76
|
+
): Promise<T> {
|
|
77
|
+
// ... 实现结构化输出
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2. 实现 LLMProvider 接口
|
|
83
|
+
|
|
84
|
+
`LLMProvider` 接口包含两个核心方法:
|
|
85
|
+
|
|
86
|
+
#### `chat` - 基础对话
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
async chat(messages: LLMMessage[], options?: LLMCallOptions): Promise<string>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- **messages**: 对话消息列表,每条消息包含 `role` (system/user/assistant) 和 `content`
|
|
93
|
+
- **options**: 可选参数,包括 `temperature`、`maxTokens`、`timeout`
|
|
94
|
+
- **返回**: 模型响应的文本内容
|
|
95
|
+
|
|
96
|
+
**实现要点**:
|
|
97
|
+
- 处理 API 调用超时
|
|
98
|
+
- 抛出有意义的错误信息
|
|
99
|
+
- 返回干净的响应文本
|
|
100
|
+
|
|
101
|
+
#### `chatWithStructuredOutput` - 结构化输出
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
async chatWithStructuredOutput<T>(
|
|
105
|
+
messages: LLMMessage[],
|
|
106
|
+
config: StructuredOutputConfig<T>,
|
|
107
|
+
options?: LLMCallOptions
|
|
108
|
+
): Promise<T>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- **config.schema**: JSON Schema 描述字符串,告诉 LLM 期望的输出格式
|
|
112
|
+
- **config.parser**: 可选的自定义解析函数
|
|
113
|
+
- **返回**: 解析后的结构化对象
|
|
114
|
+
|
|
115
|
+
**实现要点**:
|
|
116
|
+
|
|
117
|
+
1. **增强提示词** - 在消息中添加 JSON 格式要求
|
|
118
|
+
2. **提取 JSON** - 从响应中提取 JSON 内容(可能被 markdown 代码块包裹)
|
|
119
|
+
3. **解析验证** - 解析 JSON 并返回
|
|
120
|
+
|
|
121
|
+
示例实现:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
async chatWithStructuredOutput<T>(
|
|
125
|
+
messages: LLMMessage[],
|
|
126
|
+
config: StructuredOutputConfig<T>,
|
|
127
|
+
options?: LLMCallOptions
|
|
128
|
+
): Promise<T> {
|
|
129
|
+
// 1. 增强最后一条消息,添加 JSON 格式要求
|
|
130
|
+
const enhancedMessages = [
|
|
131
|
+
...messages.slice(0, -1),
|
|
132
|
+
{
|
|
133
|
+
role: messages[messages.length - 1].role,
|
|
134
|
+
content: `${messages[messages.length - 1].content}
|
|
135
|
+
|
|
136
|
+
请严格按照以下 JSON 格式返回结果,不要包含任何其他内容:
|
|
137
|
+
${config.schema}`,
|
|
138
|
+
} as LLMMessage,
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
// 2. 调用基础 chat 方法
|
|
142
|
+
const content = await this.chat(enhancedMessages, options);
|
|
143
|
+
|
|
144
|
+
// 3. 提取 JSON 内容
|
|
145
|
+
const jsonMatch = content.match(/```json\n?([\s\S]*?)\n?```/) ||
|
|
146
|
+
content.match(/\{[\s\S]*\}/);
|
|
147
|
+
|
|
148
|
+
if (!jsonMatch) {
|
|
149
|
+
throw new Error(`Failed to parse structured output: ${content}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const jsonStr = jsonMatch[1] || jsonMatch[0];
|
|
153
|
+
|
|
154
|
+
// 4. 使用自定义解析器或默认 JSON.parse
|
|
155
|
+
if (config.parser) {
|
|
156
|
+
return config.parser(jsonStr);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return JSON.parse(jsonStr);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 3. 导出 Provider
|
|
164
|
+
|
|
165
|
+
在 `src/llm/providers/index.ts` 中添加导出:
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
export { DeepSeekProvider } from './deepseek.js';
|
|
169
|
+
export type { DeepSeekProviderConfig } from './deepseek.js';
|
|
170
|
+
|
|
171
|
+
// 新增
|
|
172
|
+
export { OpenAIProvider } from './openai.js';
|
|
173
|
+
export type { OpenAIProviderConfig } from './openai.js';
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 使用新 Provider
|
|
177
|
+
|
|
178
|
+
### 基础用法
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { createServices } from 'persona-core';
|
|
182
|
+
import { OpenAIProvider } from 'persona-core/llm/providers';
|
|
183
|
+
|
|
184
|
+
const llmProvider = new OpenAIProvider({
|
|
185
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
186
|
+
model: 'gpt-4-turbo',
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const services = createServices({ llmProvider });
|
|
190
|
+
|
|
191
|
+
// services.thinkingService、services.actionService、services.branchService
|
|
192
|
+
// 都会使用 OpenAI 作为底层 LLM
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 混合使用多个 Provider
|
|
196
|
+
|
|
197
|
+
可以为不同场景配置不同的 Provider:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
const services = createServices({
|
|
201
|
+
llmProvider: deepseekProvider, // 默认 Provider
|
|
202
|
+
planningProvider: gpt4Provider, // 规划专用(更强大的模型)
|
|
203
|
+
branchProvider: gpt35Provider, // 分支决策(更快的模型)
|
|
204
|
+
contentProvider: claudeProvider, // 内容生成(特定领域模型)
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## 完整示例:OpenAI Provider
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import {
|
|
212
|
+
LLMProvider,
|
|
213
|
+
LLMMessage,
|
|
214
|
+
StructuredOutputConfig,
|
|
215
|
+
LLMCallOptions,
|
|
216
|
+
} from '../interfaces.js';
|
|
217
|
+
|
|
218
|
+
export interface OpenAIProviderConfig {
|
|
219
|
+
apiKey: string;
|
|
220
|
+
baseUrl?: string;
|
|
221
|
+
model?: string;
|
|
222
|
+
defaultTimeout?: number;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export class OpenAIProvider implements LLMProvider {
|
|
226
|
+
readonly name = 'openai';
|
|
227
|
+
|
|
228
|
+
private config: Required<OpenAIProviderConfig>;
|
|
229
|
+
private endpoint: string;
|
|
230
|
+
|
|
231
|
+
constructor(config: OpenAIProviderConfig) {
|
|
232
|
+
this.config = {
|
|
233
|
+
apiKey: config.apiKey,
|
|
234
|
+
baseUrl: config.baseUrl ?? 'https://api.openai.com/v1',
|
|
235
|
+
model: config.model ?? 'gpt-4',
|
|
236
|
+
defaultTimeout: config.defaultTimeout ?? 60000,
|
|
237
|
+
};
|
|
238
|
+
this.endpoint = `${this.config.baseUrl}/chat/completions`;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async chat(messages: LLMMessage[], options?: LLMCallOptions): Promise<string> {
|
|
242
|
+
const timeout = options?.timeout ?? this.config.defaultTimeout;
|
|
243
|
+
const controller = new AbortController();
|
|
244
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
245
|
+
|
|
246
|
+
try {
|
|
247
|
+
const response = await fetch(this.endpoint, {
|
|
248
|
+
method: 'POST',
|
|
249
|
+
headers: {
|
|
250
|
+
'Authorization': `Bearer ${this.config.apiKey}`,
|
|
251
|
+
'Content-Type': 'application/json',
|
|
252
|
+
},
|
|
253
|
+
body: JSON.stringify({
|
|
254
|
+
model: this.config.model,
|
|
255
|
+
messages: messages.map(m => ({ role: m.role, content: m.content })),
|
|
256
|
+
temperature: options?.temperature ?? 0.7,
|
|
257
|
+
max_tokens: options?.maxTokens,
|
|
258
|
+
}),
|
|
259
|
+
signal: controller.signal,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
if (!response.ok) {
|
|
263
|
+
const error = await response.text();
|
|
264
|
+
throw new Error(`OpenAI API error: ${response.status} - ${error}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const data = await response.json() as {
|
|
268
|
+
choices: Array<{ message: { content: string } }>;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
return data.choices[0]?.message?.content ?? '';
|
|
272
|
+
} finally {
|
|
273
|
+
clearTimeout(timeoutId);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async chatWithStructuredOutput<T>(
|
|
278
|
+
messages: LLMMessage[],
|
|
279
|
+
config: StructuredOutputConfig<T>,
|
|
280
|
+
options?: LLMCallOptions
|
|
281
|
+
): Promise<T> {
|
|
282
|
+
const enhancedMessages = [
|
|
283
|
+
...messages.slice(0, -1),
|
|
284
|
+
{
|
|
285
|
+
role: messages[messages.length - 1].role,
|
|
286
|
+
content: `${messages[messages.length - 1].content}
|
|
287
|
+
|
|
288
|
+
请严格按照以下 JSON 格式返回结果,不要包含任何其他内容:
|
|
289
|
+
${config.schema}`,
|
|
290
|
+
} as LLMMessage,
|
|
291
|
+
];
|
|
292
|
+
|
|
293
|
+
const content = await this.chat(enhancedMessages, options);
|
|
294
|
+
|
|
295
|
+
const jsonMatch = content.match(/```json\n?([\s\S]*?)\n?```/) ||
|
|
296
|
+
content.match(/\{[\s\S]*\}/);
|
|
297
|
+
|
|
298
|
+
if (!jsonMatch) {
|
|
299
|
+
throw new Error(`Failed to parse structured output: ${content}`);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const jsonStr = jsonMatch[1] || jsonMatch[0];
|
|
303
|
+
|
|
304
|
+
if (config.parser) {
|
|
305
|
+
return config.parser(jsonStr);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return JSON.parse(jsonStr);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## 测试新 Provider
|
|
314
|
+
|
|
315
|
+
建议编写单元测试验证:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import { describe, it, expect } from 'vitest';
|
|
319
|
+
import { OpenAIProvider } from './openai.js';
|
|
320
|
+
|
|
321
|
+
describe('OpenAIProvider', () => {
|
|
322
|
+
const provider = new OpenAIProvider({
|
|
323
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('should complete basic chat', async () => {
|
|
327
|
+
const response = await provider.chat([
|
|
328
|
+
{ role: 'user', content: 'Say "hello" and nothing else.' }
|
|
329
|
+
]);
|
|
330
|
+
|
|
331
|
+
expect(response.toLowerCase()).toContain('hello');
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('should return structured output', async () => {
|
|
335
|
+
const result = await provider.chatWithStructuredOutput<{ name: string }>(
|
|
336
|
+
[{ role: 'user', content: 'Generate a random name' }],
|
|
337
|
+
{ schema: '{ "name": "<人名>" }' }
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
expect(result).toHaveProperty('name');
|
|
341
|
+
expect(typeof result.name).toBe('string');
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## 注意事项
|
|
347
|
+
|
|
348
|
+
1. **错误处理**:确保 API 错误有清晰的错误信息
|
|
349
|
+
2. **超时控制**:实现请求超时机制
|
|
350
|
+
3. **速率限制**:考虑处理 API 速率限制(429 错误)
|
|
351
|
+
4. **JSON 解析**:处理 LLM 可能返回不规范 JSON 的情况
|
|
352
|
+
5. **流式响应**:当前接口不支持流式响应,如需支持可扩展接口
|
|
353
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
curl 调用例子:
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
curl --location 'https://ark.cn-beijing.volces.com/api/v3/responses' \
|
|
5
|
+
--header "Authorization: Bearer 30f13e3e-f7d0-41da-acc2-ecc8cd65a776" \
|
|
6
|
+
--header 'Content-Type: application/json' \
|
|
7
|
+
--data '{
|
|
8
|
+
"model": "deepseek-v3-2-251201",
|
|
9
|
+
"stream": true,
|
|
10
|
+
"tools": [
|
|
11
|
+
{
|
|
12
|
+
"type": "web_search",
|
|
13
|
+
"max_keyword": 3
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"input": [
|
|
17
|
+
{
|
|
18
|
+
"role": "user",
|
|
19
|
+
"content": [
|
|
20
|
+
{
|
|
21
|
+
"type": "input_text",
|
|
22
|
+
"text": "今天有什么热点新闻"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}'
|
|
28
|
+
```
|