@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/esm/llm-agent.js
CHANGED
|
@@ -80,29 +80,37 @@ let PipelineAgent = PipelineAgent_1 = class PipelineAgent extends Runnable {
|
|
|
80
80
|
.filter(isNonNullable));
|
|
81
81
|
const stream = await runnable.run(inputValues, { stream: true });
|
|
82
82
|
const needRespondTextStream = textStreamOutput?.from === 'variable' && textStreamOutput.fromVariableId === process.id;
|
|
83
|
-
const needRespondJsonStream = outputs.some(
|
|
83
|
+
// const needRespondJsonStream = outputs.some(
|
|
84
|
+
// (i) => i.name !== StreamTextOutputName && i.from === 'variable' && i.fromVariableId === process.id
|
|
85
|
+
// );
|
|
86
|
+
const processResult = {};
|
|
87
|
+
variables[process.id] = processResult;
|
|
84
88
|
for await (const chunk of stream) {
|
|
85
|
-
if (chunk.$text
|
|
86
|
-
|
|
89
|
+
if (chunk.$text) {
|
|
90
|
+
Object.assign(processResult, { $text: (processResult.$text || '') + chunk.$text });
|
|
91
|
+
if (needRespondTextStream) {
|
|
92
|
+
controller.enqueue({ $text: chunk.$text });
|
|
93
|
+
}
|
|
87
94
|
}
|
|
88
95
|
if (chunk.delta) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
96
|
+
Object.assign(processResult, chunk.delta);
|
|
97
|
+
// TODO: 这里需要考虑上层 agent 直接输出了 {$text: 'xxx'} 没有用 chunk 的方式返回的情况
|
|
98
|
+
// if (needRespondJsonStream) {
|
|
99
|
+
result = Object.fromEntries(OrderedRecord.map(definition.outputs, (output) => {
|
|
100
|
+
if (!output.name)
|
|
101
|
+
return null;
|
|
102
|
+
let value;
|
|
103
|
+
if (output.from === 'variable') {
|
|
104
|
+
const v = variables[output.fromVariableId];
|
|
105
|
+
value = output.fromVariablePropPath?.length ? get(v, output.fromVariablePropPath) : v;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
throw new Error(`Unsupported output source ${output.from}`);
|
|
109
|
+
}
|
|
110
|
+
return [output.name, value];
|
|
111
|
+
}).filter(isNonNullable));
|
|
112
|
+
controller.enqueue({ delta: result });
|
|
113
|
+
// }
|
|
106
114
|
}
|
|
107
115
|
}
|
|
108
116
|
}
|