Socket
Socket
Sign inDemoInstall

@langchain/openai

Package Overview
Dependencies
Maintainers
8
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/openai - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

3

dist/chat_models.d.ts

@@ -11,2 +11,3 @@ import { type ClientOptions, OpenAI as OpenAIClient } from "openai";

import type { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput, OpenAICoreRequestOptions, LegacyOpenAIInput } from "./types.js";
import { OpenAIToolChoice } from "./utils/openai.js";
export type { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput };

@@ -25,3 +26,3 @@ interface TokenUsage {

tools?: StructuredToolInterface[] | OpenAIClient.ChatCompletionTool[];
tool_choice?: OpenAIClient.ChatCompletionToolChoiceOption;
tool_choice?: OpenAIToolChoice;
promptIndex?: number;

@@ -28,0 +29,0 @@ response_format?: {

@@ -12,3 +12,3 @@ import { OpenAI as OpenAIClient } from "openai";

import { getEndpoint } from "./utils/azure.js";
import { wrapOpenAIClientError } from "./utils/openai.js";
import { formatToOpenAIToolChoice, wrapOpenAIClientError, } from "./utils/openai.js";
import { formatFunctionDefinitions, } from "./utils/openai-format-fndef.js";

@@ -568,3 +568,3 @@ function extractGenericMessageCustomRole(message) {

: options?.tools,
tool_choice: options?.tool_choice,
tool_choice: formatToOpenAIToolChoice(options?.tool_choice),
response_format: options?.response_format,

@@ -571,0 +571,0 @@ seed: options?.seed,

@@ -0,1 +1,2 @@

import { OpenAI as OpenAIClient } from "openai";
import type { StructuredToolInterface } from "@langchain/core/tools";

@@ -18,1 +19,3 @@ import { convertToOpenAIFunction, convertToOpenAITool } from "@langchain/core/utils/function_calling";

};
export type OpenAIToolChoice = OpenAIClient.ChatCompletionToolChoiceOption | "any" | string;
export declare function formatToOpenAIToolChoice(toolChoice?: OpenAIToolChoice): OpenAIClient.ChatCompletionToolChoiceOption | undefined;

@@ -1,2 +0,2 @@

import { APIConnectionTimeoutError, APIUserAbortError } from "openai";
import { APIConnectionTimeoutError, APIUserAbortError, } from "openai";
import { zodToJsonSchema } from "zod-to-json-schema";

@@ -31,1 +31,26 @@ import { convertToOpenAIFunction, convertToOpenAITool, } from "@langchain/core/utils/function_calling";

}
export function formatToOpenAIToolChoice(toolChoice) {
if (!toolChoice) {
return undefined;
}
else if (toolChoice === "any" || toolChoice === "required") {
return "required";
}
else if (toolChoice === "auto") {
return "auto";
}
else if (toolChoice === "none") {
return "none";
}
else if (typeof toolChoice === "string") {
return {
type: "function",
function: {
name: toolChoice,
},
};
}
else {
return toolChoice;
}
}
{
"name": "@langchain/openai",
"version": "0.2.3",
"version": "0.2.4",
"description": "OpenAI integrations for LangChain.js",

@@ -5,0 +5,0 @@ "type": "module",

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