ai 3.3.4 → 3.3.6
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 +84 -60
- package/dist/index.d.ts +84 -60
- package/dist/index.js +241 -215
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +192 -155
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/rsc/dist/rsc-server.mjs +5 -37
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.d.mts
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
import { DeepPartial, Attachment, JSONValue, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
|
2
|
-
export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, parseComplexResponse, parseStreamPart, readDataStream } from '@ai-sdk/ui-utils';
|
1
|
+
import { Schema, DeepPartial, Attachment, JSONValue, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
|
2
|
+
export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, Schema, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, jsonSchema, parseComplexResponse, parseStreamPart, readDataStream } from '@ai-sdk/ui-utils';
|
3
3
|
import { AttributeValue, Span } from '@opentelemetry/api';
|
4
4
|
import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1CallWarning, LanguageModelV1StreamPart, AISDKError } from '@ai-sdk/provider';
|
5
5
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LoadAPIKeyError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
6
6
|
import { z } from 'zod';
|
7
|
-
import { Validator } from '@ai-sdk/provider-utils';
|
8
|
-
import { JSONSchema7 } from 'json-schema';
|
9
7
|
import { ServerResponse } from 'http';
|
10
8
|
import { ServerResponse as ServerResponse$1 } from 'node:http';
|
11
9
|
import { AssistantStream } from 'openai/lib/AssistantStream';
|
@@ -514,40 +512,6 @@ type Prompt = {
|
|
514
512
|
messages?: Array<CoreMessage>;
|
515
513
|
};
|
516
514
|
|
517
|
-
/**
|
518
|
-
* Used to mark schemas so we can support both Zod and custom schemas.
|
519
|
-
*/
|
520
|
-
declare const schemaSymbol: unique symbol;
|
521
|
-
type Schema<OBJECT = unknown> = Validator<OBJECT> & {
|
522
|
-
/**
|
523
|
-
* Used to mark schemas so we can support both Zod and custom schemas.
|
524
|
-
*/
|
525
|
-
[schemaSymbol]: true;
|
526
|
-
/**
|
527
|
-
* Schema type for inference.
|
528
|
-
*/
|
529
|
-
_type: OBJECT;
|
530
|
-
/**
|
531
|
-
* The JSON Schema for the schema. It is passed to the providers.
|
532
|
-
*/
|
533
|
-
readonly jsonSchema: JSONSchema7;
|
534
|
-
};
|
535
|
-
/**
|
536
|
-
* Create a schema using a JSON Schema.
|
537
|
-
*
|
538
|
-
* @param jsonSchema The JSON Schema for the schema.
|
539
|
-
* @param options.validate Optional. A validation function for the schema.
|
540
|
-
*/
|
541
|
-
declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validate, }?: {
|
542
|
-
validate?: (value: unknown) => {
|
543
|
-
success: true;
|
544
|
-
value: OBJECT;
|
545
|
-
} | {
|
546
|
-
success: false;
|
547
|
-
error: Error;
|
548
|
-
};
|
549
|
-
}): Schema<OBJECT>;
|
550
|
-
|
551
515
|
/**
|
552
516
|
The result of a `generateObject` call.
|
553
517
|
*/
|
@@ -1554,6 +1518,7 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1554
1518
|
get textStream(): AsyncIterableStream<string>;
|
1555
1519
|
get fullStream(): AsyncIterableStream<TextStreamPart<TOOLS>>;
|
1556
1520
|
toAIStream(callbacks?: AIStreamCallbacksAndOptions): ReadableStream<Uint8Array>;
|
1521
|
+
private toDataStream;
|
1557
1522
|
pipeAIStreamToResponse(response: ServerResponse$1, init?: {
|
1558
1523
|
headers?: Record<string, string>;
|
1559
1524
|
status?: number;
|
@@ -1573,6 +1538,7 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1573
1538
|
toDataStreamResponse(options?: ResponseInit | {
|
1574
1539
|
init?: ResponseInit;
|
1575
1540
|
data?: StreamData;
|
1541
|
+
getErrorMessage?: (error: unknown) => string;
|
1576
1542
|
}): Response;
|
1577
1543
|
toTextStreamResponse(init?: ResponseInit): Response;
|
1578
1544
|
}
|
@@ -1581,13 +1547,22 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1581
1547
|
*/
|
1582
1548
|
declare const experimental_streamText: typeof streamText;
|
1583
1549
|
|
1584
|
-
declare
|
1550
|
+
declare const symbol$a: unique symbol;
|
1551
|
+
declare class InvalidModelIdError extends AISDKError {
|
1552
|
+
private readonly [symbol$a];
|
1585
1553
|
readonly id: string;
|
1586
1554
|
constructor({ id, message, }: {
|
1587
1555
|
id: string;
|
1588
1556
|
message?: string;
|
1589
1557
|
});
|
1558
|
+
static isInstance(error: unknown): error is InvalidModelIdError;
|
1559
|
+
/**
|
1560
|
+
* @deprecated use `isInstance` instead
|
1561
|
+
*/
|
1590
1562
|
static isInvalidModelIdError(error: unknown): error is InvalidModelIdError;
|
1563
|
+
/**
|
1564
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1565
|
+
*/
|
1591
1566
|
toJSON(): {
|
1592
1567
|
name: string;
|
1593
1568
|
message: string;
|
@@ -1596,25 +1571,37 @@ declare class InvalidModelIdError extends Error {
|
|
1596
1571
|
};
|
1597
1572
|
}
|
1598
1573
|
|
1599
|
-
declare
|
1574
|
+
declare const symbol$9: unique symbol;
|
1575
|
+
type ModelType = 'languageModel' | 'textEmbeddingModel';
|
1576
|
+
declare class NoSuchModelError extends AISDKError {
|
1577
|
+
private readonly [symbol$9];
|
1600
1578
|
readonly modelId: string;
|
1601
|
-
readonly modelType:
|
1579
|
+
readonly modelType: ModelType;
|
1602
1580
|
constructor({ modelId, modelType, message, }: {
|
1603
1581
|
modelId: string;
|
1604
|
-
modelType:
|
1582
|
+
modelType: ModelType;
|
1605
1583
|
message?: string;
|
1606
1584
|
});
|
1585
|
+
static isInstance(error: unknown): error is NoSuchModelError;
|
1586
|
+
/**
|
1587
|
+
* @deprecated use `isInstance` instead
|
1588
|
+
*/
|
1607
1589
|
static isNoSuchModelError(error: unknown): error is NoSuchModelError;
|
1590
|
+
/**
|
1591
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1592
|
+
*/
|
1608
1593
|
toJSON(): {
|
1609
1594
|
name: string;
|
1610
1595
|
message: string;
|
1611
1596
|
stack: string | undefined;
|
1612
1597
|
modelId: string;
|
1613
|
-
modelType:
|
1598
|
+
modelType: ModelType;
|
1614
1599
|
};
|
1615
1600
|
}
|
1616
1601
|
|
1617
|
-
declare
|
1602
|
+
declare const symbol$8: unique symbol;
|
1603
|
+
declare class NoSuchProviderError extends AISDKError {
|
1604
|
+
private readonly [symbol$8];
|
1618
1605
|
readonly providerId: string;
|
1619
1606
|
readonly availableProviders: string[];
|
1620
1607
|
constructor({ providerId, availableProviders, message, }: {
|
@@ -1622,7 +1609,14 @@ declare class NoSuchProviderError extends Error {
|
|
1622
1609
|
availableProviders: string[];
|
1623
1610
|
message?: string;
|
1624
1611
|
});
|
1612
|
+
static isInstance(error: unknown): error is NoSuchProviderError;
|
1613
|
+
/**
|
1614
|
+
* @deprecated use `isInstance` instead
|
1615
|
+
*/
|
1625
1616
|
static isNoSuchProviderError(error: unknown): error is NoSuchProviderError;
|
1617
|
+
/**
|
1618
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1619
|
+
*/
|
1626
1620
|
toJSON(): {
|
1627
1621
|
name: string;
|
1628
1622
|
message: string;
|
@@ -1632,6 +1626,50 @@ declare class NoSuchProviderError extends Error {
|
|
1632
1626
|
};
|
1633
1627
|
}
|
1634
1628
|
|
1629
|
+
/**
|
1630
|
+
* Provides for language and text embedding models.
|
1631
|
+
*/
|
1632
|
+
interface experimental_Provider {
|
1633
|
+
/**
|
1634
|
+
Returns the language model with the given id in the format `providerId:modelId`.
|
1635
|
+
The model id is then passed to the provider function to get the model.
|
1636
|
+
|
1637
|
+
@param {string} id - The id of the model to return.
|
1638
|
+
|
1639
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1640
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1641
|
+
|
1642
|
+
@returns {LanguageModel} The language model associated with the id.
|
1643
|
+
*/
|
1644
|
+
languageModel?: (modelId: string) => LanguageModel;
|
1645
|
+
/**
|
1646
|
+
Returns the text embedding model with the given id in the format `providerId:modelId`.
|
1647
|
+
The model id is then passed to the provider function to get the model.
|
1648
|
+
|
1649
|
+
@param {string} id - The id of the model to return.
|
1650
|
+
|
1651
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1652
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1653
|
+
|
1654
|
+
@returns {LanguageModel} The language model associated with the id.
|
1655
|
+
*/
|
1656
|
+
textEmbeddingModel?: (modelId: string) => EmbeddingModel<string>;
|
1657
|
+
/**
|
1658
|
+
Returns the text embedding model with the given id in the format `providerId:modelId`.
|
1659
|
+
The model id is then passed to the provider function to get the model.
|
1660
|
+
|
1661
|
+
@param {string} id - The id of the model to return.
|
1662
|
+
|
1663
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1664
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1665
|
+
|
1666
|
+
@returns {LanguageModel} The language model associated with the id.
|
1667
|
+
|
1668
|
+
@deprecated use `textEmbeddingModel` instead.
|
1669
|
+
*/
|
1670
|
+
textEmbedding?: (modelId: string) => EmbeddingModel<string>;
|
1671
|
+
}
|
1672
|
+
|
1635
1673
|
/**
|
1636
1674
|
Registry for managing models. It enables getting a model with a string id.
|
1637
1675
|
*/
|
@@ -1665,24 +1703,10 @@ type experimental_ProviderRegistry = {
|
|
1665
1703
|
* @deprecated Use `experimental_ProviderRegistry` instead.
|
1666
1704
|
*/
|
1667
1705
|
type experimental_ModelRegistry = experimental_ProviderRegistry;
|
1668
|
-
/**
|
1669
|
-
* Provider for language and text embedding models. Compatible with the
|
1670
|
-
* provider registry.
|
1671
|
-
*/
|
1672
|
-
interface Provider {
|
1673
|
-
/**
|
1674
|
-
* Returns a language model with the given id.
|
1675
|
-
*/
|
1676
|
-
languageModel?: (modelId: string) => LanguageModel;
|
1677
|
-
/**
|
1678
|
-
* Returns a text embedding model with the given id.
|
1679
|
-
*/
|
1680
|
-
textEmbedding?: (modelId: string) => EmbeddingModel<string>;
|
1681
|
-
}
|
1682
1706
|
/**
|
1683
1707
|
* Creates a registry for the given providers.
|
1684
1708
|
*/
|
1685
|
-
declare function experimental_createProviderRegistry(providers: Record<string,
|
1709
|
+
declare function experimental_createProviderRegistry(providers: Record<string, experimental_Provider>): experimental_ProviderRegistry;
|
1686
1710
|
/**
|
1687
1711
|
* @deprecated Use `experimental_createProviderRegistry` instead.
|
1688
1712
|
*/
|
@@ -2676,4 +2700,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2676
2700
|
*/
|
2677
2701
|
declare const nanoid: (size?: number | undefined) => string;
|
2678
2702
|
|
2679
|
-
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidModelIdError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, NoObjectGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, RetryError,
|
2703
|
+
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidModelIdError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, ModelType, NoObjectGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, RetryError, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertDataContentToBase64String, convertDataContentToUint8Array, convertToCoreMessages, convertUint8ArrayToText, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_Provider, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|
package/dist/index.d.ts
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
import { DeepPartial, Attachment, JSONValue, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
|
2
|
-
export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, parseComplexResponse, parseStreamPart, readDataStream } from '@ai-sdk/ui-utils';
|
1
|
+
import { Schema, DeepPartial, Attachment, JSONValue, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
|
2
|
+
export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, Schema, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, jsonSchema, parseComplexResponse, parseStreamPart, readDataStream } from '@ai-sdk/ui-utils';
|
3
3
|
import { AttributeValue, Span } from '@opentelemetry/api';
|
4
4
|
import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1CallWarning, LanguageModelV1StreamPart, AISDKError } from '@ai-sdk/provider';
|
5
5
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LoadAPIKeyError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
6
6
|
import { z } from 'zod';
|
7
|
-
import { Validator } from '@ai-sdk/provider-utils';
|
8
|
-
import { JSONSchema7 } from 'json-schema';
|
9
7
|
import { ServerResponse } from 'http';
|
10
8
|
import { ServerResponse as ServerResponse$1 } from 'node:http';
|
11
9
|
import { AssistantStream } from 'openai/lib/AssistantStream';
|
@@ -514,40 +512,6 @@ type Prompt = {
|
|
514
512
|
messages?: Array<CoreMessage>;
|
515
513
|
};
|
516
514
|
|
517
|
-
/**
|
518
|
-
* Used to mark schemas so we can support both Zod and custom schemas.
|
519
|
-
*/
|
520
|
-
declare const schemaSymbol: unique symbol;
|
521
|
-
type Schema<OBJECT = unknown> = Validator<OBJECT> & {
|
522
|
-
/**
|
523
|
-
* Used to mark schemas so we can support both Zod and custom schemas.
|
524
|
-
*/
|
525
|
-
[schemaSymbol]: true;
|
526
|
-
/**
|
527
|
-
* Schema type for inference.
|
528
|
-
*/
|
529
|
-
_type: OBJECT;
|
530
|
-
/**
|
531
|
-
* The JSON Schema for the schema. It is passed to the providers.
|
532
|
-
*/
|
533
|
-
readonly jsonSchema: JSONSchema7;
|
534
|
-
};
|
535
|
-
/**
|
536
|
-
* Create a schema using a JSON Schema.
|
537
|
-
*
|
538
|
-
* @param jsonSchema The JSON Schema for the schema.
|
539
|
-
* @param options.validate Optional. A validation function for the schema.
|
540
|
-
*/
|
541
|
-
declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validate, }?: {
|
542
|
-
validate?: (value: unknown) => {
|
543
|
-
success: true;
|
544
|
-
value: OBJECT;
|
545
|
-
} | {
|
546
|
-
success: false;
|
547
|
-
error: Error;
|
548
|
-
};
|
549
|
-
}): Schema<OBJECT>;
|
550
|
-
|
551
515
|
/**
|
552
516
|
The result of a `generateObject` call.
|
553
517
|
*/
|
@@ -1554,6 +1518,7 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1554
1518
|
get textStream(): AsyncIterableStream<string>;
|
1555
1519
|
get fullStream(): AsyncIterableStream<TextStreamPart<TOOLS>>;
|
1556
1520
|
toAIStream(callbacks?: AIStreamCallbacksAndOptions): ReadableStream<Uint8Array>;
|
1521
|
+
private toDataStream;
|
1557
1522
|
pipeAIStreamToResponse(response: ServerResponse$1, init?: {
|
1558
1523
|
headers?: Record<string, string>;
|
1559
1524
|
status?: number;
|
@@ -1573,6 +1538,7 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1573
1538
|
toDataStreamResponse(options?: ResponseInit | {
|
1574
1539
|
init?: ResponseInit;
|
1575
1540
|
data?: StreamData;
|
1541
|
+
getErrorMessage?: (error: unknown) => string;
|
1576
1542
|
}): Response;
|
1577
1543
|
toTextStreamResponse(init?: ResponseInit): Response;
|
1578
1544
|
}
|
@@ -1581,13 +1547,22 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1581
1547
|
*/
|
1582
1548
|
declare const experimental_streamText: typeof streamText;
|
1583
1549
|
|
1584
|
-
declare
|
1550
|
+
declare const symbol$a: unique symbol;
|
1551
|
+
declare class InvalidModelIdError extends AISDKError {
|
1552
|
+
private readonly [symbol$a];
|
1585
1553
|
readonly id: string;
|
1586
1554
|
constructor({ id, message, }: {
|
1587
1555
|
id: string;
|
1588
1556
|
message?: string;
|
1589
1557
|
});
|
1558
|
+
static isInstance(error: unknown): error is InvalidModelIdError;
|
1559
|
+
/**
|
1560
|
+
* @deprecated use `isInstance` instead
|
1561
|
+
*/
|
1590
1562
|
static isInvalidModelIdError(error: unknown): error is InvalidModelIdError;
|
1563
|
+
/**
|
1564
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1565
|
+
*/
|
1591
1566
|
toJSON(): {
|
1592
1567
|
name: string;
|
1593
1568
|
message: string;
|
@@ -1596,25 +1571,37 @@ declare class InvalidModelIdError extends Error {
|
|
1596
1571
|
};
|
1597
1572
|
}
|
1598
1573
|
|
1599
|
-
declare
|
1574
|
+
declare const symbol$9: unique symbol;
|
1575
|
+
type ModelType = 'languageModel' | 'textEmbeddingModel';
|
1576
|
+
declare class NoSuchModelError extends AISDKError {
|
1577
|
+
private readonly [symbol$9];
|
1600
1578
|
readonly modelId: string;
|
1601
|
-
readonly modelType:
|
1579
|
+
readonly modelType: ModelType;
|
1602
1580
|
constructor({ modelId, modelType, message, }: {
|
1603
1581
|
modelId: string;
|
1604
|
-
modelType:
|
1582
|
+
modelType: ModelType;
|
1605
1583
|
message?: string;
|
1606
1584
|
});
|
1585
|
+
static isInstance(error: unknown): error is NoSuchModelError;
|
1586
|
+
/**
|
1587
|
+
* @deprecated use `isInstance` instead
|
1588
|
+
*/
|
1607
1589
|
static isNoSuchModelError(error: unknown): error is NoSuchModelError;
|
1590
|
+
/**
|
1591
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1592
|
+
*/
|
1608
1593
|
toJSON(): {
|
1609
1594
|
name: string;
|
1610
1595
|
message: string;
|
1611
1596
|
stack: string | undefined;
|
1612
1597
|
modelId: string;
|
1613
|
-
modelType:
|
1598
|
+
modelType: ModelType;
|
1614
1599
|
};
|
1615
1600
|
}
|
1616
1601
|
|
1617
|
-
declare
|
1602
|
+
declare const symbol$8: unique symbol;
|
1603
|
+
declare class NoSuchProviderError extends AISDKError {
|
1604
|
+
private readonly [symbol$8];
|
1618
1605
|
readonly providerId: string;
|
1619
1606
|
readonly availableProviders: string[];
|
1620
1607
|
constructor({ providerId, availableProviders, message, }: {
|
@@ -1622,7 +1609,14 @@ declare class NoSuchProviderError extends Error {
|
|
1622
1609
|
availableProviders: string[];
|
1623
1610
|
message?: string;
|
1624
1611
|
});
|
1612
|
+
static isInstance(error: unknown): error is NoSuchProviderError;
|
1613
|
+
/**
|
1614
|
+
* @deprecated use `isInstance` instead
|
1615
|
+
*/
|
1625
1616
|
static isNoSuchProviderError(error: unknown): error is NoSuchProviderError;
|
1617
|
+
/**
|
1618
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1619
|
+
*/
|
1626
1620
|
toJSON(): {
|
1627
1621
|
name: string;
|
1628
1622
|
message: string;
|
@@ -1632,6 +1626,50 @@ declare class NoSuchProviderError extends Error {
|
|
1632
1626
|
};
|
1633
1627
|
}
|
1634
1628
|
|
1629
|
+
/**
|
1630
|
+
* Provides for language and text embedding models.
|
1631
|
+
*/
|
1632
|
+
interface experimental_Provider {
|
1633
|
+
/**
|
1634
|
+
Returns the language model with the given id in the format `providerId:modelId`.
|
1635
|
+
The model id is then passed to the provider function to get the model.
|
1636
|
+
|
1637
|
+
@param {string} id - The id of the model to return.
|
1638
|
+
|
1639
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1640
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1641
|
+
|
1642
|
+
@returns {LanguageModel} The language model associated with the id.
|
1643
|
+
*/
|
1644
|
+
languageModel?: (modelId: string) => LanguageModel;
|
1645
|
+
/**
|
1646
|
+
Returns the text embedding model with the given id in the format `providerId:modelId`.
|
1647
|
+
The model id is then passed to the provider function to get the model.
|
1648
|
+
|
1649
|
+
@param {string} id - The id of the model to return.
|
1650
|
+
|
1651
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1652
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1653
|
+
|
1654
|
+
@returns {LanguageModel} The language model associated with the id.
|
1655
|
+
*/
|
1656
|
+
textEmbeddingModel?: (modelId: string) => EmbeddingModel<string>;
|
1657
|
+
/**
|
1658
|
+
Returns the text embedding model with the given id in the format `providerId:modelId`.
|
1659
|
+
The model id is then passed to the provider function to get the model.
|
1660
|
+
|
1661
|
+
@param {string} id - The id of the model to return.
|
1662
|
+
|
1663
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1664
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1665
|
+
|
1666
|
+
@returns {LanguageModel} The language model associated with the id.
|
1667
|
+
|
1668
|
+
@deprecated use `textEmbeddingModel` instead.
|
1669
|
+
*/
|
1670
|
+
textEmbedding?: (modelId: string) => EmbeddingModel<string>;
|
1671
|
+
}
|
1672
|
+
|
1635
1673
|
/**
|
1636
1674
|
Registry for managing models. It enables getting a model with a string id.
|
1637
1675
|
*/
|
@@ -1665,24 +1703,10 @@ type experimental_ProviderRegistry = {
|
|
1665
1703
|
* @deprecated Use `experimental_ProviderRegistry` instead.
|
1666
1704
|
*/
|
1667
1705
|
type experimental_ModelRegistry = experimental_ProviderRegistry;
|
1668
|
-
/**
|
1669
|
-
* Provider for language and text embedding models. Compatible with the
|
1670
|
-
* provider registry.
|
1671
|
-
*/
|
1672
|
-
interface Provider {
|
1673
|
-
/**
|
1674
|
-
* Returns a language model with the given id.
|
1675
|
-
*/
|
1676
|
-
languageModel?: (modelId: string) => LanguageModel;
|
1677
|
-
/**
|
1678
|
-
* Returns a text embedding model with the given id.
|
1679
|
-
*/
|
1680
|
-
textEmbedding?: (modelId: string) => EmbeddingModel<string>;
|
1681
|
-
}
|
1682
1706
|
/**
|
1683
1707
|
* Creates a registry for the given providers.
|
1684
1708
|
*/
|
1685
|
-
declare function experimental_createProviderRegistry(providers: Record<string,
|
1709
|
+
declare function experimental_createProviderRegistry(providers: Record<string, experimental_Provider>): experimental_ProviderRegistry;
|
1686
1710
|
/**
|
1687
1711
|
* @deprecated Use `experimental_createProviderRegistry` instead.
|
1688
1712
|
*/
|
@@ -2676,4 +2700,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2676
2700
|
*/
|
2677
2701
|
declare const nanoid: (size?: number | undefined) => string;
|
2678
2702
|
|
2679
|
-
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidModelIdError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, NoObjectGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, RetryError,
|
2703
|
+
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidModelIdError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, ModelType, NoObjectGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, RetryError, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertDataContentToBase64String, convertDataContentToUint8Array, convertToCoreMessages, convertUint8ArrayToText, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_Provider, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|