langchain 0.1.29 → 0.1.31

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.
@@ -15,8 +15,7 @@ export type CreateOpenAIToolsAgentParams = {
15
15
  * a different model that adds in equivalent support.
16
16
  */
17
17
  llm: BaseChatModel<BaseChatModelCallOptions & {
18
- tools?: StructuredToolInterface[] | OpenAIClient.ChatCompletionTool[];
19
- tool_choice?: OpenAIClient.ChatCompletionToolChoiceOption;
18
+ tools?: StructuredToolInterface[] | OpenAIClient.ChatCompletionTool[] | any[];
20
19
  }>;
21
20
  /** Tools this agent has access to. */
22
21
  tools: StructuredToolInterface[];
@@ -67,6 +67,7 @@ class OpenAIAssistantRunnable extends runnables_1.Runnable {
67
67
  });
68
68
  }
69
69
  async invoke(input, _options) {
70
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
71
  let run;
71
72
  if (this.asAgent && input.steps && input.steps.length > 0) {
72
73
  const parsedStepsInput = await this._parseStepsInput(input);
@@ -148,6 +149,7 @@ class OpenAIAssistantRunnable extends runnables_1.Runnable {
148
149
  if (!toolCalls) {
149
150
  return input;
150
151
  }
152
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
151
153
  const toolOutputs = toolCalls.flatMap((toolCall) => {
152
154
  const matchedAction = input.steps.find((step) => step.action.toolCallId === toolCall.id);
153
155
  return matchedAction
@@ -193,6 +195,7 @@ class OpenAIAssistantRunnable extends runnables_1.Runnable {
193
195
  }
194
196
  async _waitForRun(runId, threadId) {
195
197
  let inProgress = true;
198
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
196
199
  let run = {};
197
200
  while (inProgress) {
198
201
  run = await this.client.beta.threads.runs.retrieve(threadId, runId);
@@ -235,7 +238,9 @@ class OpenAIAssistantRunnable extends runnables_1.Runnable {
235
238
  return run.required_action?.submit_tool_outputs.tool_calls ?? [];
236
239
  }
237
240
  const actions = [];
238
- run.required_action?.submit_tool_outputs.tool_calls.forEach((item) => {
241
+ run.required_action?.submit_tool_outputs.tool_calls.forEach(
242
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
243
+ (item) => {
239
244
  const functionCall = item.function;
240
245
  const args = JSON.parse(functionCall.arguments);
241
246
  actions.push({
@@ -2,8 +2,8 @@ import { type ClientOptions, OpenAIClient } from "@langchain/openai";
2
2
  import { StructuredTool } from "@langchain/core/tools";
3
3
  import { Runnable, RunnableConfig } from "@langchain/core/runnables";
4
4
  import type { OpenAIAssistantFinish, OpenAIAssistantAction, OpenAIToolType } from "./schema.js";
5
- type ThreadMessage = OpenAIClient.Beta.Threads.ThreadMessage;
6
- type RequiredActionFunctionToolCall = OpenAIClient.Beta.Threads.RequiredActionFunctionToolCall;
5
+ type ThreadMessage = any;
6
+ type RequiredActionFunctionToolCall = any;
7
7
  type ExtractRunOutput<AsAgent extends boolean | undefined> = AsAgent extends true ? OpenAIAssistantFinish | OpenAIAssistantAction[] : ThreadMessage[] | RequiredActionFunctionToolCall[];
8
8
  export type OpenAIAssistantRunnableInput<AsAgent extends boolean | undefined = undefined> = {
9
9
  client?: OpenAIClient;
@@ -64,6 +64,7 @@ export class OpenAIAssistantRunnable extends Runnable {
64
64
  });
65
65
  }
66
66
  async invoke(input, _options) {
67
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
68
  let run;
68
69
  if (this.asAgent && input.steps && input.steps.length > 0) {
69
70
  const parsedStepsInput = await this._parseStepsInput(input);
@@ -145,6 +146,7 @@ export class OpenAIAssistantRunnable extends Runnable {
145
146
  if (!toolCalls) {
146
147
  return input;
147
148
  }
149
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
150
  const toolOutputs = toolCalls.flatMap((toolCall) => {
149
151
  const matchedAction = input.steps.find((step) => step.action.toolCallId === toolCall.id);
150
152
  return matchedAction
@@ -190,6 +192,7 @@ export class OpenAIAssistantRunnable extends Runnable {
190
192
  }
191
193
  async _waitForRun(runId, threadId) {
192
194
  let inProgress = true;
195
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
193
196
  let run = {};
194
197
  while (inProgress) {
195
198
  run = await this.client.beta.threads.runs.retrieve(threadId, runId);
@@ -232,7 +235,9 @@ export class OpenAIAssistantRunnable extends Runnable {
232
235
  return run.required_action?.submit_tool_outputs.tool_calls ?? [];
233
236
  }
234
237
  const actions = [];
235
- run.required_action?.submit_tool_outputs.tool_calls.forEach((item) => {
238
+ run.required_action?.submit_tool_outputs.tool_calls.forEach(
239
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
240
+ (item) => {
236
241
  const functionCall = item.function;
237
242
  const args = JSON.parse(functionCall.arguments);
238
243
  actions.push({
@@ -1,4 +1,3 @@
1
- import type { OpenAIClient } from "@langchain/openai";
2
1
  import type { AgentFinish, AgentAction } from "@langchain/core/agents";
3
2
  export type OpenAIAssistantFinish = AgentFinish & {
4
3
  runId: string;
@@ -9,4 +8,4 @@ export type OpenAIAssistantAction = AgentAction & {
9
8
  runId: string;
10
9
  threadId: string;
11
10
  };
12
- export type OpenAIToolType = Array<OpenAIClient.Beta.AssistantCreateParams.AssistantToolsCode | OpenAIClient.Beta.AssistantCreateParams.AssistantToolsRetrieval | OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction>;
11
+ export type OpenAIToolType = Array<any>;
@@ -1,5 +1,16 @@
1
- import type { OpenAIClient } from "@langchain/openai";
2
1
  import type { StructuredToolInterface } from "@langchain/core/tools";
3
2
  import { convertToOpenAIFunction, convertToOpenAITool } from "@langchain/core/utils/function_calling";
4
3
  export { convertToOpenAIFunction as formatToOpenAIFunction, convertToOpenAITool as formatToOpenAITool, };
5
- export declare function formatToOpenAIAssistantTool(tool: StructuredToolInterface): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction;
4
+ export declare function formatToOpenAIAssistantTool(tool: StructuredToolInterface): {
5
+ type: string;
6
+ function: {
7
+ name: string;
8
+ description: string;
9
+ parameters: import("zod-to-json-schema").JsonSchema7Type & {
10
+ $schema?: string | undefined;
11
+ definitions?: {
12
+ [key: string]: import("zod-to-json-schema").JsonSchema7Type;
13
+ } | undefined;
14
+ };
15
+ };
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -1281,7 +1281,7 @@
1281
1281
  "node-llama-cpp": "2.7.3",
1282
1282
  "notion-to-md": "^3.1.0",
1283
1283
  "officeparser": "^4.0.4",
1284
- "openai": "^4.26.1",
1284
+ "openai": "^4.32.1",
1285
1285
  "pdf-parse": "1.1.1",
1286
1286
  "peggy": "^3.0.2",
1287
1287
  "playwright": "^1.32.1",
@@ -1514,7 +1514,7 @@
1514
1514
  "@anthropic-ai/sdk": "^0.9.1",
1515
1515
  "@langchain/community": "~0.0.41",
1516
1516
  "@langchain/core": "~0.1.44",
1517
- "@langchain/openai": "~0.0.19",
1517
+ "@langchain/openai": "~0.0.26",
1518
1518
  "binary-extensions": "^2.2.0",
1519
1519
  "js-tiktoken": "^1.0.7",
1520
1520
  "js-yaml": "^4.1.0",