ai 2.2.21 → 2.2.22
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.ts +3 -1
- package/dist/index.js +3 -2
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
- package/react/dist/index.d.ts +1 -1
- package/react/dist/index.js +3 -3
- package/react/dist/index.mjs +3 -3
package/dist/index.d.ts
CHANGED
@@ -574,7 +574,9 @@ interface Prediction {
|
|
574
574
|
* return new StreamingTextResponse(stream)
|
575
575
|
*
|
576
576
|
*/
|
577
|
-
declare function ReplicateStream(res: Prediction, cb?: AIStreamCallbacksAndOptions
|
577
|
+
declare function ReplicateStream(res: Prediction, cb?: AIStreamCallbacksAndOptions, options?: {
|
578
|
+
headers?: Record<string, string>;
|
579
|
+
}): Promise<ReadableStream>;
|
578
580
|
|
579
581
|
declare const nanoid: (size?: number | undefined) => string;
|
580
582
|
declare function createChunkDecoder(): (chunk: Uint8Array | undefined) => string;
|
package/dist/index.js
CHANGED
@@ -691,7 +691,7 @@ function LangChainStream(callbacks) {
|
|
691
691
|
}
|
692
692
|
|
693
693
|
// streams/replicate-stream.ts
|
694
|
-
async function ReplicateStream(res, cb) {
|
694
|
+
async function ReplicateStream(res, cb, options) {
|
695
695
|
var _a;
|
696
696
|
const url = (_a = res.urls) == null ? void 0 : _a.stream;
|
697
697
|
if (!url) {
|
@@ -703,7 +703,8 @@ async function ReplicateStream(res, cb) {
|
|
703
703
|
const eventStream = await fetch(url, {
|
704
704
|
method: "GET",
|
705
705
|
headers: {
|
706
|
-
Accept: "text/event-stream"
|
706
|
+
Accept: "text/event-stream",
|
707
|
+
...options == null ? void 0 : options.headers
|
707
708
|
}
|
708
709
|
});
|
709
710
|
return AIStream(eventStream, void 0, cb).pipeThrough(
|
package/dist/index.mjs
CHANGED
@@ -645,7 +645,7 @@ function LangChainStream(callbacks) {
|
|
645
645
|
}
|
646
646
|
|
647
647
|
// streams/replicate-stream.ts
|
648
|
-
async function ReplicateStream(res, cb) {
|
648
|
+
async function ReplicateStream(res, cb, options) {
|
649
649
|
var _a;
|
650
650
|
const url = (_a = res.urls) == null ? void 0 : _a.stream;
|
651
651
|
if (!url) {
|
@@ -657,7 +657,8 @@ async function ReplicateStream(res, cb) {
|
|
657
657
|
const eventStream = await fetch(url, {
|
658
658
|
method: "GET",
|
659
659
|
headers: {
|
660
|
-
Accept: "text/event-stream"
|
660
|
+
Accept: "text/event-stream",
|
661
|
+
...options == null ? void 0 : options.headers
|
661
662
|
}
|
662
663
|
});
|
663
664
|
return AIStream(eventStream, void 0, cb).pipeThrough(
|
package/package.json
CHANGED
package/react/dist/index.d.ts
CHANGED
@@ -264,7 +264,7 @@ type UseChatHelpers = {
|
|
264
264
|
type StreamingReactResponseAction = (payload: {
|
265
265
|
messages: Message[];
|
266
266
|
}) => Promise<experimental_StreamingReactResponse>;
|
267
|
-
declare function useChat({ api, id, initialMessages
|
267
|
+
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, onResponse, onFinish, onError, credentials, headers, body, }?: Omit<UseChatOptions, 'api'> & {
|
268
268
|
api?: string | StreamingReactResponseAction;
|
269
269
|
}): UseChatHelpers;
|
270
270
|
|
package/react/dist/index.js
CHANGED
@@ -332,7 +332,7 @@ var getStreamedResponse = async (api, chatRequest, mutate, mutateStreamData, exi
|
|
332
332
|
function useChat({
|
333
333
|
api = "/api/chat",
|
334
334
|
id,
|
335
|
-
initialMessages
|
335
|
+
initialMessages,
|
336
336
|
initialInput = "",
|
337
337
|
sendExtraMessageFields,
|
338
338
|
experimental_onFunctionCall,
|
@@ -345,9 +345,9 @@ function useChat({
|
|
345
345
|
} = {}) {
|
346
346
|
const hookId = (0, import_react.useId)();
|
347
347
|
const chatId = id || hookId;
|
348
|
-
const [
|
348
|
+
const [initialMessagesFallback] = (0, import_react.useState)([]);
|
349
349
|
const { data: messages, mutate } = (0, import_swr.default)([api, chatId], null, {
|
350
|
-
fallbackData: initialMessages
|
350
|
+
fallbackData: initialMessages != null ? initialMessages : initialMessagesFallback
|
351
351
|
});
|
352
352
|
const { data: isLoading = false, mutate: mutateLoading } = (0, import_swr.default)(
|
353
353
|
[chatId, "loading"],
|
package/react/dist/index.mjs
CHANGED
@@ -296,7 +296,7 @@ var getStreamedResponse = async (api, chatRequest, mutate, mutateStreamData, exi
|
|
296
296
|
function useChat({
|
297
297
|
api = "/api/chat",
|
298
298
|
id,
|
299
|
-
initialMessages
|
299
|
+
initialMessages,
|
300
300
|
initialInput = "",
|
301
301
|
sendExtraMessageFields,
|
302
302
|
experimental_onFunctionCall,
|
@@ -309,9 +309,9 @@ function useChat({
|
|
309
309
|
} = {}) {
|
310
310
|
const hookId = useId();
|
311
311
|
const chatId = id || hookId;
|
312
|
-
const [
|
312
|
+
const [initialMessagesFallback] = useState([]);
|
313
313
|
const { data: messages, mutate } = useSWR([api, chatId], null, {
|
314
|
-
fallbackData: initialMessages
|
314
|
+
fallbackData: initialMessages != null ? initialMessages : initialMessagesFallback
|
315
315
|
});
|
316
316
|
const { data: isLoading = false, mutate: mutateLoading } = useSWR(
|
317
317
|
[chatId, "loading"],
|