ai 3.3.41 → 3.3.43

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # ai
2
2
 
3
+ ## 3.3.43
4
+
5
+ ### Patch Changes
6
+
7
+ - fea6bec: fix (ai/core): support tool calls without arguments
8
+
9
+ ## 3.3.42
10
+
11
+ ### Patch Changes
12
+
13
+ - de37aee: feat (ai): Add support for LlamaIndex
14
+
3
15
  ## 3.3.41
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -185,7 +185,7 @@ type EmbeddingTokenUsage = EmbeddingModelUsage$1;
185
185
  type EmbeddingModelUsage = EmbeddingModelUsage$1;
186
186
 
187
187
  /**
188
- The result of a `embed` call.
188
+ The result of an `embed` call.
189
189
  It contains the embedding, the value, and additional information.
190
190
  */
191
191
  interface EmbedResult<VALUE> {
@@ -615,7 +615,7 @@ interface GenerateObjectResult<T> {
615
615
  */
616
616
  readonly usage: LanguageModelUsage$1;
617
617
  /**
618
- Warnings from the model provider (e.g. unsupported settings)
618
+ Warnings from the model provider (e.g. unsupported settings).
619
619
  */
620
620
  readonly warnings: CallWarning[] | undefined;
621
621
  /**
@@ -686,11 +686,11 @@ via tool or schema description.
686
686
  /**
687
687
  The mode to use for object generation.
688
688
 
689
- The schema is converted in a JSON schema and used in one of the following ways
689
+ The schema is converted into a JSON schema and used in one of the following ways
690
690
 
691
691
  - 'auto': The provider will choose the best mode for the model.
692
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
693
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
692
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
693
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
694
694
 
695
695
  Please note that most providers do not support all modes.
696
696
 
@@ -748,11 +748,11 @@ via tool or schema description.
748
748
  /**
749
749
  The mode to use for object generation.
750
750
 
751
- The schema is converted in a JSON schema and used in one of the following ways
751
+ The schema is converted into a JSON schema and used in one of the following ways
752
752
 
753
753
  - 'auto': The provider will choose the best mode for the model.
754
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
755
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
754
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
755
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
756
756
 
757
757
  Please note that most providers do not support all modes.
758
758
 
@@ -798,11 +798,11 @@ The enum values that the model should use.
798
798
  /**
799
799
  The mode to use for object generation.
800
800
 
801
- The schema is converted in a JSON schema and used in one of the following ways
801
+ The schema is converted into a JSON schema and used in one of the following ways
802
802
 
803
803
  - 'auto': The provider will choose the best mode for the model.
804
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
805
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
804
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
805
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
806
806
 
807
807
  Please note that most providers do not support all modes.
808
808
 
@@ -1037,11 +1037,11 @@ via tool or schema description.
1037
1037
  /**
1038
1038
  The mode to use for object generation.
1039
1039
 
1040
- The schema is converted in a JSON schema and used in one of the following ways
1040
+ The schema is converted into a JSON schema and used in one of the following ways
1041
1041
 
1042
1042
  - 'auto': The provider will choose the best mode for the model.
1043
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
1044
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
1043
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
1044
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
1045
1045
 
1046
1046
  Please note that most providers do not support all modes.
1047
1047
 
@@ -1104,11 +1104,11 @@ via tool or schema description.
1104
1104
  /**
1105
1105
  The mode to use for object generation.
1106
1106
 
1107
- The schema is converted in a JSON schema and used in one of the following ways
1107
+ The schema is converted into a JSON schema and used in one of the following ways
1108
1108
 
1109
1109
  - 'auto': The provider will choose the best mode for the model.
1110
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
1111
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
1110
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
1111
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
1112
1112
 
1113
1113
  Please note that most providers do not support all modes.
1114
1114
 
@@ -1333,7 +1333,7 @@ type StepResult<TOOLS extends Record<string, CoreTool>> = {
1333
1333
  */
1334
1334
  readonly usage: LanguageModelUsage$1;
1335
1335
  /**
1336
- Warnings from the model provider (e.g. unsupported settings)
1336
+ Warnings from the model provider (e.g. unsupported settings).
1337
1337
  */
1338
1338
  readonly warnings: CallWarning[] | undefined;
1339
1339
  /**
@@ -2964,21 +2964,38 @@ The following streams are supported:
2964
2964
  - `LangChainAIMessageChunk` streams (LangChain `model.stream` output)
2965
2965
  - `string` streams (LangChain `StringOutputParser` output)
2966
2966
  */
2967
- declare function toDataStream(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2968
- declare function toDataStreamResponse(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, options?: {
2967
+ declare function toDataStream$1(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2968
+ declare function toDataStreamResponse$1(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, options?: {
2969
2969
  init?: ResponseInit;
2970
2970
  data?: StreamData;
2971
2971
  callbacks?: AIStreamCallbacksAndOptions;
2972
2972
  }): Response;
2973
2973
 
2974
2974
  declare const langchainAdapter_toAIStream: typeof toAIStream;
2975
- declare const langchainAdapter_toDataStream: typeof toDataStream;
2976
- declare const langchainAdapter_toDataStreamResponse: typeof toDataStreamResponse;
2977
2975
  declare namespace langchainAdapter {
2978
2976
  export {
2979
2977
  langchainAdapter_toAIStream as toAIStream,
2980
- langchainAdapter_toDataStream as toDataStream,
2981
- langchainAdapter_toDataStreamResponse as toDataStreamResponse,
2978
+ toDataStream$1 as toDataStream,
2979
+ toDataStreamResponse$1 as toDataStreamResponse,
2980
+ };
2981
+ }
2982
+
2983
+ type EngineResponse = {
2984
+ delta: string;
2985
+ };
2986
+ declare function toDataStream(stream: AsyncIterable<EngineResponse>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2987
+ declare function toDataStreamResponse(stream: AsyncIterable<EngineResponse>, options?: {
2988
+ init?: ResponseInit;
2989
+ data?: StreamData;
2990
+ callbacks?: AIStreamCallbacksAndOptions;
2991
+ }): Response;
2992
+
2993
+ declare const llamaindexAdapter_toDataStream: typeof toDataStream;
2994
+ declare const llamaindexAdapter_toDataStreamResponse: typeof toDataStreamResponse;
2995
+ declare namespace llamaindexAdapter {
2996
+ export {
2997
+ llamaindexAdapter_toDataStream as toDataStream,
2998
+ llamaindexAdapter_toDataStreamResponse as toDataStreamResponse,
2982
2999
  };
2983
3000
  }
2984
3001
 
@@ -3108,4 +3125,4 @@ declare const generateId: (size?: number) => string;
3108
3125
  */
3109
3126
  declare const nanoid: (size?: number) => string;
3110
3127
 
3111
- 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, EmbeddingModelUsage, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, Experimental_LanguageModelV1Middleware, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LanguageModelResponseMetadata, LanguageModelResponseMetadataWithHeaders, LanguageModelUsage, LogProbs, MessageConversionError, MistralStream, NoObjectGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, Provider, ProviderMetadata, ReplicateStream, RetryError, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertToCoreMessages, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_Provider, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_customProvider, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, experimental_wrapLanguageModel, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
3128
+ 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, EmbeddingModelUsage, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, Experimental_LanguageModelV1Middleware, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LanguageModelResponseMetadata, LanguageModelResponseMetadataWithHeaders, LanguageModelUsage, llamaindexAdapter as LlamaIndexAdapter, LogProbs, MessageConversionError, MistralStream, NoObjectGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, Provider, ProviderMetadata, ReplicateStream, RetryError, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertToCoreMessages, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_Provider, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_customProvider, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, experimental_wrapLanguageModel, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
package/dist/index.d.ts CHANGED
@@ -185,7 +185,7 @@ type EmbeddingTokenUsage = EmbeddingModelUsage$1;
185
185
  type EmbeddingModelUsage = EmbeddingModelUsage$1;
186
186
 
187
187
  /**
188
- The result of a `embed` call.
188
+ The result of an `embed` call.
189
189
  It contains the embedding, the value, and additional information.
190
190
  */
191
191
  interface EmbedResult<VALUE> {
@@ -615,7 +615,7 @@ interface GenerateObjectResult<T> {
615
615
  */
616
616
  readonly usage: LanguageModelUsage$1;
617
617
  /**
618
- Warnings from the model provider (e.g. unsupported settings)
618
+ Warnings from the model provider (e.g. unsupported settings).
619
619
  */
620
620
  readonly warnings: CallWarning[] | undefined;
621
621
  /**
@@ -686,11 +686,11 @@ via tool or schema description.
686
686
  /**
687
687
  The mode to use for object generation.
688
688
 
689
- The schema is converted in a JSON schema and used in one of the following ways
689
+ The schema is converted into a JSON schema and used in one of the following ways
690
690
 
691
691
  - 'auto': The provider will choose the best mode for the model.
692
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
693
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
692
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
693
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
694
694
 
695
695
  Please note that most providers do not support all modes.
696
696
 
@@ -748,11 +748,11 @@ via tool or schema description.
748
748
  /**
749
749
  The mode to use for object generation.
750
750
 
751
- The schema is converted in a JSON schema and used in one of the following ways
751
+ The schema is converted into a JSON schema and used in one of the following ways
752
752
 
753
753
  - 'auto': The provider will choose the best mode for the model.
754
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
755
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
754
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
755
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
756
756
 
757
757
  Please note that most providers do not support all modes.
758
758
 
@@ -798,11 +798,11 @@ The enum values that the model should use.
798
798
  /**
799
799
  The mode to use for object generation.
800
800
 
801
- The schema is converted in a JSON schema and used in one of the following ways
801
+ The schema is converted into a JSON schema and used in one of the following ways
802
802
 
803
803
  - 'auto': The provider will choose the best mode for the model.
804
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
805
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
804
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
805
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
806
806
 
807
807
  Please note that most providers do not support all modes.
808
808
 
@@ -1037,11 +1037,11 @@ via tool or schema description.
1037
1037
  /**
1038
1038
  The mode to use for object generation.
1039
1039
 
1040
- The schema is converted in a JSON schema and used in one of the following ways
1040
+ The schema is converted into a JSON schema and used in one of the following ways
1041
1041
 
1042
1042
  - 'auto': The provider will choose the best mode for the model.
1043
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
1044
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
1043
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
1044
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
1045
1045
 
1046
1046
  Please note that most providers do not support all modes.
1047
1047
 
@@ -1104,11 +1104,11 @@ via tool or schema description.
1104
1104
  /**
1105
1105
  The mode to use for object generation.
1106
1106
 
1107
- The schema is converted in a JSON schema and used in one of the following ways
1107
+ The schema is converted into a JSON schema and used in one of the following ways
1108
1108
 
1109
1109
  - 'auto': The provider will choose the best mode for the model.
1110
- - 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
1111
- - 'json': The JSON schema and an instruction is injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
1110
+ - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
1111
+ - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
1112
1112
 
1113
1113
  Please note that most providers do not support all modes.
1114
1114
 
@@ -1333,7 +1333,7 @@ type StepResult<TOOLS extends Record<string, CoreTool>> = {
1333
1333
  */
1334
1334
  readonly usage: LanguageModelUsage$1;
1335
1335
  /**
1336
- Warnings from the model provider (e.g. unsupported settings)
1336
+ Warnings from the model provider (e.g. unsupported settings).
1337
1337
  */
1338
1338
  readonly warnings: CallWarning[] | undefined;
1339
1339
  /**
@@ -2964,21 +2964,38 @@ The following streams are supported:
2964
2964
  - `LangChainAIMessageChunk` streams (LangChain `model.stream` output)
2965
2965
  - `string` streams (LangChain `StringOutputParser` output)
2966
2966
  */
2967
- declare function toDataStream(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2968
- declare function toDataStreamResponse(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, options?: {
2967
+ declare function toDataStream$1(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2968
+ declare function toDataStreamResponse$1(stream: ReadableStream<LangChainStreamEvent> | ReadableStream<LangChainAIMessageChunk> | ReadableStream<string>, options?: {
2969
2969
  init?: ResponseInit;
2970
2970
  data?: StreamData;
2971
2971
  callbacks?: AIStreamCallbacksAndOptions;
2972
2972
  }): Response;
2973
2973
 
2974
2974
  declare const langchainAdapter_toAIStream: typeof toAIStream;
2975
- declare const langchainAdapter_toDataStream: typeof toDataStream;
2976
- declare const langchainAdapter_toDataStreamResponse: typeof toDataStreamResponse;
2977
2975
  declare namespace langchainAdapter {
2978
2976
  export {
2979
2977
  langchainAdapter_toAIStream as toAIStream,
2980
- langchainAdapter_toDataStream as toDataStream,
2981
- langchainAdapter_toDataStreamResponse as toDataStreamResponse,
2978
+ toDataStream$1 as toDataStream,
2979
+ toDataStreamResponse$1 as toDataStreamResponse,
2980
+ };
2981
+ }
2982
+
2983
+ type EngineResponse = {
2984
+ delta: string;
2985
+ };
2986
+ declare function toDataStream(stream: AsyncIterable<EngineResponse>, callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
2987
+ declare function toDataStreamResponse(stream: AsyncIterable<EngineResponse>, options?: {
2988
+ init?: ResponseInit;
2989
+ data?: StreamData;
2990
+ callbacks?: AIStreamCallbacksAndOptions;
2991
+ }): Response;
2992
+
2993
+ declare const llamaindexAdapter_toDataStream: typeof toDataStream;
2994
+ declare const llamaindexAdapter_toDataStreamResponse: typeof toDataStreamResponse;
2995
+ declare namespace llamaindexAdapter {
2996
+ export {
2997
+ llamaindexAdapter_toDataStream as toDataStream,
2998
+ llamaindexAdapter_toDataStreamResponse as toDataStreamResponse,
2982
2999
  };
2983
3000
  }
2984
3001
 
@@ -3108,4 +3125,4 @@ declare const generateId: (size?: number) => string;
3108
3125
  */
3109
3126
  declare const nanoid: (size?: number) => string;
3110
3127
 
3111
- 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, EmbeddingModelUsage, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, Experimental_LanguageModelV1Middleware, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LanguageModelResponseMetadata, LanguageModelResponseMetadataWithHeaders, LanguageModelUsage, LogProbs, MessageConversionError, MistralStream, NoObjectGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, Provider, ProviderMetadata, ReplicateStream, RetryError, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertToCoreMessages, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_Provider, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_customProvider, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, experimental_wrapLanguageModel, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
3128
+ 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, EmbeddingModelUsage, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, Experimental_LanguageModelV1Middleware, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LanguageModelResponseMetadata, LanguageModelResponseMetadataWithHeaders, LanguageModelUsage, llamaindexAdapter as LlamaIndexAdapter, LogProbs, MessageConversionError, MistralStream, NoObjectGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, Provider, ProviderMetadata, ReplicateStream, RetryError, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertToCoreMessages, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_Provider, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_customProvider, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, experimental_wrapLanguageModel, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ __export(streams_exports, {
45
45
  JSONParseError: () => import_provider13.JSONParseError,
46
46
  LangChainAdapter: () => langchain_adapter_exports,
47
47
  LangChainStream: () => LangChainStream,
48
+ LlamaIndexAdapter: () => llamaindex_adapter_exports,
48
49
  LoadAPIKeyError: () => import_provider13.LoadAPIKeyError,
49
50
  MessageConversionError: () => MessageConversionError,
50
51
  MistralStream: () => MistralStream,
@@ -2976,32 +2977,7 @@ function prepareToolsAndToolChoice({
2976
2977
  };
2977
2978
  }
2978
2979
 
2979
- // core/generate-text/to-response-messages.ts
2980
- function toResponseMessages({
2981
- text = "",
2982
- toolCalls,
2983
- toolResults
2984
- }) {
2985
- const responseMessages = [];
2986
- responseMessages.push({
2987
- role: "assistant",
2988
- content: [{ type: "text", text }, ...toolCalls]
2989
- });
2990
- if (toolResults.length > 0) {
2991
- responseMessages.push({
2992
- role: "tool",
2993
- content: toolResults.map((result) => ({
2994
- type: "tool-result",
2995
- toolCallId: result.toolCallId,
2996
- toolName: result.toolName,
2997
- result: result.result
2998
- }))
2999
- });
3000
- }
3001
- return responseMessages;
3002
- }
3003
-
3004
- // core/generate-text/tool-call.ts
2980
+ // core/generate-text/parse-tool-call.ts
3005
2981
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
3006
2982
  var import_ui_utils4 = require("@ai-sdk/ui-utils");
3007
2983
  function parseToolCall({
@@ -3019,10 +2995,8 @@ function parseToolCall({
3019
2995
  availableTools: Object.keys(tools)
3020
2996
  });
3021
2997
  }
3022
- const parseResult = (0, import_provider_utils8.safeParseJSON)({
3023
- text: toolCall.args,
3024
- schema: (0, import_ui_utils4.asSchema)(tool2.parameters)
3025
- });
2998
+ const schema = (0, import_ui_utils4.asSchema)(tool2.parameters);
2999
+ const parseResult = toolCall.args.trim() === "" ? (0, import_provider_utils8.safeValidateTypes)({ value: {}, schema }) : (0, import_provider_utils8.safeParseJSON)({ text: toolCall.args, schema });
3026
3000
  if (parseResult.success === false) {
3027
3001
  throw new InvalidToolArgumentsError({
3028
3002
  toolName,
@@ -3038,6 +3012,31 @@ function parseToolCall({
3038
3012
  };
3039
3013
  }
3040
3014
 
3015
+ // core/generate-text/to-response-messages.ts
3016
+ function toResponseMessages({
3017
+ text = "",
3018
+ toolCalls,
3019
+ toolResults
3020
+ }) {
3021
+ const responseMessages = [];
3022
+ responseMessages.push({
3023
+ role: "assistant",
3024
+ content: [{ type: "text", text }, ...toolCalls]
3025
+ });
3026
+ if (toolResults.length > 0) {
3027
+ responseMessages.push({
3028
+ role: "tool",
3029
+ content: toolResults.map((result) => ({
3030
+ type: "tool-result",
3031
+ toolCallId: result.toolCallId,
3032
+ toolName: result.toolName,
3033
+ result: result.result
3034
+ }))
3035
+ });
3036
+ }
3037
+ return responseMessages;
3038
+ }
3039
+
3041
3040
  // core/generate-text/generate-text.ts
3042
3041
  var originalGenerateId3 = (0, import_provider_utils9.createIdGenerator)({ prefix: "aitxt-", size: 24 });
3043
3042
  async function generateText({
@@ -5392,6 +5391,48 @@ function forwardAIMessageChunk(chunk, controller) {
5392
5391
  }
5393
5392
  }
5394
5393
 
5394
+ // streams/llamaindex-adapter.ts
5395
+ var llamaindex_adapter_exports = {};
5396
+ __export(llamaindex_adapter_exports, {
5397
+ toDataStream: () => toDataStream2,
5398
+ toDataStreamResponse: () => toDataStreamResponse2
5399
+ });
5400
+ function toDataStream2(stream, callbacks) {
5401
+ return toReadableStream(stream).pipeThrough(createCallbacksTransformer(callbacks)).pipeThrough(createStreamDataTransformer());
5402
+ }
5403
+ function toDataStreamResponse2(stream, options = {}) {
5404
+ var _a11;
5405
+ const { init, data, callbacks } = options;
5406
+ const dataStream = toDataStream2(stream, callbacks);
5407
+ const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
5408
+ return new Response(responseStream, {
5409
+ status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
5410
+ statusText: init == null ? void 0 : init.statusText,
5411
+ headers: prepareResponseHeaders(init, {
5412
+ contentType: "text/plain; charset=utf-8",
5413
+ dataStreamVersion: "v1"
5414
+ })
5415
+ });
5416
+ }
5417
+ function toReadableStream(res) {
5418
+ const it = res[Symbol.asyncIterator]();
5419
+ const trimStartOfStream = trimStartOfStreamHelper();
5420
+ return new ReadableStream({
5421
+ async pull(controller) {
5422
+ var _a11;
5423
+ const { value, done } = await it.next();
5424
+ if (done) {
5425
+ controller.close();
5426
+ return;
5427
+ }
5428
+ const text = trimStartOfStream((_a11 = value.delta) != null ? _a11 : "");
5429
+ if (text) {
5430
+ controller.enqueue(text);
5431
+ }
5432
+ }
5433
+ });
5434
+ }
5435
+
5395
5436
  // streams/langchain-stream.ts
5396
5437
  function LangChainStream(callbacks) {
5397
5438
  const stream = new TransformStream();
@@ -5880,6 +5921,7 @@ var nanoid = import_provider_utils11.generateId;
5880
5921
  JSONParseError,
5881
5922
  LangChainAdapter,
5882
5923
  LangChainStream,
5924
+ LlamaIndexAdapter,
5883
5925
  LoadAPIKeyError,
5884
5926
  MessageConversionError,
5885
5927
  MistralStream,