Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/openai

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/openai - npm Package Compare versions

Comparing version 0.0.42 to 0.0.43

36

./dist/index.js

@@ -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) {

6

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc