@ai-sdk/openai
Advanced tools
Comparing version 0.0.42 to 0.0.43
@@ -200,3 +200,2 @@ "use strict"; | ||
this.specificationVersion = "v1"; | ||
this.defaultObjectGenerationMode = "tool"; | ||
this.modelId = modelId; | ||
@@ -206,2 +205,8 @@ this.settings = settings; | ||
} | ||
get supportsStructuredOutputs() { | ||
return this.settings.structuredOutputs === true; | ||
} | ||
get defaultObjectGenerationMode() { | ||
return this.supportsStructuredOutputs ? "json" : "tool"; | ||
} | ||
get provider() { | ||
@@ -244,2 +249,7 @@ return this.config.provider; | ||
} | ||
if (useLegacyFunctionCalling && this.settings.structuredOutputs === true) { | ||
throw new import_provider2.UnsupportedFunctionalityError({ | ||
functionality: "structuredOutputs with useLegacyFunctionCalling" | ||
}); | ||
} | ||
const baseArgs = { | ||
@@ -275,3 +285,7 @@ // model id: | ||
...baseArgs, | ||
...prepareToolsAndToolChoice({ mode, useLegacyFunctionCalling }) | ||
...prepareToolsAndToolChoice({ | ||
mode, | ||
useLegacyFunctionCalling, | ||
structuredOutputs: this.settings.structuredOutputs | ||
}) | ||
}, | ||
@@ -285,3 +299,10 @@ warnings | ||
...baseArgs, | ||
response_format: { type: "json_object" } | ||
response_format: this.settings.structuredOutputs === true ? { | ||
type: "json_schema", | ||
json_schema: { | ||
name: "response", | ||
strict: true, | ||
schema: mode.schema | ||
} | ||
} : { type: "json_object" } | ||
}, | ||
@@ -318,3 +339,4 @@ warnings | ||
parameters: mode.tool.parameters | ||
} | ||
}, | ||
strict: this.settings.structuredOutputs === true ? true : void 0 | ||
} | ||
@@ -643,3 +665,4 @@ ] | ||
mode, | ||
useLegacyFunctionCalling = false | ||
useLegacyFunctionCalling = false, | ||
structuredOutputs = false | ||
}) { | ||
@@ -687,3 +710,4 @@ var _a; | ||
parameters: tool.parameters | ||
} | ||
}, | ||
strict: structuredOutputs === true ? true : void 0 | ||
})); | ||
@@ -690,0 +714,0 @@ if (toolChoice == null) { |
import { LanguageModelV1, EmbeddingModelV1 } from '@ai-sdk/provider'; | ||
type OpenAIChatModelId = 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | (string & {}); | ||
type OpenAIChatModelId = 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | (string & {}); | ||
interface OpenAIChatSettings { | ||
@@ -37,2 +37,8 @@ /** | ||
/** | ||
Whether to use structured outputs. Defaults to false. | ||
When enabled, tool calls and object generation will be strict and follow the provided schema. | ||
*/ | ||
structuredOutputs?: boolean; | ||
/** | ||
Whether to use legacy function calling. Defaults to false. | ||
@@ -68,3 +74,2 @@ | ||
readonly specificationVersion = "v1"; | ||
readonly defaultObjectGenerationMode = "tool"; | ||
readonly modelId: OpenAIChatModelId; | ||
@@ -74,2 +79,4 @@ readonly settings: OpenAIChatSettings; | ||
constructor(modelId: OpenAIChatModelId, settings: OpenAIChatSettings, config: OpenAIChatConfig); | ||
get supportsStructuredOutputs(): boolean; | ||
get defaultObjectGenerationMode(): "tool" | "json"; | ||
get provider(): string; | ||
@@ -76,0 +83,0 @@ private getArgs; |
@@ -200,3 +200,2 @@ "use strict"; | ||
this.specificationVersion = "v1"; | ||
this.defaultObjectGenerationMode = "tool"; | ||
this.modelId = modelId; | ||
@@ -206,2 +205,8 @@ this.settings = settings; | ||
} | ||
get supportsStructuredOutputs() { | ||
return this.settings.structuredOutputs === true; | ||
} | ||
get defaultObjectGenerationMode() { | ||
return this.supportsStructuredOutputs ? "json" : "tool"; | ||
} | ||
get provider() { | ||
@@ -244,2 +249,7 @@ return this.config.provider; | ||
} | ||
if (useLegacyFunctionCalling && this.settings.structuredOutputs === true) { | ||
throw new import_provider2.UnsupportedFunctionalityError({ | ||
functionality: "structuredOutputs with useLegacyFunctionCalling" | ||
}); | ||
} | ||
const baseArgs = { | ||
@@ -275,3 +285,7 @@ // model id: | ||
...baseArgs, | ||
...prepareToolsAndToolChoice({ mode, useLegacyFunctionCalling }) | ||
...prepareToolsAndToolChoice({ | ||
mode, | ||
useLegacyFunctionCalling, | ||
structuredOutputs: this.settings.structuredOutputs | ||
}) | ||
}, | ||
@@ -285,3 +299,10 @@ warnings | ||
...baseArgs, | ||
response_format: { type: "json_object" } | ||
response_format: this.settings.structuredOutputs === true ? { | ||
type: "json_schema", | ||
json_schema: { | ||
name: "response", | ||
strict: true, | ||
schema: mode.schema | ||
} | ||
} : { type: "json_object" } | ||
}, | ||
@@ -318,3 +339,4 @@ warnings | ||
parameters: mode.tool.parameters | ||
} | ||
}, | ||
strict: this.settings.structuredOutputs === true ? true : void 0 | ||
} | ||
@@ -643,3 +665,4 @@ ] | ||
mode, | ||
useLegacyFunctionCalling = false | ||
useLegacyFunctionCalling = false, | ||
structuredOutputs = false | ||
}) { | ||
@@ -687,3 +710,4 @@ var _a; | ||
parameters: tool.parameters | ||
} | ||
}, | ||
strict: structuredOutputs === true ? true : void 0 | ||
})); | ||
@@ -690,0 +714,0 @@ if (toolChoice == null) { |
import { LanguageModelV1, EmbeddingModelV1 } from '@ai-sdk/provider'; | ||
type OpenAIChatModelId = 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | (string & {}); | ||
type OpenAIChatModelId = 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | (string & {}); | ||
interface OpenAIChatSettings { | ||
@@ -37,2 +37,8 @@ /** | ||
/** | ||
Whether to use structured outputs. Defaults to false. | ||
When enabled, tool calls and object generation will be strict and follow the provided schema. | ||
*/ | ||
structuredOutputs?: boolean; | ||
/** | ||
Whether to use legacy function calling. Defaults to false. | ||
@@ -68,3 +74,2 @@ | ||
readonly specificationVersion = "v1"; | ||
readonly defaultObjectGenerationMode = "tool"; | ||
readonly modelId: OpenAIChatModelId; | ||
@@ -74,2 +79,4 @@ readonly settings: OpenAIChatSettings; | ||
constructor(modelId: OpenAIChatModelId, settings: OpenAIChatSettings, config: OpenAIChatConfig); | ||
get supportsStructuredOutputs(): boolean; | ||
get defaultObjectGenerationMode(): "tool" | "json"; | ||
get provider(): string; | ||
@@ -76,0 +83,0 @@ private getArgs; |
@@ -197,3 +197,2 @@ "use strict"; | ||
this.specificationVersion = "v1"; | ||
this.defaultObjectGenerationMode = "tool"; | ||
this.modelId = modelId; | ||
@@ -203,2 +202,8 @@ this.settings = settings; | ||
} | ||
get supportsStructuredOutputs() { | ||
return this.settings.structuredOutputs === true; | ||
} | ||
get defaultObjectGenerationMode() { | ||
return this.supportsStructuredOutputs ? "json" : "tool"; | ||
} | ||
get provider() { | ||
@@ -241,2 +246,7 @@ return this.config.provider; | ||
} | ||
if (useLegacyFunctionCalling && this.settings.structuredOutputs === true) { | ||
throw new import_provider2.UnsupportedFunctionalityError({ | ||
functionality: "structuredOutputs with useLegacyFunctionCalling" | ||
}); | ||
} | ||
const baseArgs = { | ||
@@ -272,3 +282,7 @@ // model id: | ||
...baseArgs, | ||
...prepareToolsAndToolChoice({ mode, useLegacyFunctionCalling }) | ||
...prepareToolsAndToolChoice({ | ||
mode, | ||
useLegacyFunctionCalling, | ||
structuredOutputs: this.settings.structuredOutputs | ||
}) | ||
}, | ||
@@ -282,3 +296,10 @@ warnings | ||
...baseArgs, | ||
response_format: { type: "json_object" } | ||
response_format: this.settings.structuredOutputs === true ? { | ||
type: "json_schema", | ||
json_schema: { | ||
name: "response", | ||
strict: true, | ||
schema: mode.schema | ||
} | ||
} : { type: "json_object" } | ||
}, | ||
@@ -315,3 +336,4 @@ warnings | ||
parameters: mode.tool.parameters | ||
} | ||
}, | ||
strict: this.settings.structuredOutputs === true ? true : void 0 | ||
} | ||
@@ -640,3 +662,4 @@ ] | ||
mode, | ||
useLegacyFunctionCalling = false | ||
useLegacyFunctionCalling = false, | ||
structuredOutputs = false | ||
}) { | ||
@@ -684,3 +707,4 @@ var _a; | ||
parameters: tool.parameters | ||
} | ||
}, | ||
strict: structuredOutputs === true ? true : void 0 | ||
})); | ||
@@ -687,0 +711,0 @@ if (toolChoice == null) { |
{ | ||
"name": "@ai-sdk/openai", | ||
"version": "0.0.42", | ||
"version": "0.0.43", | ||
"license": "Apache-2.0", | ||
@@ -28,4 +28,4 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@ai-sdk/provider": "0.0.15", | ||
"@ai-sdk/provider-utils": "1.0.7" | ||
"@ai-sdk/provider": "0.0.16", | ||
"@ai-sdk/provider-utils": "1.0.8" | ||
}, | ||
@@ -32,0 +32,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
537252
6476
+ Added@ai-sdk/provider@0.0.16(transitive)
+ Added@ai-sdk/provider-utils@1.0.8(transitive)
- Removed@ai-sdk/provider@0.0.15(transitive)
- Removed@ai-sdk/provider-utils@1.0.7(transitive)
Updated@ai-sdk/provider@0.0.16
Updated@ai-sdk/provider-utils@1.0.8