@aigne/core 0.4.196 → 0.4.198
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/lib/cjs/llm-agent.js +1 -1
- package/lib/cjs/pipeline-agent.js +28 -20
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/llm-agent.js +1 -1
- package/lib/esm/pipeline-agent.js +28 -20
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/memory.d.ts +3 -5
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/lib/cjs/llm-agent.js
CHANGED
|
@@ -87,29 +87,37 @@ let PipelineAgent = PipelineAgent_1 = class PipelineAgent extends runnable_1.Run
|
|
|
87
87
|
.filter(is_non_nullable_1.isNonNullable));
|
|
88
88
|
const stream = await runnable.run(inputValues, { stream: true });
|
|
89
89
|
const needRespondTextStream = textStreamOutput?.from === 'variable' && textStreamOutput.fromVariableId === process.id;
|
|
90
|
-
const needRespondJsonStream = outputs.some(
|
|
90
|
+
// const needRespondJsonStream = outputs.some(
|
|
91
|
+
// (i) => i.name !== StreamTextOutputName && i.from === 'variable' && i.fromVariableId === process.id
|
|
92
|
+
// );
|
|
93
|
+
const processResult = {};
|
|
94
|
+
variables[process.id] = processResult;
|
|
91
95
|
for await (const chunk of stream) {
|
|
92
|
-
if (chunk.$text
|
|
93
|
-
|
|
96
|
+
if (chunk.$text) {
|
|
97
|
+
Object.assign(processResult, { $text: (processResult.$text || '') + chunk.$text });
|
|
98
|
+
if (needRespondTextStream) {
|
|
99
|
+
controller.enqueue({ $text: chunk.$text });
|
|
100
|
+
}
|
|
94
101
|
}
|
|
95
102
|
if (chunk.delta) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
103
|
+
Object.assign(processResult, chunk.delta);
|
|
104
|
+
// TODO: 这里需要考虑上层 agent 直接输出了 {$text: 'xxx'} 没有用 chunk 的方式返回的情况
|
|
105
|
+
// if (needRespondJsonStream) {
|
|
106
|
+
result = Object.fromEntries(ordered_map_1.OrderedRecord.map(definition.outputs, (output) => {
|
|
107
|
+
if (!output.name)
|
|
108
|
+
return null;
|
|
109
|
+
let value;
|
|
110
|
+
if (output.from === 'variable') {
|
|
111
|
+
const v = variables[output.fromVariableId];
|
|
112
|
+
value = output.fromVariablePropPath?.length ? (0, lodash_1.get)(v, output.fromVariablePropPath) : v;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
throw new Error(`Unsupported output source ${output.from}`);
|
|
116
|
+
}
|
|
117
|
+
return [output.name, value];
|
|
118
|
+
}).filter(is_non_nullable_1.isNonNullable));
|
|
119
|
+
controller.enqueue({ delta: result });
|
|
120
|
+
// }
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
}
|