ai 4.1.23 → 4.1.25
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +13 -6
- package/dist/index.d.ts +13 -6
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 4.1.25
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 5a21310: fix (ai/core): use ai types on custom provider to prevent ts error
|
8
|
+
|
9
|
+
## 4.1.24
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 38142b8: feat (ai/core): introduce streamText consumeStream
|
14
|
+
|
3
15
|
## 4.1.23
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -2116,6 +2116,13 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
2116
2116
|
*/
|
2117
2117
|
readonly experimental_partialOutputStream: AsyncIterableStream<PARTIAL_OUTPUT>;
|
2118
2118
|
/**
|
2119
|
+
Consumes the stream without processing the parts.
|
2120
|
+
This is useful to force the stream to finish.
|
2121
|
+
It effectively removes the backpressure and allows the stream to finish,
|
2122
|
+
triggering the `onFinish` callback and the promise resolution.
|
2123
|
+
*/
|
2124
|
+
consumeStream(): Promise<void>;
|
2125
|
+
/**
|
2119
2126
|
Converts the result to a data stream.
|
2120
2127
|
|
2121
2128
|
@param data an optional StreamData object that will be merged into the stream.
|
@@ -2541,22 +2548,22 @@ declare const experimental_wrapLanguageModel: ({ model, middleware: middlewareAr
|
|
2541
2548
|
* Creates a custom provider with specified language models, text embedding models, and an optional fallback provider.
|
2542
2549
|
*
|
2543
2550
|
* @param {Object} options - The options for creating the custom provider.
|
2544
|
-
* @param {Record<string,
|
2545
|
-
* @param {Record<string,
|
2551
|
+
* @param {Record<string, LanguageModel>} [options.languageModels] - A record of language models, where keys are model IDs and values are LanguageModel instances.
|
2552
|
+
* @param {Record<string, EmbeddingModel<string>>} [options.textEmbeddingModels] - A record of text embedding models, where keys are model IDs and values are EmbeddingModel<string> instances.
|
2546
2553
|
* @param {Provider} [options.fallbackProvider] - An optional fallback provider to use when a requested model is not found in the custom provider.
|
2547
2554
|
* @returns {Provider} A Provider object with languageModel and textEmbeddingModel methods.
|
2548
2555
|
*
|
2549
2556
|
* @throws {NoSuchModelError} Throws when a requested model is not found and no fallback provider is available.
|
2550
2557
|
*/
|
2551
|
-
declare function customProvider<LANGUAGE_MODELS extends Record<string,
|
2558
|
+
declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModel>, EMBEDDING_MODELS extends Record<string, EmbeddingModel<string>>, IMAGE_MODELS extends Record<string, ImageModel>>({ languageModels, textEmbeddingModels, imageModels, fallbackProvider, }: {
|
2552
2559
|
languageModels?: LANGUAGE_MODELS;
|
2553
2560
|
textEmbeddingModels?: EMBEDDING_MODELS;
|
2554
2561
|
imageModels?: IMAGE_MODELS;
|
2555
2562
|
fallbackProvider?: ProviderV1;
|
2556
2563
|
}): Provider & {
|
2557
|
-
languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>):
|
2558
|
-
textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>):
|
2559
|
-
imageModel(modelId: ExtractModelId<IMAGE_MODELS>):
|
2564
|
+
languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>): LanguageModel;
|
2565
|
+
textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>): EmbeddingModel<string>;
|
2566
|
+
imageModel(modelId: ExtractModelId<IMAGE_MODELS>): ImageModel;
|
2560
2567
|
};
|
2561
2568
|
/**
|
2562
2569
|
* @deprecated Use `customProvider` instead.
|
package/dist/index.d.ts
CHANGED
@@ -2116,6 +2116,13 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
2116
2116
|
*/
|
2117
2117
|
readonly experimental_partialOutputStream: AsyncIterableStream<PARTIAL_OUTPUT>;
|
2118
2118
|
/**
|
2119
|
+
Consumes the stream without processing the parts.
|
2120
|
+
This is useful to force the stream to finish.
|
2121
|
+
It effectively removes the backpressure and allows the stream to finish,
|
2122
|
+
triggering the `onFinish` callback and the promise resolution.
|
2123
|
+
*/
|
2124
|
+
consumeStream(): Promise<void>;
|
2125
|
+
/**
|
2119
2126
|
Converts the result to a data stream.
|
2120
2127
|
|
2121
2128
|
@param data an optional StreamData object that will be merged into the stream.
|
@@ -2541,22 +2548,22 @@ declare const experimental_wrapLanguageModel: ({ model, middleware: middlewareAr
|
|
2541
2548
|
* Creates a custom provider with specified language models, text embedding models, and an optional fallback provider.
|
2542
2549
|
*
|
2543
2550
|
* @param {Object} options - The options for creating the custom provider.
|
2544
|
-
* @param {Record<string,
|
2545
|
-
* @param {Record<string,
|
2551
|
+
* @param {Record<string, LanguageModel>} [options.languageModels] - A record of language models, where keys are model IDs and values are LanguageModel instances.
|
2552
|
+
* @param {Record<string, EmbeddingModel<string>>} [options.textEmbeddingModels] - A record of text embedding models, where keys are model IDs and values are EmbeddingModel<string> instances.
|
2546
2553
|
* @param {Provider} [options.fallbackProvider] - An optional fallback provider to use when a requested model is not found in the custom provider.
|
2547
2554
|
* @returns {Provider} A Provider object with languageModel and textEmbeddingModel methods.
|
2548
2555
|
*
|
2549
2556
|
* @throws {NoSuchModelError} Throws when a requested model is not found and no fallback provider is available.
|
2550
2557
|
*/
|
2551
|
-
declare function customProvider<LANGUAGE_MODELS extends Record<string,
|
2558
|
+
declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModel>, EMBEDDING_MODELS extends Record<string, EmbeddingModel<string>>, IMAGE_MODELS extends Record<string, ImageModel>>({ languageModels, textEmbeddingModels, imageModels, fallbackProvider, }: {
|
2552
2559
|
languageModels?: LANGUAGE_MODELS;
|
2553
2560
|
textEmbeddingModels?: EMBEDDING_MODELS;
|
2554
2561
|
imageModels?: IMAGE_MODELS;
|
2555
2562
|
fallbackProvider?: ProviderV1;
|
2556
2563
|
}): Provider & {
|
2557
|
-
languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>):
|
2558
|
-
textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>):
|
2559
|
-
imageModel(modelId: ExtractModelId<IMAGE_MODELS>):
|
2564
|
+
languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>): LanguageModel;
|
2565
|
+
textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>): EmbeddingModel<string>;
|
2566
|
+
imageModel(modelId: ExtractModelId<IMAGE_MODELS>): ImageModel;
|
2560
2567
|
};
|
2561
2568
|
/**
|
2562
2569
|
* @deprecated Use `customProvider` instead.
|
package/dist/index.js
CHANGED
@@ -5521,6 +5521,11 @@ var DefaultStreamTextResult = class {
|
|
5521
5521
|
)
|
5522
5522
|
);
|
5523
5523
|
}
|
5524
|
+
async consumeStream() {
|
5525
|
+
const stream = this.fullStream;
|
5526
|
+
for await (const part of stream) {
|
5527
|
+
}
|
5528
|
+
}
|
5524
5529
|
get experimental_partialOutputStream() {
|
5525
5530
|
if (this.output == null) {
|
5526
5531
|
throw new NoOutputSpecifiedError();
|