@langchain/openai 0.1.1 → 0.1.3

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.
@@ -13,7 +13,7 @@ export declare class AzureChatOpenAI extends ChatOpenAI {
13
13
  } & BaseChatModelParams & {
14
14
  configuration?: ClientOptions & LegacyOpenAIInput;
15
15
  });
16
- protected getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
16
+ getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
17
17
  protected _getClientOptions(options: OpenAICoreRequestOptions | undefined): OpenAICoreRequestOptions;
18
18
  toJSON(): any;
19
19
  }
@@ -532,6 +532,7 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
532
532
  ...(options?.stream_options !== undefined
533
533
  ? { stream_options: options.stream_options }
534
534
  : {}),
535
+ parallel_tool_calls: options?.parallel_tool_calls,
535
536
  ...this.modelKwargs,
536
537
  };
537
538
  return params;
@@ -27,9 +27,22 @@ export interface ChatOpenAICallOptions extends OpenAICallOptions, BaseFunctionCa
27
27
  type: "json_object";
28
28
  };
29
29
  seed?: number;
30
+ /**
31
+ * Additional options to pass to streamed completions.
32
+ */
30
33
  stream_options?: {
34
+ /**
35
+ * Whether or not to include token usage in the stream.
36
+ * If set to `true`, this will include an additional
37
+ * chunk at the end of the stream with the token usage.
38
+ */
31
39
  include_usage: boolean;
32
40
  };
41
+ /**
42
+ * Whether or not to restrict the ability to
43
+ * call multiple tools in one response.
44
+ */
45
+ parallel_tool_calls?: boolean;
33
46
  }
34
47
  /**
35
48
  * Wrapper around OpenAI large language models that use the Chat endpoint.
@@ -106,7 +119,7 @@ export declare class ChatOpenAI<CallOptions extends ChatOpenAICallOptions = Chat
106
119
  },
107
120
  /** @deprecated */
108
121
  configuration?: ClientOptions & LegacyOpenAIInput);
109
- protected getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
122
+ getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
110
123
  bindTools(tools: (Record<string, unknown> | StructuredToolInterface)[], kwargs?: Partial<CallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>;
111
124
  /**
112
125
  * Get the parameters used to invoke the model
@@ -528,6 +528,7 @@ export class ChatOpenAI extends BaseChatModel {
528
528
  ...(options?.stream_options !== undefined
529
529
  ? { stream_options: options.stream_options }
530
530
  : {}),
531
+ parallel_tool_calls: options?.parallel_tool_calls,
531
532
  ...this.modelKwargs,
532
533
  };
533
534
  return params;
package/dist/legacy.cjs CHANGED
@@ -227,7 +227,9 @@ class OpenAIChat extends llms_1.LLM {
227
227
  value: void 0
228
228
  });
229
229
  this.openAIApiKey =
230
- fields?.openAIApiKey ?? (0, env_1.getEnvironmentVariable)("OPENAI_API_KEY");
230
+ fields?.apiKey ??
231
+ fields?.openAIApiKey ??
232
+ (0, env_1.getEnvironmentVariable)("OPENAI_API_KEY");
231
233
  this.azureOpenAIApiKey =
232
234
  fields?.azureOpenAIApiKey ??
233
235
  (0, env_1.getEnvironmentVariable)("AZURE_OPENAI_API_KEY");
package/dist/legacy.js CHANGED
@@ -224,7 +224,9 @@ export class OpenAIChat extends LLM {
224
224
  value: void 0
225
225
  });
226
226
  this.openAIApiKey =
227
- fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY");
227
+ fields?.apiKey ??
228
+ fields?.openAIApiKey ??
229
+ getEnvironmentVariable("OPENAI_API_KEY");
228
230
  this.azureOpenAIApiKey =
229
231
  fields?.azureOpenAIApiKey ??
230
232
  getEnvironmentVariable("AZURE_OPENAI_API_KEY");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/openai",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -16,33 +16,28 @@
16
16
  "scripts": {
17
17
  "build": "yarn turbo:command build:internal --filter=@langchain/openai",
18
18
  "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking",
19
- "build:deps": "yarn run turbo:command build --filter=@langchain/core",
20
- "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/",
21
- "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs",
22
- "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch",
23
- "build:scripts": "yarn create-entrypoints && yarn check-tree-shaking",
24
19
  "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
25
20
  "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
26
21
  "lint": "yarn lint:eslint && yarn lint:dpdm",
27
22
  "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
28
23
  "clean": "rm -rf .turbo dist/",
29
24
  "prepack": "yarn build",
30
- "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
31
- "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
32
- "test:single": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
25
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
26
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
27
+ "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
33
28
  "test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
29
+ "test:standard:unit": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.standard\\.test.ts --testTimeout 100000 --maxWorkers=50%",
30
+ "test:standard:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.standard\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
31
+ "test:standard": "yarn test:standard:unit && yarn test:standard:int",
34
32
  "format": "prettier --config .prettierrc --write \"src\"",
35
- "format:check": "prettier --config .prettierrc --check \"src\"",
36
- "move-cjs-to-dist": "yarn lc-build --config ./langchain.config.js --move-cjs-dist",
37
- "create-entrypoints": "yarn lc-build --config ./langchain.config.js --create-entrypoints",
38
- "check-tree-shaking": "yarn lc-build --config ./langchain.config.js --tree-shaking"
33
+ "format:check": "prettier --config .prettierrc --check \"src\""
39
34
  },
40
35
  "author": "LangChain",
41
36
  "license": "MIT",
42
37
  "dependencies": {
43
38
  "@langchain/core": ">=0.2.5 <0.3.0",
44
39
  "js-tiktoken": "^1.0.12",
45
- "openai": "^4.41.1",
40
+ "openai": "^4.49.1",
46
41
  "zod": "^3.22.4",
47
42
  "zod-to-json-schema": "^3.22.3"
48
43
  },
@@ -50,6 +45,7 @@
50
45
  "@azure/identity": "^4.2.0",
51
46
  "@jest/globals": "^29.5.0",
52
47
  "@langchain/scripts": "~0.0.14",
48
+ "@langchain/standard-tests": "0.0.0",
53
49
  "@swc/core": "^1.3.90",
54
50
  "@swc/jest": "^0.2.29",
55
51
  "dpdm": "^3.12.0",
@@ -65,6 +61,7 @@
65
61
  "prettier": "^2.8.3",
66
62
  "release-it": "^15.10.1",
67
63
  "rimraf": "^5.0.1",
64
+ "ts-jest": "^29.1.0",
68
65
  "typescript": "~5.1.6"
69
66
  },
70
67
  "publishConfig": {