ai 3.2.30 → 3.2.31
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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +26 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -3132,23 +3132,38 @@ __export(langchain_adapter_exports, {
|
|
3132
3132
|
function toAIStream(stream, callbacks) {
|
3133
3133
|
return stream.pipeThrough(
|
3134
3134
|
new TransformStream({
|
3135
|
-
transform: async (
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3139
|
-
|
3140
|
-
}
|
3141
|
-
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
|
3135
|
+
transform: async (value, controller) => {
|
3136
|
+
var _a;
|
3137
|
+
if (typeof value === "string") {
|
3138
|
+
controller.enqueue(value);
|
3139
|
+
return;
|
3140
|
+
}
|
3141
|
+
if ("event" in value) {
|
3142
|
+
if (value.event === "on_chat_model_stream") {
|
3143
|
+
forwardAIMessageChunk(
|
3144
|
+
(_a = value.data) == null ? void 0 : _a.chunk,
|
3145
|
+
controller
|
3146
|
+
);
|
3146
3147
|
}
|
3148
|
+
return;
|
3147
3149
|
}
|
3150
|
+
forwardAIMessageChunk(value, controller);
|
3148
3151
|
}
|
3149
3152
|
})
|
3150
3153
|
).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(createStreamDataTransformer());
|
3151
3154
|
}
|
3155
|
+
function forwardAIMessageChunk(chunk, controller) {
|
3156
|
+
if (typeof chunk.content === "string") {
|
3157
|
+
controller.enqueue(chunk.content);
|
3158
|
+
} else {
|
3159
|
+
const content = chunk.content;
|
3160
|
+
for (const item of content) {
|
3161
|
+
if (item.type === "text") {
|
3162
|
+
controller.enqueue(item.text);
|
3163
|
+
}
|
3164
|
+
}
|
3165
|
+
}
|
3166
|
+
}
|
3152
3167
|
|
3153
3168
|
// streams/langchain-stream.ts
|
3154
3169
|
function LangChainStream(callbacks) {
|