New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/openai

Package Overview
Dependencies
Maintainers
2
Versions
111
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.16 to 0.0.17

85

./dist/index.js

@@ -121,2 +121,15 @@ "use strict";

// src/map-openai-chat-logprobs.ts
function mapOpenAIChatLogProbsOutput(logprobs) {
var _a, _b;
return (_b = (_a = logprobs == null ? void 0 : logprobs.content) == null ? void 0 : _a.map(({ token, logprob, top_logprobs }) => ({
token,
logprob,
topLogprobs: top_logprobs ? top_logprobs.map(({ token: token2, logprob: logprob2 }) => ({
token: token2,
logprob: logprob2
})) : []
}))) != null ? _b : void 0;
}
// src/map-openai-finish-reason.ts

@@ -155,15 +168,2 @@ function mapOpenAIFinishReason(finishReason) {

// src/map-openai-chat-logprobs.ts
function mapOpenAIChatLogProbsOutput(logprobs) {
var _a, _b;
return (_b = (_a = logprobs == null ? void 0 : logprobs.content) == null ? void 0 : _a.map(({ token, logprob, top_logprobs }) => ({
token,
logprob,
topLogprobs: top_logprobs ? top_logprobs.map(({ token: token2, logprob: logprob2 }) => ({
token: token2,
logprob: logprob2
})) : []
}))) != null ? _b : void 0;
}
// src/openai-chat-language-model.ts

@@ -191,3 +191,2 @@ var OpenAIChatLanguageModel = class {

}) {
var _a;
const type = mode.type;

@@ -214,14 +213,3 @@ const baseArgs = {

case "regular": {
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
return {
...baseArgs,
tools: tools == null ? void 0 : tools.map((tool) => ({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters
}
}))
};
return { ...baseArgs, ...prepareToolsAndToolChoice(mode) };
}

@@ -515,2 +503,42 @@ case "object-json": {

});
function prepareToolsAndToolChoice(mode) {
var _a;
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
if (tools == null) {
return { tools: void 0, tool_choice: void 0 };
}
const mappedTools = tools.map((tool) => ({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters
}
}));
const toolChoice = mode.toolChoice;
if (toolChoice == null) {
return { tools: mappedTools, tool_choice: void 0 };
}
const type = toolChoice.type;
switch (type) {
case "auto":
case "none":
case "required":
return { tools: mappedTools, tool_choice: type };
case "tool":
return {
tools: mappedTools,
tool_choice: {
type: "function",
function: {
name: toolChoice.toolName
}
}
};
default: {
const _exhaustiveCheck = type;
throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`);
}
}
}

@@ -674,2 +702,7 @@ // src/openai-completion-language-model.ts

}
if (mode.toolChoice) {
throw new import_provider3.UnsupportedFunctionalityError({
functionality: "toolChoice"
});
}
return baseArgs;

@@ -676,0 +709,0 @@ }

@@ -121,2 +121,15 @@ "use strict";

// src/map-openai-chat-logprobs.ts
function mapOpenAIChatLogProbsOutput(logprobs) {
var _a, _b;
return (_b = (_a = logprobs == null ? void 0 : logprobs.content) == null ? void 0 : _a.map(({ token, logprob, top_logprobs }) => ({
token,
logprob,
topLogprobs: top_logprobs ? top_logprobs.map(({ token: token2, logprob: logprob2 }) => ({
token: token2,
logprob: logprob2
})) : []
}))) != null ? _b : void 0;
}
// src/map-openai-finish-reason.ts

@@ -155,15 +168,2 @@ function mapOpenAIFinishReason(finishReason) {

// src/map-openai-chat-logprobs.ts
function mapOpenAIChatLogProbsOutput(logprobs) {
var _a, _b;
return (_b = (_a = logprobs == null ? void 0 : logprobs.content) == null ? void 0 : _a.map(({ token, logprob, top_logprobs }) => ({
token,
logprob,
topLogprobs: top_logprobs ? top_logprobs.map(({ token: token2, logprob: logprob2 }) => ({
token: token2,
logprob: logprob2
})) : []
}))) != null ? _b : void 0;
}
// src/openai-chat-language-model.ts

@@ -191,3 +191,2 @@ var OpenAIChatLanguageModel = class {

}) {
var _a;
const type = mode.type;

@@ -214,14 +213,3 @@ const baseArgs = {

case "regular": {
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
return {
...baseArgs,
tools: tools == null ? void 0 : tools.map((tool) => ({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters
}
}))
};
return { ...baseArgs, ...prepareToolsAndToolChoice(mode) };
}

@@ -515,2 +503,42 @@ case "object-json": {

});
function prepareToolsAndToolChoice(mode) {
var _a;
const tools = ((_a = mode.tools) == null ? void 0 : _a.length) ? mode.tools : void 0;
if (tools == null) {
return { tools: void 0, tool_choice: void 0 };
}
const mappedTools = tools.map((tool) => ({
type: "function",
function: {
name: tool.name,
description: tool.description,
parameters: tool.parameters
}
}));
const toolChoice = mode.toolChoice;
if (toolChoice == null) {
return { tools: mappedTools, tool_choice: void 0 };
}
const type = toolChoice.type;
switch (type) {
case "auto":
case "none":
case "required":
return { tools: mappedTools, tool_choice: type };
case "tool":
return {
tools: mappedTools,
tool_choice: {
type: "function",
function: {
name: toolChoice.toolName
}
}
};
default: {
const _exhaustiveCheck = type;
throw new Error(`Unsupported tool choice type: ${_exhaustiveCheck}`);
}
}
}

@@ -674,2 +702,7 @@ // src/openai-completion-language-model.ts

}
if (mode.toolChoice) {
throw new import_provider3.UnsupportedFunctionalityError({
functionality: "toolChoice"
});
}
return baseArgs;

@@ -676,0 +709,0 @@ }

{
"name": "@ai-sdk/openai",
"version": "0.0.16",
"version": "0.0.17",
"license": "Apache-2.0",

@@ -21,4 +21,4 @@ "sideEffects": false,

"dependencies": {
"@ai-sdk/provider": "0.0.7",
"@ai-sdk/provider-utils": "0.0.10"
"@ai-sdk/provider": "0.0.8",
"@ai-sdk/provider-utils": "0.0.11"
},

@@ -25,0 +25,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

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