ai 3.0.10 → 3.0.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/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/prompts/dist/index.d.mts +32 -19
- package/prompts/dist/index.d.ts +32 -19
- package/prompts/dist/index.js +0 -1
- package/prompts/dist/index.js.map +1 -1
- package/prompts/dist/index.mjs +0 -1
- package/prompts/dist/index.mjs.map +1 -1
- package/react/dist/index.js +16 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +16 -1
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/rsc-server.mjs +4 -0
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.d.mts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { AssistantStream } from 'openai/lib/AssistantStream';
|
1
2
|
import { ChatCompletionResponseChunk } from '@mistralai/mistralai';
|
2
3
|
import { ServerResponse } from 'node:http';
|
3
4
|
|
@@ -799,11 +800,12 @@ type AssistantResponseSettings = {
|
|
799
800
|
threadId: string;
|
800
801
|
messageId: string;
|
801
802
|
};
|
802
|
-
type AssistantResponseCallback = (
|
803
|
+
type AssistantResponseCallback = (options: {
|
803
804
|
threadId: string;
|
804
805
|
messageId: string;
|
805
806
|
sendMessage: (message: AssistantMessage) => void;
|
806
807
|
sendDataMessage: (message: DataMessage) => void;
|
808
|
+
forwardStream: (stream: AssistantStream) => Promise<any>;
|
807
809
|
}) => Promise<void>;
|
808
810
|
declare function experimental_AssistantResponse({ threadId, messageId }: AssistantResponseSettings, process: AssistantResponseCallback): Response;
|
809
811
|
|
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { AssistantStream } from 'openai/lib/AssistantStream';
|
1
2
|
import { ChatCompletionResponseChunk } from '@mistralai/mistralai';
|
2
3
|
import { ServerResponse } from 'node:http';
|
3
4
|
|
@@ -799,11 +800,12 @@ type AssistantResponseSettings = {
|
|
799
800
|
threadId: string;
|
800
801
|
messageId: string;
|
801
802
|
};
|
802
|
-
type AssistantResponseCallback = (
|
803
|
+
type AssistantResponseCallback = (options: {
|
803
804
|
threadId: string;
|
804
805
|
messageId: string;
|
805
806
|
sendMessage: (message: AssistantMessage) => void;
|
806
807
|
sendDataMessage: (message: DataMessage) => void;
|
808
|
+
forwardStream: (stream: AssistantStream) => Promise<any>;
|
807
809
|
}) => Promise<void>;
|
808
810
|
declare function experimental_AssistantResponse({ threadId, messageId }: AssistantResponseSettings, process: AssistantResponseCallback): Response;
|
809
811
|
|
package/dist/index.js
CHANGED
@@ -550,6 +550,43 @@ function experimental_AssistantResponse({ threadId, messageId }, process2) {
|
|
550
550
|
textEncoder.encode(formatStreamPart("error", errorMessage))
|
551
551
|
);
|
552
552
|
};
|
553
|
+
const forwardStream = async (stream2) => {
|
554
|
+
var _a2, _b;
|
555
|
+
let result = void 0;
|
556
|
+
for await (const value of stream2) {
|
557
|
+
switch (value.event) {
|
558
|
+
case "thread.message.created": {
|
559
|
+
controller.enqueue(
|
560
|
+
textEncoder.encode(
|
561
|
+
formatStreamPart("assistant_message", {
|
562
|
+
id: value.data.id,
|
563
|
+
role: "assistant",
|
564
|
+
content: [{ type: "text", text: { value: "" } }]
|
565
|
+
})
|
566
|
+
)
|
567
|
+
);
|
568
|
+
break;
|
569
|
+
}
|
570
|
+
case "thread.message.delta": {
|
571
|
+
const content = (_a2 = value.data.delta.content) == null ? void 0 : _a2[0];
|
572
|
+
if ((content == null ? void 0 : content.type) === "text" && ((_b = content.text) == null ? void 0 : _b.value) != null) {
|
573
|
+
controller.enqueue(
|
574
|
+
textEncoder.encode(
|
575
|
+
formatStreamPart("text", content.text.value)
|
576
|
+
)
|
577
|
+
);
|
578
|
+
}
|
579
|
+
break;
|
580
|
+
}
|
581
|
+
case "thread.run.completed":
|
582
|
+
case "thread.run.requires_action": {
|
583
|
+
result = value.data;
|
584
|
+
break;
|
585
|
+
}
|
586
|
+
}
|
587
|
+
}
|
588
|
+
return result;
|
589
|
+
};
|
553
590
|
controller.enqueue(
|
554
591
|
textEncoder.encode(
|
555
592
|
formatStreamPart("assistant_control_data", {
|
@@ -563,7 +600,8 @@ function experimental_AssistantResponse({ threadId, messageId }, process2) {
|
|
563
600
|
threadId,
|
564
601
|
messageId,
|
565
602
|
sendMessage,
|
566
|
-
sendDataMessage
|
603
|
+
sendDataMessage,
|
604
|
+
forwardStream
|
567
605
|
});
|
568
606
|
} catch (error) {
|
569
607
|
sendError((_a = error.message) != null ? _a : `${error}`);
|