ai 2.1.26 → 2.1.27
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 +48 -3
- package/dist/index.js +236 -253
- package/dist/index.mjs +235 -256
- package/package.json +3 -3
- package/react/dist/index.js +177 -197
- package/react/dist/index.mjs +177 -199
- package/react/dist/index.server.js +14 -38
- package/react/dist/index.server.mjs +14 -39
- package/solid/dist/index.js +156 -184
- package/solid/dist/index.mjs +156 -187
- package/svelte/dist/index.d.ts +2 -2
- package/svelte/dist/index.js +232 -236
- package/svelte/dist/index.mjs +232 -239
- package/vue/dist/index.d.ts +2 -2
- package/vue/dist/index.js +153 -177
- package/vue/dist/index.mjs +153 -180
package/dist/index.d.ts
CHANGED
@@ -83,7 +83,12 @@ declare function trimStartOfStreamHelper(): (text: string) => string;
|
|
83
83
|
* @return {ReadableStream} The AIStream.
|
84
84
|
* @throws Will throw an error if the response is not OK.
|
85
85
|
*/
|
86
|
-
declare function AIStream(response: Response, customParser: AIStreamParser, callbacks?: AIStreamCallbacks): ReadableStream
|
86
|
+
declare function AIStream(response: Response, customParser: AIStreamParser, callbacks?: AIStreamCallbacks): ReadableStream<Uint8Array>;
|
87
|
+
/**
|
88
|
+
* Implements ReadableStream.from(asyncIterable), which isn't documented in MDN and isn't implemented in node.
|
89
|
+
* https://github.com/whatwg/streams/commit/8d7a0bf26eb2cc23e884ddbaac7c1da4b91cf2bc
|
90
|
+
*/
|
91
|
+
declare function readableFromAsyncIterable<T>(iterable: AsyncIterable<T>): ReadableStream<T>;
|
87
92
|
|
88
93
|
/**
|
89
94
|
* Shared types between the API and UI packages.
|
@@ -282,7 +287,47 @@ type OpenAIStreamCallbacks = AIStreamCallbacks & {
|
|
282
287
|
*/
|
283
288
|
experimental_onFunctionCall?: (functionCallPayload: FunctionCallPayload, createFunctionCallMessages: (functionCallResult: JSONValue) => CreateMessage[]) => Promise<Response | undefined | void | string>;
|
284
289
|
};
|
285
|
-
|
290
|
+
interface ChatCompletionChunk {
|
291
|
+
id: string;
|
292
|
+
choices: Array<ChatCompletionChunkChoice>;
|
293
|
+
created: number;
|
294
|
+
model: string;
|
295
|
+
object: string;
|
296
|
+
}
|
297
|
+
interface ChatCompletionChunkChoice {
|
298
|
+
delta: ChoiceDelta;
|
299
|
+
finish_reason: 'stop' | 'length' | 'function_call' | null;
|
300
|
+
index: number;
|
301
|
+
}
|
302
|
+
interface ChoiceDelta {
|
303
|
+
/**
|
304
|
+
* The contents of the chunk message.
|
305
|
+
*/
|
306
|
+
content?: string | null;
|
307
|
+
/**
|
308
|
+
* The name and arguments of a function that should be called, as generated by the
|
309
|
+
* model.
|
310
|
+
*/
|
311
|
+
function_call?: FunctionCall;
|
312
|
+
/**
|
313
|
+
* The role of the author of this message.
|
314
|
+
*/
|
315
|
+
role?: 'system' | 'user' | 'assistant' | 'function';
|
316
|
+
}
|
317
|
+
interface FunctionCall {
|
318
|
+
/**
|
319
|
+
* The arguments to call the function with, as generated by the model in JSON
|
320
|
+
* format. Note that the model does not always generate valid JSON, and may
|
321
|
+
* hallucinate parameters not defined by your function schema. Validate the
|
322
|
+
* arguments in your code before calling your function.
|
323
|
+
*/
|
324
|
+
arguments?: string;
|
325
|
+
/**
|
326
|
+
* The name of the function to call.
|
327
|
+
*/
|
328
|
+
name?: string;
|
329
|
+
}
|
330
|
+
declare function OpenAIStream(res: Response | AsyncIterable<ChatCompletionChunk>, callbacks?: OpenAIStreamCallbacks): ReadableStream;
|
286
331
|
|
287
332
|
/**
|
288
333
|
* A utility class for streaming text responses.
|
@@ -323,4 +368,4 @@ declare function LangChainStream(callbacks?: AIStreamCallbacks): {
|
|
323
368
|
declare const nanoid: (size?: number | undefined) => string;
|
324
369
|
declare function createChunkDecoder(): (chunk: Uint8Array | undefined) => string;
|
325
370
|
|
326
|
-
export { AIStream, AIStreamCallbacks, AIStreamParser, AnthropicStream, ChatRequest, ChatRequestOptions, CohereStream, CreateMessage, FunctionCallHandler, FunctionCallPayload, HuggingFaceStream, LangChainStream, Message, OpenAIStream, OpenAIStreamCallbacks, RequestOptions, StreamingTextResponse, UseChatOptions, UseCompletionOptions, createCallbacksTransformer, createChunkDecoder, createEventStreamTransformer, nanoid, streamToResponse, trimStartOfStreamHelper };
|
371
|
+
export { AIStream, AIStreamCallbacks, AIStreamParser, AnthropicStream, ChatRequest, ChatRequestOptions, CohereStream, CreateMessage, FunctionCallHandler, FunctionCallPayload, HuggingFaceStream, LangChainStream, Message, OpenAIStream, OpenAIStreamCallbacks, RequestOptions, StreamingTextResponse, UseChatOptions, UseCompletionOptions, createCallbacksTransformer, createChunkDecoder, createEventStreamTransformer, nanoid, readableFromAsyncIterable, streamToResponse, trimStartOfStreamHelper };
|