ai 3.3.2 → 3.3.4
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 +40 -4
- package/dist/index.d.ts +40 -4
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -9
- 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
|
@@ -2628,7 +2656,15 @@ declare function streamToResponse(res: ReadableStream, response: ServerResponse$
|
|
2628
2656
|
/**
|
2629
2657
|
* A utility class for streaming text responses.
|
2630
2658
|
*
|
2631
|
-
* @deprecated Use `streamText.toDataStreamResponse()`
|
2659
|
+
* @deprecated Use `streamText.toDataStreamResponse()` (if you did send StreamData)
|
2660
|
+
* or a regular `Response` instead (if you did not send any StreamData):
|
2661
|
+
*
|
2662
|
+
* ```ts
|
2663
|
+
* return new Response(stream, {
|
2664
|
+
* status: 200,
|
2665
|
+
* contentType: 'text/plain; charset=utf-8',
|
2666
|
+
* })
|
2667
|
+
* ```
|
2632
2668
|
*/
|
2633
2669
|
declare class StreamingTextResponse extends Response {
|
2634
2670
|
constructor(res: ReadableStream, init?: ResponseInit, data?: StreamData);
|
@@ -2640,4 +2676,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2640
2676
|
*/
|
2641
2677
|
declare const nanoid: (size?: number | undefined) => string;
|
2642
2678
|
|
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 };
|
2679
|
+
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidModelIdError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, NoObjectGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, RetryError, 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
|
@@ -2628,7 +2656,15 @@ declare function streamToResponse(res: ReadableStream, response: ServerResponse$
|
|
2628
2656
|
/**
|
2629
2657
|
* A utility class for streaming text responses.
|
2630
2658
|
*
|
2631
|
-
* @deprecated Use `streamText.toDataStreamResponse()`
|
2659
|
+
* @deprecated Use `streamText.toDataStreamResponse()` (if you did send StreamData)
|
2660
|
+
* or a regular `Response` instead (if you did not send any StreamData):
|
2661
|
+
*
|
2662
|
+
* ```ts
|
2663
|
+
* return new Response(stream, {
|
2664
|
+
* status: 200,
|
2665
|
+
* contentType: 'text/plain; charset=utf-8',
|
2666
|
+
* })
|
2667
|
+
* ```
|
2632
2668
|
*/
|
2633
2669
|
declare class StreamingTextResponse extends Response {
|
2634
2670
|
constructor(res: ReadableStream, init?: ResponseInit, data?: StreamData);
|
@@ -2640,4 +2676,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2640
2676
|
*/
|
2641
2677
|
declare const nanoid: (size?: number | undefined) => string;
|
2642
2678
|
|
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 };
|
2679
|
+
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidModelIdError, InvalidToolArgumentsError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, NoObjectGeneratedError, NoSuchModelError, NoSuchProviderError, NoSuchToolError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, RetryError, 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
|
}),
|
@@ -1422,7 +1426,7 @@ async function generateObject({
|
|
1422
1426
|
switch (mode) {
|
1423
1427
|
case "json": {
|
1424
1428
|
const validatedPrompt = getValidatedPrompt({
|
1425
|
-
system: injectJsonSchemaIntoSystem({
|
1429
|
+
system: model.supportsStructuredOutputs ? system : injectJsonSchemaIntoSystem({
|
1426
1430
|
system,
|
1427
1431
|
schema: schema.jsonSchema
|
1428
1432
|
}),
|
@@ -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
|
}),
|
@@ -1774,7 +1787,7 @@ async function streamObject({
|
|
1774
1787
|
switch (mode) {
|
1775
1788
|
case "json": {
|
1776
1789
|
const validatedPrompt = getValidatedPrompt({
|
1777
|
-
system: injectJsonSchemaIntoSystem({
|
1790
|
+
system: model.supportsStructuredOutputs ? system : injectJsonSchemaIntoSystem({
|
1778
1791
|
system,
|
1779
1792
|
schema: schema.jsonSchema
|
1780
1793
|
}),
|
@@ -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
|
},
|
@@ -3716,6 +3734,7 @@ function readableFromAsyncIterable(iterable) {
|
|
3716
3734
|
|
3717
3735
|
// streams/stream-data.ts
|
3718
3736
|
var import_ui_utils3 = require("@ai-sdk/ui-utils");
|
3737
|
+
var STREAM_DATA_WARNING_TIME_MS = 15 * 1e3;
|
3719
3738
|
var StreamData2 = class {
|
3720
3739
|
constructor() {
|
3721
3740
|
this.encoder = new TextEncoder();
|
@@ -3731,7 +3750,7 @@ var StreamData2 = class {
|
|
3731
3750
|
console.warn(
|
3732
3751
|
"The data stream is hanging. Did you forget to close it with `data.close()`?"
|
3733
3752
|
);
|
3734
|
-
},
|
3753
|
+
}, STREAM_DATA_WARNING_TIME_MS);
|
3735
3754
|
}
|
3736
3755
|
},
|
3737
3756
|
pull: (controller) => {
|