@langchain/openai 0.2.9 → 0.3.0-rc.0

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.
package/README.md CHANGED
@@ -17,18 +17,18 @@ You can do so by adding appropriate fields to your project's `package.json` like
17
17
  "name": "your-project",
18
18
  "version": "0.0.0",
19
19
  "dependencies": {
20
- "@langchain/openai": "^0.0.9",
21
- "langchain": "0.0.207"
20
+ "@langchain/core": "^0.3.0",
21
+ "@langchain/openai": "^0.0.0"
22
22
  },
23
23
  "resolutions": {
24
- "@langchain/core": "0.1.5"
24
+ "@langchain/core": "^0.3.0"
25
25
  },
26
26
  "overrides": {
27
- "@langchain/core": "0.1.5"
27
+ "@langchain/core": "^0.3.0"
28
28
  },
29
29
  "pnpm": {
30
30
  "overrides": {
31
- "@langchain/core": "0.1.5"
31
+ "@langchain/core": "^0.3.0"
32
32
  }
33
33
  }
34
34
  }
@@ -1364,7 +1364,9 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
1364
1364
  * @param {OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming} request
1365
1365
  * @param {OpenAICoreRequestOptions | undefined} options
1366
1366
  */
1367
- async betaParsedCompletionWithRetry(request, options) {
1367
+ async betaParsedCompletionWithRetry(request, options
1368
+ // Avoid relying importing a beta type with no official entrypoint
1369
+ ) {
1368
1370
  const requestOptions = this._getClientOptions(options);
1369
1371
  return this.caller.call(async () => {
1370
1372
  try {
@@ -6,7 +6,6 @@ import { BaseChatModel, BindToolsInput, LangSmithParams, type BaseChatModelParam
6
6
  import { type BaseFunctionCallOptions, type BaseLanguageModelInput, type StructuredOutputMethodOptions, type StructuredOutputMethodParams } from "@langchain/core/language_models/base";
7
7
  import { z } from "zod";
8
8
  import { Runnable } from "@langchain/core/runnables";
9
- import { ParsedChatCompletion } from "openai/resources/beta/chat/completions.mjs";
10
9
  import type { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput, OpenAICoreRequestOptions, LegacyOpenAIInput, ChatOpenAIResponseFormat } from "./types.js";
11
10
  import { OpenAIToolChoice } from "./utils/openai.js";
12
11
  export type { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput };
@@ -634,7 +633,7 @@ export declare class ChatOpenAI<CallOptions extends ChatOpenAICallOptions = Chat
634
633
  * @param {OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming} request
635
634
  * @param {OpenAICoreRequestOptions | undefined} options
636
635
  */
637
- betaParsedCompletionWithRetry(request: OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming, options?: OpenAICoreRequestOptions): Promise<ParsedChatCompletion<null>>;
636
+ betaParsedCompletionWithRetry(request: OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming, options?: OpenAICoreRequestOptions): Promise<ReturnType<OpenAIClient["beta"]["chat"]["completions"]["parse"]>>;
638
637
  protected _getClientOptions(options: OpenAICoreRequestOptions | undefined): OpenAICoreRequestOptions;
639
638
  _llmType(): string;
640
639
  /** @ignore */
@@ -1360,7 +1360,9 @@ export class ChatOpenAI extends BaseChatModel {
1360
1360
  * @param {OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming} request
1361
1361
  * @param {OpenAICoreRequestOptions | undefined} options
1362
1362
  */
1363
- async betaParsedCompletionWithRetry(request, options) {
1363
+ async betaParsedCompletionWithRetry(request, options
1364
+ // Avoid relying importing a beta type with no official entrypoint
1365
+ ) {
1364
1366
  const requestOptions = this._getClientOptions(options);
1365
1367
  return this.caller.call(async () => {
1366
1368
  try {
@@ -89,6 +89,7 @@ class DallEAPIWrapper extends tools_1.Tool {
89
89
  apiKey: openAIApiKey,
90
90
  organization,
91
91
  dangerouslyAllowBrowser: true,
92
+ baseUrl: fields?.baseUrl,
92
93
  };
93
94
  this.client = new openai_1.OpenAI(clientConfig);
94
95
  this.model = fields?.model ?? fields?.modelName ?? this.model;
@@ -73,6 +73,10 @@ export interface DallEAPIWrapperParams extends ToolParams {
73
73
  * The organization to use
74
74
  */
75
75
  organization?: string;
76
+ /**
77
+ * The base URL of the OpenAI API.
78
+ */
79
+ baseUrl?: string;
76
80
  }
77
81
  /**
78
82
  * A tool for generating images with Open AIs Dall-E 2 or 3 API.
@@ -86,6 +86,7 @@ export class DallEAPIWrapper extends Tool {
86
86
  apiKey: openAIApiKey,
87
87
  organization,
88
88
  dangerouslyAllowBrowser: true,
89
+ baseUrl: fields?.baseUrl,
89
90
  };
90
91
  this.client = new OpenAIClient(clientConfig);
91
92
  this.model = fields?.model ?? fields?.modelName ?? this.model;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/openai",
3
- "version": "0.2.9",
3
+ "version": "0.3.0-rc.0",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -35,15 +35,18 @@
35
35
  "author": "LangChain",
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "@langchain/core": ">=0.2.26 <0.3.0",
39
38
  "js-tiktoken": "^1.0.12",
40
- "openai": "^4.55.0",
39
+ "openai": "^4.57.3",
41
40
  "zod": "^3.22.4",
42
41
  "zod-to-json-schema": "^3.22.3"
43
42
  },
43
+ "peerDependencies": {
44
+ "@langchain/core": ">=0.2.26 <0.4.0 || 0.3.0-rc.0"
45
+ },
44
46
  "devDependencies": {
45
47
  "@azure/identity": "^4.2.1",
46
48
  "@jest/globals": "^29.5.0",
49
+ "@langchain/core": "workspace:*",
47
50
  "@langchain/scripts": ">=0.1.0 <0.2.0",
48
51
  "@langchain/standard-tests": "0.0.0",
49
52
  "@swc/core": "^1.3.90",