ai 3.3.3 → 3.3.5
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 +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/rsc/dist/rsc-server.mjs +1 -0
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.d.mts
CHANGED
@@ -597,6 +597,8 @@ This function does not stream the output. If you want to stream the output, use
|
|
597
597
|
@param model - The language model to use.
|
598
598
|
|
599
599
|
@param schema - The schema of the object that the model should generate.
|
600
|
+
@param schemaName - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
|
601
|
+
@param schemaDescription - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
|
600
602
|
@param mode - The mode to use for object generation. Not all models support all modes. Defaults to 'auto'.
|
601
603
|
|
602
604
|
@param system - A system message that will be part of the prompt.
|
@@ -629,7 +631,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
629
631
|
@returns
|
630
632
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
631
633
|
*/
|
632
|
-
declare function generateObject<T>({ model, schema: inputSchema, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
634
|
+
declare function generateObject<T>({ model, schema: inputSchema, schemaName, schemaDescription, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
633
635
|
/**
|
634
636
|
The language model to use.
|
635
637
|
*/
|
@@ -639,6 +641,18 @@ The schema of the object that the model should generate.
|
|
639
641
|
*/
|
640
642
|
schema: z.Schema<T, z.ZodTypeDef, any> | Schema<T>;
|
641
643
|
/**
|
644
|
+
Optional name of the output that should be generated.
|
645
|
+
Used by some providers for additional LLM guidance, e.g.
|
646
|
+
via tool or schema name.
|
647
|
+
*/
|
648
|
+
schemaName?: string;
|
649
|
+
/**
|
650
|
+
Optional description of the output that should be generated.
|
651
|
+
Used by some providers for additional LLM guidance, e.g.
|
652
|
+
via tool or schema description.
|
653
|
+
*/
|
654
|
+
schemaDescription?: string;
|
655
|
+
/**
|
642
656
|
The mode to use for object generation.
|
643
657
|
|
644
658
|
The schema is converted in a JSON schema and used in one of the following ways
|
@@ -774,6 +788,8 @@ This function streams the output. If you do not want to stream the output, use `
|
|
774
788
|
@param model - The language model to use.
|
775
789
|
|
776
790
|
@param schema - The schema of the object that the model should generate.
|
791
|
+
@param schemaName - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
|
792
|
+
@param schemaDescription - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
|
777
793
|
@param mode - The mode to use for object generation. Not all models support all modes. Defaults to 'auto'.
|
778
794
|
|
779
795
|
@param system - A system message that will be part of the prompt.
|
@@ -806,7 +822,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
806
822
|
@return
|
807
823
|
A result object for accessing the partial object stream and additional information.
|
808
824
|
*/
|
809
|
-
declare function streamObject<T>({ model, schema: inputSchema, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, onFinish, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
825
|
+
declare function streamObject<T>({ model, schema: inputSchema, schemaName, schemaDescription, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, onFinish, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
810
826
|
/**
|
811
827
|
The language model to use.
|
812
828
|
*/
|
@@ -816,6 +832,18 @@ The schema of the object that the model should generate.
|
|
816
832
|
*/
|
817
833
|
schema: z.Schema<T, z.ZodTypeDef, any> | Schema<T>;
|
818
834
|
/**
|
835
|
+
Optional name of the output that should be generated.
|
836
|
+
Used by some providers for additional LLM guidance, e.g.
|
837
|
+
via tool or schema name.
|
838
|
+
*/
|
839
|
+
schemaName?: string;
|
840
|
+
/**
|
841
|
+
Optional description of the output that should be generated.
|
842
|
+
Used by some providers for additional LLM guidance, e.g.
|
843
|
+
via tool or schema description.
|
844
|
+
*/
|
845
|
+
schemaDescription?: string;
|
846
|
+
/**
|
819
847
|
The mode to use for object generation.
|
820
848
|
|
821
849
|
The schema is converted in a JSON schema and used in one of the following ways
|
@@ -1526,6 +1554,7 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1526
1554
|
get textStream(): AsyncIterableStream<string>;
|
1527
1555
|
get fullStream(): AsyncIterableStream<TextStreamPart<TOOLS>>;
|
1528
1556
|
toAIStream(callbacks?: AIStreamCallbacksAndOptions): ReadableStream<Uint8Array>;
|
1557
|
+
private toDataStream;
|
1529
1558
|
pipeAIStreamToResponse(response: ServerResponse$1, init?: {
|
1530
1559
|
headers?: Record<string, string>;
|
1531
1560
|
status?: number;
|
@@ -1545,6 +1574,7 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1545
1574
|
toDataStreamResponse(options?: ResponseInit | {
|
1546
1575
|
init?: ResponseInit;
|
1547
1576
|
data?: StreamData;
|
1577
|
+
getErrorMessage?: (error: unknown) => string;
|
1548
1578
|
}): Response;
|
1549
1579
|
toTextStreamResponse(init?: ResponseInit): Response;
|
1550
1580
|
}
|
@@ -2628,7 +2658,15 @@ declare function streamToResponse(res: ReadableStream, response: ServerResponse$
|
|
2628
2658
|
/**
|
2629
2659
|
* A utility class for streaming text responses.
|
2630
2660
|
*
|
2631
|
-
* @deprecated Use `streamText.toDataStreamResponse()`
|
2661
|
+
* @deprecated Use `streamText.toDataStreamResponse()` (if you did send StreamData)
|
2662
|
+
* or a regular `Response` instead (if you did not send any StreamData):
|
2663
|
+
*
|
2664
|
+
* ```ts
|
2665
|
+
* return new Response(stream, {
|
2666
|
+
* status: 200,
|
2667
|
+
* contentType: 'text/plain; charset=utf-8',
|
2668
|
+
* })
|
2669
|
+
* ```
|
2632
2670
|
*/
|
2633
2671
|
declare class StreamingTextResponse extends Response {
|
2634
2672
|
constructor(res: ReadableStream, init?: ResponseInit, data?: StreamData);
|
@@ -2640,4 +2678,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2640
2678
|
*/
|
2641
2679
|
declare const nanoid: (size?: number | undefined) => string;
|
2642
2680
|
|
2643
|
-
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, 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_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, jsonSchema, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|
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, Schema, 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_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, jsonSchema, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|
package/dist/index.d.ts
CHANGED
@@ -597,6 +597,8 @@ This function does not stream the output. If you want to stream the output, use
|
|
597
597
|
@param model - The language model to use.
|
598
598
|
|
599
599
|
@param schema - The schema of the object that the model should generate.
|
600
|
+
@param schemaName - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
|
601
|
+
@param schemaDescription - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
|
600
602
|
@param mode - The mode to use for object generation. Not all models support all modes. Defaults to 'auto'.
|
601
603
|
|
602
604
|
@param system - A system message that will be part of the prompt.
|
@@ -629,7 +631,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
629
631
|
@returns
|
630
632
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
631
633
|
*/
|
632
|
-
declare function generateObject<T>({ model, schema: inputSchema, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
634
|
+
declare function generateObject<T>({ model, schema: inputSchema, schemaName, schemaDescription, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
633
635
|
/**
|
634
636
|
The language model to use.
|
635
637
|
*/
|
@@ -639,6 +641,18 @@ The schema of the object that the model should generate.
|
|
639
641
|
*/
|
640
642
|
schema: z.Schema<T, z.ZodTypeDef, any> | Schema<T>;
|
641
643
|
/**
|
644
|
+
Optional name of the output that should be generated.
|
645
|
+
Used by some providers for additional LLM guidance, e.g.
|
646
|
+
via tool or schema name.
|
647
|
+
*/
|
648
|
+
schemaName?: string;
|
649
|
+
/**
|
650
|
+
Optional description of the output that should be generated.
|
651
|
+
Used by some providers for additional LLM guidance, e.g.
|
652
|
+
via tool or schema description.
|
653
|
+
*/
|
654
|
+
schemaDescription?: string;
|
655
|
+
/**
|
642
656
|
The mode to use for object generation.
|
643
657
|
|
644
658
|
The schema is converted in a JSON schema and used in one of the following ways
|
@@ -774,6 +788,8 @@ This function streams the output. If you do not want to stream the output, use `
|
|
774
788
|
@param model - The language model to use.
|
775
789
|
|
776
790
|
@param schema - The schema of the object that the model should generate.
|
791
|
+
@param schemaName - Optional name of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema name.
|
792
|
+
@param schemaDescription - Optional description of the output that should be generated. Used by some providers for additional LLM guidance, e.g. via tool or schema description.
|
777
793
|
@param mode - The mode to use for object generation. Not all models support all modes. Defaults to 'auto'.
|
778
794
|
|
779
795
|
@param system - A system message that will be part of the prompt.
|
@@ -806,7 +822,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
806
822
|
@return
|
807
823
|
A result object for accessing the partial object stream and additional information.
|
808
824
|
*/
|
809
|
-
declare function streamObject<T>({ model, schema: inputSchema, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, onFinish, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
825
|
+
declare function streamObject<T>({ model, schema: inputSchema, schemaName, schemaDescription, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, onFinish, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
810
826
|
/**
|
811
827
|
The language model to use.
|
812
828
|
*/
|
@@ -816,6 +832,18 @@ The schema of the object that the model should generate.
|
|
816
832
|
*/
|
817
833
|
schema: z.Schema<T, z.ZodTypeDef, any> | Schema<T>;
|
818
834
|
/**
|
835
|
+
Optional name of the output that should be generated.
|
836
|
+
Used by some providers for additional LLM guidance, e.g.
|
837
|
+
via tool or schema name.
|
838
|
+
*/
|
839
|
+
schemaName?: string;
|
840
|
+
/**
|
841
|
+
Optional description of the output that should be generated.
|
842
|
+
Used by some providers for additional LLM guidance, e.g.
|
843
|
+
via tool or schema description.
|
844
|
+
*/
|
845
|
+
schemaDescription?: string;
|
846
|
+
/**
|
819
847
|
The mode to use for object generation.
|
820
848
|
|
821
849
|
The schema is converted in a JSON schema and used in one of the following ways
|
@@ -1526,6 +1554,7 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1526
1554
|
get textStream(): AsyncIterableStream<string>;
|
1527
1555
|
get fullStream(): AsyncIterableStream<TextStreamPart<TOOLS>>;
|
1528
1556
|
toAIStream(callbacks?: AIStreamCallbacksAndOptions): ReadableStream<Uint8Array>;
|
1557
|
+
private toDataStream;
|
1529
1558
|
pipeAIStreamToResponse(response: ServerResponse$1, init?: {
|
1530
1559
|
headers?: Record<string, string>;
|
1531
1560
|
status?: number;
|
@@ -1545,6 +1574,7 @@ declare class DefaultStreamTextResult<TOOLS extends Record<string, CoreTool>> im
|
|
1545
1574
|
toDataStreamResponse(options?: ResponseInit | {
|
1546
1575
|
init?: ResponseInit;
|
1547
1576
|
data?: StreamData;
|
1577
|
+
getErrorMessage?: (error: unknown) => string;
|
1548
1578
|
}): Response;
|
1549
1579
|
toTextStreamResponse(init?: ResponseInit): Response;
|
1550
1580
|
}
|
@@ -2628,7 +2658,15 @@ declare function streamToResponse(res: ReadableStream, response: ServerResponse$
|
|
2628
2658
|
/**
|
2629
2659
|
* A utility class for streaming text responses.
|
2630
2660
|
*
|
2631
|
-
* @deprecated Use `streamText.toDataStreamResponse()`
|
2661
|
+
* @deprecated Use `streamText.toDataStreamResponse()` (if you did send StreamData)
|
2662
|
+
* or a regular `Response` instead (if you did not send any StreamData):
|
2663
|
+
*
|
2664
|
+
* ```ts
|
2665
|
+
* return new Response(stream, {
|
2666
|
+
* status: 200,
|
2667
|
+
* contentType: 'text/plain; charset=utf-8',
|
2668
|
+
* })
|
2669
|
+
* ```
|
2632
2670
|
*/
|
2633
2671
|
declare class StreamingTextResponse extends Response {
|
2634
2672
|
constructor(res: ReadableStream, init?: ResponseInit, data?: StreamData);
|
@@ -2640,4 +2678,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2640
2678
|
*/
|
2641
2679
|
declare const nanoid: (size?: number | undefined) => string;
|
2642
2680
|
|
2643
|
-
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, 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_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, jsonSchema, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|
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, Schema, 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_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, jsonSchema, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|
package/dist/index.js
CHANGED
@@ -1368,6 +1368,8 @@ _a6 = symbol6;
|
|
1368
1368
|
async function generateObject({
|
1369
1369
|
model,
|
1370
1370
|
schema: inputSchema,
|
1371
|
+
schemaName,
|
1372
|
+
schemaDescription,
|
1371
1373
|
mode,
|
1372
1374
|
system,
|
1373
1375
|
prompt,
|
@@ -1404,6 +1406,8 @@ async function generateObject({
|
|
1404
1406
|
"ai.schema": {
|
1405
1407
|
input: () => JSON.stringify(schema.jsonSchema)
|
1406
1408
|
},
|
1409
|
+
"ai.schema.name": schemaName,
|
1410
|
+
"ai.schema.description": schemaDescription,
|
1407
1411
|
"ai.settings.mode": mode
|
1408
1412
|
}
|
1409
1413
|
}),
|
@@ -1463,7 +1467,12 @@ async function generateObject({
|
|
1463
1467
|
tracer,
|
1464
1468
|
fn: async (span2) => {
|
1465
1469
|
const result2 = await model.doGenerate({
|
1466
|
-
mode: {
|
1470
|
+
mode: {
|
1471
|
+
type: "object-json",
|
1472
|
+
schema: schema.jsonSchema,
|
1473
|
+
name: schemaName,
|
1474
|
+
description: schemaDescription
|
1475
|
+
},
|
1467
1476
|
...prepareCallSettings(settings),
|
1468
1477
|
inputFormat,
|
1469
1478
|
prompt: promptMessages,
|
@@ -1545,8 +1554,8 @@ async function generateObject({
|
|
1545
1554
|
type: "object-tool",
|
1546
1555
|
tool: {
|
1547
1556
|
type: "function",
|
1548
|
-
name: "json",
|
1549
|
-
description: "Respond with a JSON object.",
|
1557
|
+
name: schemaName != null ? schemaName : "json",
|
1558
|
+
description: schemaDescription != null ? schemaDescription : "Respond with a JSON object.",
|
1550
1559
|
parameters: schema.jsonSchema
|
1551
1560
|
}
|
1552
1561
|
},
|
@@ -1724,6 +1733,8 @@ function createAsyncIterableStream(source, transformer) {
|
|
1724
1733
|
async function streamObject({
|
1725
1734
|
model,
|
1726
1735
|
schema: inputSchema,
|
1736
|
+
schemaName,
|
1737
|
+
schemaDescription,
|
1727
1738
|
mode,
|
1728
1739
|
system,
|
1729
1740
|
prompt,
|
@@ -1760,6 +1771,8 @@ async function streamObject({
|
|
1760
1771
|
input: () => JSON.stringify({ system, prompt, messages })
|
1761
1772
|
},
|
1762
1773
|
"ai.schema": { input: () => JSON.stringify(schema.jsonSchema) },
|
1774
|
+
"ai.schema.name": schemaName,
|
1775
|
+
"ai.schema.description": schemaDescription,
|
1763
1776
|
"ai.settings.mode": mode
|
1764
1777
|
}
|
1765
1778
|
}),
|
@@ -1782,7 +1795,12 @@ async function streamObject({
|
|
1782
1795
|
messages
|
1783
1796
|
});
|
1784
1797
|
callOptions = {
|
1785
|
-
mode: {
|
1798
|
+
mode: {
|
1799
|
+
type: "object-json",
|
1800
|
+
schema: schema.jsonSchema,
|
1801
|
+
name: schemaName,
|
1802
|
+
description: schemaDescription
|
1803
|
+
},
|
1786
1804
|
...prepareCallSettings(settings),
|
1787
1805
|
inputFormat: validatedPrompt.type,
|
1788
1806
|
prompt: await convertToLanguageModelPrompt({
|
@@ -1818,8 +1836,8 @@ async function streamObject({
|
|
1818
1836
|
type: "object-tool",
|
1819
1837
|
tool: {
|
1820
1838
|
type: "function",
|
1821
|
-
name: "json",
|
1822
|
-
description: "Respond with a JSON object.",
|
1839
|
+
name: schemaName != null ? schemaName : "json",
|
1840
|
+
description: schemaDescription != null ? schemaDescription : "Respond with a JSON object.",
|
1823
1841
|
parameters: schema.jsonSchema
|
1824
1842
|
}
|
1825
1843
|
},
|
@@ -3141,6 +3159,13 @@ var DefaultStreamTextResult = class {
|
|
3141
3159
|
});
|
3142
3160
|
}
|
3143
3161
|
toAIStream(callbacks = {}) {
|
3162
|
+
return this.toDataStream({ callbacks });
|
3163
|
+
}
|
3164
|
+
toDataStream({
|
3165
|
+
callbacks = {},
|
3166
|
+
getErrorMessage: getErrorMessage4 = () => ""
|
3167
|
+
// mask error messages for safety by default
|
3168
|
+
} = {}) {
|
3144
3169
|
let aggregatedResponse = "";
|
3145
3170
|
const callbackTransformer = new TransformStream({
|
3146
3171
|
async start() {
|
@@ -3207,7 +3232,7 @@ var DefaultStreamTextResult = class {
|
|
3207
3232
|
break;
|
3208
3233
|
case "error":
|
3209
3234
|
controller.enqueue(
|
3210
|
-
(0, import_ui_utils6.formatStreamPart)("error",
|
3235
|
+
(0, import_ui_utils6.formatStreamPart)("error", getErrorMessage4(chunk.error))
|
3211
3236
|
);
|
3212
3237
|
break;
|
3213
3238
|
case "finish":
|
@@ -3239,7 +3264,7 @@ var DefaultStreamTextResult = class {
|
|
3239
3264
|
"Content-Type": "text/plain; charset=utf-8",
|
3240
3265
|
...init == null ? void 0 : init.headers
|
3241
3266
|
});
|
3242
|
-
const reader = this.
|
3267
|
+
const reader = this.toDataStream().getReader();
|
3243
3268
|
const read = async () => {
|
3244
3269
|
try {
|
3245
3270
|
while (true) {
|
@@ -3290,7 +3315,8 @@ var DefaultStreamTextResult = class {
|
|
3290
3315
|
statusText: "statusText" in options ? options.statusText : void 0
|
3291
3316
|
};
|
3292
3317
|
const data = options == null ? void 0 : "data" in options ? options.data : void 0;
|
3293
|
-
const
|
3318
|
+
const getErrorMessage4 = options == null ? void 0 : "getErrorMessage" in options ? options.getErrorMessage : void 0;
|
3319
|
+
const stream = data ? mergeStreams(data.stream, this.toDataStream({ getErrorMessage: getErrorMessage4 })) : this.toDataStream({ getErrorMessage: getErrorMessage4 });
|
3294
3320
|
return new Response(stream, {
|
3295
3321
|
status: (_a9 = init == null ? void 0 : init.status) != null ? _a9 : 200,
|
3296
3322
|
statusText: init == null ? void 0 : init.statusText,
|
@@ -3716,6 +3742,7 @@ function readableFromAsyncIterable(iterable) {
|
|
3716
3742
|
|
3717
3743
|
// streams/stream-data.ts
|
3718
3744
|
var import_ui_utils3 = require("@ai-sdk/ui-utils");
|
3745
|
+
var STREAM_DATA_WARNING_TIME_MS = 15 * 1e3;
|
3719
3746
|
var StreamData2 = class {
|
3720
3747
|
constructor() {
|
3721
3748
|
this.encoder = new TextEncoder();
|
@@ -3731,7 +3758,7 @@ var StreamData2 = class {
|
|
3731
3758
|
console.warn(
|
3732
3759
|
"The data stream is hanging. Did you forget to close it with `data.close()`?"
|
3733
3760
|
);
|
3734
|
-
},
|
3761
|
+
}, STREAM_DATA_WARNING_TIME_MS);
|
3735
3762
|
}
|
3736
3763
|
},
|
3737
3764
|
pull: (controller) => {
|