ai 3.3.5 → 3.3.7
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 +95 -64
- package/dist/index.d.ts +95 -64
- package/dist/index.js +253 -230
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +203 -169
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/rsc/dist/index.d.ts +186 -183
- package/rsc/dist/rsc-server.d.mts +185 -183
- package/rsc/dist/rsc-server.mjs +1219 -1248
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.d.mts +24 -22
- package/rsc/dist/rsc-shared.mjs +46 -60
- package/rsc/dist/rsc-shared.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
|
*/
|
@@ -1456,13 +1420,14 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1456
1420
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1457
1421
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1458
1422
|
|
1423
|
+
@param onChunk - Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
1459
1424
|
@param onFinish - Callback that is called when the LLM response and all request tool executions
|
1460
1425
|
(for tools that have an `execute` function) are finished.
|
1461
1426
|
|
1462
1427
|
@return
|
1463
1428
|
A result object for accessing different stream types and additional information.
|
1464
1429
|
*/
|
1465
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, experimental_toolCallStreaming: toolCallStreaming, onFinish, ...settings }: CallSettings & Prompt & {
|
1430
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, experimental_toolCallStreaming: toolCallStreaming, onChunk, onFinish, ...settings }: CallSettings & Prompt & {
|
1466
1431
|
/**
|
1467
1432
|
The language model to use.
|
1468
1433
|
*/
|
@@ -1484,6 +1449,14 @@ Enable streaming of tool call deltas as they are generated. Disabled by default.
|
|
1484
1449
|
*/
|
1485
1450
|
experimental_toolCallStreaming?: boolean;
|
1486
1451
|
/**
|
1452
|
+
Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
1453
|
+
*/
|
1454
|
+
onChunk?: (event: {
|
1455
|
+
chunk: Extract<TextStreamPart<TOOLS>, {
|
1456
|
+
type: 'text-delta' | 'tool-call' | 'tool-call-streaming-start' | 'tool-call-delta' | 'tool-result';
|
1457
|
+
}>;
|
1458
|
+
}) => Promise<void> | void;
|
1459
|
+
/**
|
1487
1460
|
Callback that is called when the LLM response and all request tool executions
|
1488
1461
|
(for tools that have an `execute` function) are finished.
|
1489
1462
|
*/
|
@@ -1525,7 +1498,6 @@ Callback that is called when the LLM response and all request tool executions
|
|
1525
1498
|
}): Promise<DefaultStreamTextResult<TOOLS>>;
|
1526
1499
|
declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> implements StreamTextResult<TOOLS> {
|
1527
1500
|
private originalStream;
|
1528
|
-
private onFinish?;
|
1529
1501
|
readonly warnings: StreamTextResult<TOOLS>['warnings'];
|
1530
1502
|
readonly usage: StreamTextResult<TOOLS>['usage'];
|
1531
1503
|
readonly finishReason: StreamTextResult<TOOLS>['finishReason'];
|
@@ -1533,11 +1505,12 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1533
1505
|
readonly toolCalls: StreamTextResult<TOOLS>['toolCalls'];
|
1534
1506
|
readonly toolResults: StreamTextResult<TOOLS>['toolResults'];
|
1535
1507
|
readonly rawResponse: StreamTextResult<TOOLS>['rawResponse'];
|
1536
|
-
constructor({ stream, warnings, rawResponse, onFinish, rootSpan, doStreamSpan, telemetry, }: {
|
1508
|
+
constructor({ stream, warnings, rawResponse, onChunk, onFinish, rootSpan, doStreamSpan, telemetry, }: {
|
1537
1509
|
stream: ReadableStream<TextStreamPart<TOOLS>>;
|
1538
1510
|
warnings: StreamTextResult<TOOLS>['warnings'];
|
1539
1511
|
rawResponse: StreamTextResult<TOOLS>['rawResponse'];
|
1540
|
-
|
1512
|
+
onChunk: Parameters<typeof streamText>[0]['onChunk'];
|
1513
|
+
onFinish: Parameters<typeof streamText>[0]['onFinish'];
|
1541
1514
|
rootSpan: Span;
|
1542
1515
|
doStreamSpan: Span;
|
1543
1516
|
telemetry: TelemetrySettings | undefined;
|
@@ -1583,13 +1556,22 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1583
1556
|
*/
|
1584
1557
|
declare const experimental_streamText: typeof streamText;
|
1585
1558
|
|
1586
|
-
declare
|
1559
|
+
declare const symbol$a: unique symbol;
|
1560
|
+
declare class InvalidModelIdError extends AISDKError {
|
1561
|
+
private readonly [symbol$a];
|
1587
1562
|
readonly id: string;
|
1588
1563
|
constructor({ id, message, }: {
|
1589
1564
|
id: string;
|
1590
1565
|
message?: string;
|
1591
1566
|
});
|
1567
|
+
static isInstance(error: unknown): error is InvalidModelIdError;
|
1568
|
+
/**
|
1569
|
+
* @deprecated use `isInstance` instead
|
1570
|
+
*/
|
1592
1571
|
static isInvalidModelIdError(error: unknown): error is InvalidModelIdError;
|
1572
|
+
/**
|
1573
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1574
|
+
*/
|
1593
1575
|
toJSON(): {
|
1594
1576
|
name: string;
|
1595
1577
|
message: string;
|
@@ -1598,25 +1580,37 @@ declare class InvalidModelIdError extends Error {
|
|
1598
1580
|
};
|
1599
1581
|
}
|
1600
1582
|
|
1601
|
-
declare
|
1583
|
+
declare const symbol$9: unique symbol;
|
1584
|
+
type ModelType = 'languageModel' | 'textEmbeddingModel';
|
1585
|
+
declare class NoSuchModelError extends AISDKError {
|
1586
|
+
private readonly [symbol$9];
|
1602
1587
|
readonly modelId: string;
|
1603
|
-
readonly modelType:
|
1588
|
+
readonly modelType: ModelType;
|
1604
1589
|
constructor({ modelId, modelType, message, }: {
|
1605
1590
|
modelId: string;
|
1606
|
-
modelType:
|
1591
|
+
modelType: ModelType;
|
1607
1592
|
message?: string;
|
1608
1593
|
});
|
1594
|
+
static isInstance(error: unknown): error is NoSuchModelError;
|
1595
|
+
/**
|
1596
|
+
* @deprecated use `isInstance` instead
|
1597
|
+
*/
|
1609
1598
|
static isNoSuchModelError(error: unknown): error is NoSuchModelError;
|
1599
|
+
/**
|
1600
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1601
|
+
*/
|
1610
1602
|
toJSON(): {
|
1611
1603
|
name: string;
|
1612
1604
|
message: string;
|
1613
1605
|
stack: string | undefined;
|
1614
1606
|
modelId: string;
|
1615
|
-
modelType:
|
1607
|
+
modelType: ModelType;
|
1616
1608
|
};
|
1617
1609
|
}
|
1618
1610
|
|
1619
|
-
declare
|
1611
|
+
declare const symbol$8: unique symbol;
|
1612
|
+
declare class NoSuchProviderError extends AISDKError {
|
1613
|
+
private readonly [symbol$8];
|
1620
1614
|
readonly providerId: string;
|
1621
1615
|
readonly availableProviders: string[];
|
1622
1616
|
constructor({ providerId, availableProviders, message, }: {
|
@@ -1624,7 +1618,14 @@ declare class NoSuchProviderError extends Error {
|
|
1624
1618
|
availableProviders: string[];
|
1625
1619
|
message?: string;
|
1626
1620
|
});
|
1621
|
+
static isInstance(error: unknown): error is NoSuchProviderError;
|
1622
|
+
/**
|
1623
|
+
* @deprecated use `isInstance` instead
|
1624
|
+
*/
|
1627
1625
|
static isNoSuchProviderError(error: unknown): error is NoSuchProviderError;
|
1626
|
+
/**
|
1627
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1628
|
+
*/
|
1628
1629
|
toJSON(): {
|
1629
1630
|
name: string;
|
1630
1631
|
message: string;
|
@@ -1634,6 +1635,50 @@ declare class NoSuchProviderError extends Error {
|
|
1634
1635
|
};
|
1635
1636
|
}
|
1636
1637
|
|
1638
|
+
/**
|
1639
|
+
* Provides for language and text embedding models.
|
1640
|
+
*/
|
1641
|
+
interface experimental_Provider {
|
1642
|
+
/**
|
1643
|
+
Returns the language model with the given id in the format `providerId:modelId`.
|
1644
|
+
The model id is then passed to the provider function to get the model.
|
1645
|
+
|
1646
|
+
@param {string} id - The id of the model to return.
|
1647
|
+
|
1648
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1649
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1650
|
+
|
1651
|
+
@returns {LanguageModel} The language model associated with the id.
|
1652
|
+
*/
|
1653
|
+
languageModel?: (modelId: string) => LanguageModel;
|
1654
|
+
/**
|
1655
|
+
Returns the text embedding model with the given id in the format `providerId:modelId`.
|
1656
|
+
The model id is then passed to the provider function to get the model.
|
1657
|
+
|
1658
|
+
@param {string} id - The id of the model to return.
|
1659
|
+
|
1660
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1661
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1662
|
+
|
1663
|
+
@returns {LanguageModel} The language model associated with the id.
|
1664
|
+
*/
|
1665
|
+
textEmbeddingModel?: (modelId: string) => EmbeddingModel<string>;
|
1666
|
+
/**
|
1667
|
+
Returns the text embedding model with the given id in the format `providerId:modelId`.
|
1668
|
+
The model id is then passed to the provider function to get the model.
|
1669
|
+
|
1670
|
+
@param {string} id - The id of the model to return.
|
1671
|
+
|
1672
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1673
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1674
|
+
|
1675
|
+
@returns {LanguageModel} The language model associated with the id.
|
1676
|
+
|
1677
|
+
@deprecated use `textEmbeddingModel` instead.
|
1678
|
+
*/
|
1679
|
+
textEmbedding?: (modelId: string) => EmbeddingModel<string>;
|
1680
|
+
}
|
1681
|
+
|
1637
1682
|
/**
|
1638
1683
|
Registry for managing models. It enables getting a model with a string id.
|
1639
1684
|
*/
|
@@ -1667,24 +1712,10 @@ type experimental_ProviderRegistry = {
|
|
1667
1712
|
* @deprecated Use `experimental_ProviderRegistry` instead.
|
1668
1713
|
*/
|
1669
1714
|
type experimental_ModelRegistry = experimental_ProviderRegistry;
|
1670
|
-
/**
|
1671
|
-
* Provider for language and text embedding models. Compatible with the
|
1672
|
-
* provider registry.
|
1673
|
-
*/
|
1674
|
-
interface Provider {
|
1675
|
-
/**
|
1676
|
-
* Returns a language model with the given id.
|
1677
|
-
*/
|
1678
|
-
languageModel?: (modelId: string) => LanguageModel;
|
1679
|
-
/**
|
1680
|
-
* Returns a text embedding model with the given id.
|
1681
|
-
*/
|
1682
|
-
textEmbedding?: (modelId: string) => EmbeddingModel<string>;
|
1683
|
-
}
|
1684
1715
|
/**
|
1685
1716
|
* Creates a registry for the given providers.
|
1686
1717
|
*/
|
1687
|
-
declare function experimental_createProviderRegistry(providers: Record<string,
|
1718
|
+
declare function experimental_createProviderRegistry(providers: Record<string, experimental_Provider>): experimental_ProviderRegistry;
|
1688
1719
|
/**
|
1689
1720
|
* @deprecated Use `experimental_createProviderRegistry` instead.
|
1690
1721
|
*/
|
@@ -2678,4 +2709,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2678
2709
|
*/
|
2679
2710
|
declare const nanoid: (size?: number | undefined) => string;
|
2680
2711
|
|
2681
|
-
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,
|
2712
|
+
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
|
*/
|
@@ -1456,13 +1420,14 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1456
1420
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1457
1421
|
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1458
1422
|
|
1423
|
+
@param onChunk - Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
1459
1424
|
@param onFinish - Callback that is called when the LLM response and all request tool executions
|
1460
1425
|
(for tools that have an `execute` function) are finished.
|
1461
1426
|
|
1462
1427
|
@return
|
1463
1428
|
A result object for accessing different stream types and additional information.
|
1464
1429
|
*/
|
1465
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, experimental_toolCallStreaming: toolCallStreaming, onFinish, ...settings }: CallSettings & Prompt & {
|
1430
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, experimental_toolCallStreaming: toolCallStreaming, onChunk, onFinish, ...settings }: CallSettings & Prompt & {
|
1466
1431
|
/**
|
1467
1432
|
The language model to use.
|
1468
1433
|
*/
|
@@ -1484,6 +1449,14 @@ Enable streaming of tool call deltas as they are generated. Disabled by default.
|
|
1484
1449
|
*/
|
1485
1450
|
experimental_toolCallStreaming?: boolean;
|
1486
1451
|
/**
|
1452
|
+
Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
1453
|
+
*/
|
1454
|
+
onChunk?: (event: {
|
1455
|
+
chunk: Extract<TextStreamPart<TOOLS>, {
|
1456
|
+
type: 'text-delta' | 'tool-call' | 'tool-call-streaming-start' | 'tool-call-delta' | 'tool-result';
|
1457
|
+
}>;
|
1458
|
+
}) => Promise<void> | void;
|
1459
|
+
/**
|
1487
1460
|
Callback that is called when the LLM response and all request tool executions
|
1488
1461
|
(for tools that have an `execute` function) are finished.
|
1489
1462
|
*/
|
@@ -1525,7 +1498,6 @@ Callback that is called when the LLM response and all request tool executions
|
|
1525
1498
|
}): Promise<DefaultStreamTextResult<TOOLS>>;
|
1526
1499
|
declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> implements StreamTextResult<TOOLS> {
|
1527
1500
|
private originalStream;
|
1528
|
-
private onFinish?;
|
1529
1501
|
readonly warnings: StreamTextResult<TOOLS>['warnings'];
|
1530
1502
|
readonly usage: StreamTextResult<TOOLS>['usage'];
|
1531
1503
|
readonly finishReason: StreamTextResult<TOOLS>['finishReason'];
|
@@ -1533,11 +1505,12 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1533
1505
|
readonly toolCalls: StreamTextResult<TOOLS>['toolCalls'];
|
1534
1506
|
readonly toolResults: StreamTextResult<TOOLS>['toolResults'];
|
1535
1507
|
readonly rawResponse: StreamTextResult<TOOLS>['rawResponse'];
|
1536
|
-
constructor({ stream, warnings, rawResponse, onFinish, rootSpan, doStreamSpan, telemetry, }: {
|
1508
|
+
constructor({ stream, warnings, rawResponse, onChunk, onFinish, rootSpan, doStreamSpan, telemetry, }: {
|
1537
1509
|
stream: ReadableStream<TextStreamPart<TOOLS>>;
|
1538
1510
|
warnings: StreamTextResult<TOOLS>['warnings'];
|
1539
1511
|
rawResponse: StreamTextResult<TOOLS>['rawResponse'];
|
1540
|
-
|
1512
|
+
onChunk: Parameters<typeof streamText>[0]['onChunk'];
|
1513
|
+
onFinish: Parameters<typeof streamText>[0]['onFinish'];
|
1541
1514
|
rootSpan: Span;
|
1542
1515
|
doStreamSpan: Span;
|
1543
1516
|
telemetry: TelemetrySettings | undefined;
|
@@ -1583,13 +1556,22 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1583
1556
|
*/
|
1584
1557
|
declare const experimental_streamText: typeof streamText;
|
1585
1558
|
|
1586
|
-
declare
|
1559
|
+
declare const symbol$a: unique symbol;
|
1560
|
+
declare class InvalidModelIdError extends AISDKError {
|
1561
|
+
private readonly [symbol$a];
|
1587
1562
|
readonly id: string;
|
1588
1563
|
constructor({ id, message, }: {
|
1589
1564
|
id: string;
|
1590
1565
|
message?: string;
|
1591
1566
|
});
|
1567
|
+
static isInstance(error: unknown): error is InvalidModelIdError;
|
1568
|
+
/**
|
1569
|
+
* @deprecated use `isInstance` instead
|
1570
|
+
*/
|
1592
1571
|
static isInvalidModelIdError(error: unknown): error is InvalidModelIdError;
|
1572
|
+
/**
|
1573
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1574
|
+
*/
|
1593
1575
|
toJSON(): {
|
1594
1576
|
name: string;
|
1595
1577
|
message: string;
|
@@ -1598,25 +1580,37 @@ declare class InvalidModelIdError extends Error {
|
|
1598
1580
|
};
|
1599
1581
|
}
|
1600
1582
|
|
1601
|
-
declare
|
1583
|
+
declare const symbol$9: unique symbol;
|
1584
|
+
type ModelType = 'languageModel' | 'textEmbeddingModel';
|
1585
|
+
declare class NoSuchModelError extends AISDKError {
|
1586
|
+
private readonly [symbol$9];
|
1602
1587
|
readonly modelId: string;
|
1603
|
-
readonly modelType:
|
1588
|
+
readonly modelType: ModelType;
|
1604
1589
|
constructor({ modelId, modelType, message, }: {
|
1605
1590
|
modelId: string;
|
1606
|
-
modelType:
|
1591
|
+
modelType: ModelType;
|
1607
1592
|
message?: string;
|
1608
1593
|
});
|
1594
|
+
static isInstance(error: unknown): error is NoSuchModelError;
|
1595
|
+
/**
|
1596
|
+
* @deprecated use `isInstance` instead
|
1597
|
+
*/
|
1609
1598
|
static isNoSuchModelError(error: unknown): error is NoSuchModelError;
|
1599
|
+
/**
|
1600
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1601
|
+
*/
|
1610
1602
|
toJSON(): {
|
1611
1603
|
name: string;
|
1612
1604
|
message: string;
|
1613
1605
|
stack: string | undefined;
|
1614
1606
|
modelId: string;
|
1615
|
-
modelType:
|
1607
|
+
modelType: ModelType;
|
1616
1608
|
};
|
1617
1609
|
}
|
1618
1610
|
|
1619
|
-
declare
|
1611
|
+
declare const symbol$8: unique symbol;
|
1612
|
+
declare class NoSuchProviderError extends AISDKError {
|
1613
|
+
private readonly [symbol$8];
|
1620
1614
|
readonly providerId: string;
|
1621
1615
|
readonly availableProviders: string[];
|
1622
1616
|
constructor({ providerId, availableProviders, message, }: {
|
@@ -1624,7 +1618,14 @@ declare class NoSuchProviderError extends Error {
|
|
1624
1618
|
availableProviders: string[];
|
1625
1619
|
message?: string;
|
1626
1620
|
});
|
1621
|
+
static isInstance(error: unknown): error is NoSuchProviderError;
|
1622
|
+
/**
|
1623
|
+
* @deprecated use `isInstance` instead
|
1624
|
+
*/
|
1627
1625
|
static isNoSuchProviderError(error: unknown): error is NoSuchProviderError;
|
1626
|
+
/**
|
1627
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
1628
|
+
*/
|
1628
1629
|
toJSON(): {
|
1629
1630
|
name: string;
|
1630
1631
|
message: string;
|
@@ -1634,6 +1635,50 @@ declare class NoSuchProviderError extends Error {
|
|
1634
1635
|
};
|
1635
1636
|
}
|
1636
1637
|
|
1638
|
+
/**
|
1639
|
+
* Provides for language and text embedding models.
|
1640
|
+
*/
|
1641
|
+
interface experimental_Provider {
|
1642
|
+
/**
|
1643
|
+
Returns the language model with the given id in the format `providerId:modelId`.
|
1644
|
+
The model id is then passed to the provider function to get the model.
|
1645
|
+
|
1646
|
+
@param {string} id - The id of the model to return.
|
1647
|
+
|
1648
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1649
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1650
|
+
|
1651
|
+
@returns {LanguageModel} The language model associated with the id.
|
1652
|
+
*/
|
1653
|
+
languageModel?: (modelId: string) => LanguageModel;
|
1654
|
+
/**
|
1655
|
+
Returns the text embedding model with the given id in the format `providerId:modelId`.
|
1656
|
+
The model id is then passed to the provider function to get the model.
|
1657
|
+
|
1658
|
+
@param {string} id - The id of the model to return.
|
1659
|
+
|
1660
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1661
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1662
|
+
|
1663
|
+
@returns {LanguageModel} The language model associated with the id.
|
1664
|
+
*/
|
1665
|
+
textEmbeddingModel?: (modelId: string) => EmbeddingModel<string>;
|
1666
|
+
/**
|
1667
|
+
Returns the text embedding model with the given id in the format `providerId:modelId`.
|
1668
|
+
The model id is then passed to the provider function to get the model.
|
1669
|
+
|
1670
|
+
@param {string} id - The id of the model to return.
|
1671
|
+
|
1672
|
+
@throws {NoSuchModelError} If no model with the given id exists.
|
1673
|
+
@throws {NoSuchProviderError} If no provider with the given id exists.
|
1674
|
+
|
1675
|
+
@returns {LanguageModel} The language model associated with the id.
|
1676
|
+
|
1677
|
+
@deprecated use `textEmbeddingModel` instead.
|
1678
|
+
*/
|
1679
|
+
textEmbedding?: (modelId: string) => EmbeddingModel<string>;
|
1680
|
+
}
|
1681
|
+
|
1637
1682
|
/**
|
1638
1683
|
Registry for managing models. It enables getting a model with a string id.
|
1639
1684
|
*/
|
@@ -1667,24 +1712,10 @@ type experimental_ProviderRegistry = {
|
|
1667
1712
|
* @deprecated Use `experimental_ProviderRegistry` instead.
|
1668
1713
|
*/
|
1669
1714
|
type experimental_ModelRegistry = experimental_ProviderRegistry;
|
1670
|
-
/**
|
1671
|
-
* Provider for language and text embedding models. Compatible with the
|
1672
|
-
* provider registry.
|
1673
|
-
*/
|
1674
|
-
interface Provider {
|
1675
|
-
/**
|
1676
|
-
* Returns a language model with the given id.
|
1677
|
-
*/
|
1678
|
-
languageModel?: (modelId: string) => LanguageModel;
|
1679
|
-
/**
|
1680
|
-
* Returns a text embedding model with the given id.
|
1681
|
-
*/
|
1682
|
-
textEmbedding?: (modelId: string) => EmbeddingModel<string>;
|
1683
|
-
}
|
1684
1715
|
/**
|
1685
1716
|
* Creates a registry for the given providers.
|
1686
1717
|
*/
|
1687
|
-
declare function experimental_createProviderRegistry(providers: Record<string,
|
1718
|
+
declare function experimental_createProviderRegistry(providers: Record<string, experimental_Provider>): experimental_ProviderRegistry;
|
1688
1719
|
/**
|
1689
1720
|
* @deprecated Use `experimental_createProviderRegistry` instead.
|
1690
1721
|
*/
|
@@ -2678,4 +2709,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2678
2709
|
*/
|
2679
2710
|
declare const nanoid: (size?: number | undefined) => string;
|
2680
2711
|
|
2681
|
-
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,
|
2712
|
+
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 };
|