@langchain/openai 0.2.8 → 0.2.10

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.
@@ -899,6 +899,7 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
899
899
  this.openAIApiKey =
900
900
  fields?.apiKey ??
901
901
  fields?.openAIApiKey ??
902
+ fields?.configuration?.apiKey ??
902
903
  (0, env_1.getEnvironmentVariable)("OPENAI_API_KEY");
903
904
  this.apiKey = this.openAIApiKey;
904
905
  this.azureOpenAIApiKey =
@@ -1363,7 +1364,9 @@ class ChatOpenAI extends chat_models_1.BaseChatModel {
1363
1364
  * @param {OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming} request
1364
1365
  * @param {OpenAICoreRequestOptions | undefined} options
1365
1366
  */
1366
- async betaParsedCompletionWithRetry(request, options) {
1367
+ async betaParsedCompletionWithRetry(request, options
1368
+ // Avoid relying importing a beta type with no official entrypoint
1369
+ ) {
1367
1370
  const requestOptions = this._getClientOptions(options);
1368
1371
  return this.caller.call(async () => {
1369
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 */
@@ -895,6 +895,7 @@ export class ChatOpenAI extends BaseChatModel {
895
895
  this.openAIApiKey =
896
896
  fields?.apiKey ??
897
897
  fields?.openAIApiKey ??
898
+ fields?.configuration?.apiKey ??
898
899
  getEnvironmentVariable("OPENAI_API_KEY");
899
900
  this.apiKey = this.openAIApiKey;
900
901
  this.azureOpenAIApiKey =
@@ -1359,7 +1360,9 @@ export class ChatOpenAI extends BaseChatModel {
1359
1360
  * @param {OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming} request
1360
1361
  * @param {OpenAICoreRequestOptions | undefined} options
1361
1362
  */
1362
- async betaParsedCompletionWithRetry(request, options) {
1363
+ async betaParsedCompletionWithRetry(request, options
1364
+ // Avoid relying importing a beta type with no official entrypoint
1365
+ ) {
1363
1366
  const requestOptions = this._getClientOptions(options);
1364
1367
  return this.caller.call(async () => {
1365
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.8",
3
+ "version": "0.2.10",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@langchain/core": ">=0.2.26 <0.3.0",
39
39
  "js-tiktoken": "^1.0.12",
40
- "openai": "^4.55.0",
40
+ "openai": "^4.57.3",
41
41
  "zod": "^3.22.4",
42
42
  "zod-to-json-schema": "^3.22.3"
43
43
  },