@langchain/openai 0.0.33 → 0.0.34

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.
@@ -18,9 +18,13 @@ class AzureChatOpenAI extends chat_models_js_1.ChatOpenAI {
18
18
  constructor(fields) {
19
19
  const newFields = fields ? { ...fields } : fields;
20
20
  if (newFields) {
21
- newFields.azureOpenAIApiDeploymentName = newFields.deploymentName;
22
- newFields.azureOpenAIApiKey = newFields.openAIApiKey;
23
- newFields.azureOpenAIApiVersion = newFields.openAIApiVersion;
21
+ // don't rewrite the fields if they are already set
22
+ newFields.azureOpenAIApiDeploymentName =
23
+ newFields.azureOpenAIApiDeploymentName ?? newFields.deploymentName;
24
+ newFields.azureOpenAIApiKey =
25
+ newFields.azureOpenAIApiKey ?? newFields.openAIApiKey;
26
+ newFields.azureOpenAIApiVersion =
27
+ newFields.azureOpenAIApiVersion ?? newFields.openAIApiVersion;
24
28
  }
25
29
  super(newFields);
26
30
  }
@@ -15,9 +15,13 @@ export class AzureChatOpenAI extends ChatOpenAI {
15
15
  constructor(fields) {
16
16
  const newFields = fields ? { ...fields } : fields;
17
17
  if (newFields) {
18
- newFields.azureOpenAIApiDeploymentName = newFields.deploymentName;
19
- newFields.azureOpenAIApiKey = newFields.openAIApiKey;
20
- newFields.azureOpenAIApiVersion = newFields.openAIApiVersion;
18
+ // don't rewrite the fields if they are already set
19
+ newFields.azureOpenAIApiDeploymentName =
20
+ newFields.azureOpenAIApiDeploymentName ?? newFields.deploymentName;
21
+ newFields.azureOpenAIApiKey =
22
+ newFields.azureOpenAIApiKey ?? newFields.openAIApiKey;
23
+ newFields.azureOpenAIApiVersion =
24
+ newFields.azureOpenAIApiVersion ?? newFields.openAIApiVersion;
21
25
  }
22
26
  super(newFields);
23
27
  }
@@ -9,9 +9,13 @@ class AzureOpenAIEmbeddings extends embeddings_js_1.OpenAIEmbeddings {
9
9
  constructor(fields, configuration) {
10
10
  const newFields = { ...fields };
11
11
  if (Object.entries(newFields).length) {
12
- newFields.azureOpenAIApiDeploymentName = newFields.deploymentName;
13
- newFields.azureOpenAIApiKey = newFields.apiKey;
14
- newFields.azureOpenAIApiVersion = newFields.openAIApiVersion;
12
+ // don't rewrite the fields if they are already set
13
+ newFields.azureOpenAIApiDeploymentName =
14
+ newFields.azureOpenAIApiDeploymentName ?? newFields.deploymentName;
15
+ newFields.azureOpenAIApiKey =
16
+ newFields.azureOpenAIApiKey ?? newFields.apiKey;
17
+ newFields.azureOpenAIApiVersion =
18
+ newFields.azureOpenAIApiVersion ?? newFields.openAIApiVersion;
15
19
  }
16
20
  super(newFields, configuration);
17
21
  }
@@ -6,9 +6,13 @@ export class AzureOpenAIEmbeddings extends OpenAIEmbeddings {
6
6
  constructor(fields, configuration) {
7
7
  const newFields = { ...fields };
8
8
  if (Object.entries(newFields).length) {
9
- newFields.azureOpenAIApiDeploymentName = newFields.deploymentName;
10
- newFields.azureOpenAIApiKey = newFields.apiKey;
11
- newFields.azureOpenAIApiVersion = newFields.openAIApiVersion;
9
+ // don't rewrite the fields if they are already set
10
+ newFields.azureOpenAIApiDeploymentName =
11
+ newFields.azureOpenAIApiDeploymentName ?? newFields.deploymentName;
12
+ newFields.azureOpenAIApiKey =
13
+ newFields.azureOpenAIApiKey ?? newFields.apiKey;
14
+ newFields.azureOpenAIApiVersion =
15
+ newFields.azureOpenAIApiVersion ?? newFields.openAIApiVersion;
12
16
  }
13
17
  super(newFields, configuration);
14
18
  }
@@ -15,9 +15,13 @@ class AzureOpenAI extends llms_js_1.OpenAI {
15
15
  constructor(fields) {
16
16
  const newFields = fields ? { ...fields } : fields;
17
17
  if (newFields) {
18
- newFields.azureOpenAIApiDeploymentName = newFields.deploymentName;
19
- newFields.azureOpenAIApiKey = newFields.openAIApiKey;
20
- newFields.azureOpenAIApiVersion = newFields.openAIApiVersion;
18
+ // don't rewrite the fields if they are already set
19
+ newFields.azureOpenAIApiDeploymentName =
20
+ newFields.azureOpenAIApiDeploymentName ?? newFields.deploymentName;
21
+ newFields.azureOpenAIApiKey =
22
+ newFields.azureOpenAIApiKey ?? newFields.openAIApiKey;
23
+ newFields.azureOpenAIApiVersion =
24
+ newFields.azureOpenAIApiVersion ?? newFields.openAIApiVersion;
21
25
  }
22
26
  super(newFields);
23
27
  }
@@ -12,9 +12,13 @@ export class AzureOpenAI extends OpenAI {
12
12
  constructor(fields) {
13
13
  const newFields = fields ? { ...fields } : fields;
14
14
  if (newFields) {
15
- newFields.azureOpenAIApiDeploymentName = newFields.deploymentName;
16
- newFields.azureOpenAIApiKey = newFields.openAIApiKey;
17
- newFields.azureOpenAIApiVersion = newFields.openAIApiVersion;
15
+ // don't rewrite the fields if they are already set
16
+ newFields.azureOpenAIApiDeploymentName =
17
+ newFields.azureOpenAIApiDeploymentName ?? newFields.deploymentName;
18
+ newFields.azureOpenAIApiKey =
19
+ newFields.azureOpenAIApiKey ?? newFields.openAIApiKey;
20
+ newFields.azureOpenAIApiVersion =
21
+ newFields.azureOpenAIApiVersion ?? newFields.openAIApiVersion;
18
22
  }
19
23
  super(newFields);
20
24
  }
@@ -25,7 +25,7 @@ exports.getEndpoint = void 0;
25
25
  */
26
26
  function getEndpoint(config) {
27
27
  const { azureOpenAIApiDeploymentName, azureOpenAIApiInstanceName, azureOpenAIApiKey, azureOpenAIBasePath, baseURL, azureADTokenProvider, } = config;
28
- if (azureOpenAIApiKey &&
28
+ if ((azureOpenAIApiKey || azureADTokenProvider) &&
29
29
  azureOpenAIBasePath &&
30
30
  azureOpenAIApiDeploymentName) {
31
31
  return `${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`;
@@ -22,7 +22,7 @@
22
22
  */
23
23
  export function getEndpoint(config) {
24
24
  const { azureOpenAIApiDeploymentName, azureOpenAIApiInstanceName, azureOpenAIApiKey, azureOpenAIBasePath, baseURL, azureADTokenProvider, } = config;
25
- if (azureOpenAIApiKey &&
25
+ if ((azureOpenAIApiKey || azureADTokenProvider) &&
26
26
  azureOpenAIBasePath &&
27
27
  azureOpenAIApiDeploymentName) {
28
28
  return `${azureOpenAIBasePath}/${azureOpenAIApiDeploymentName}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/openai",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -14,7 +14,8 @@
14
14
  },
15
15
  "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-openai/",
16
16
  "scripts": {
17
- "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
17
+ "build": "yarn turbo:command build:internal --filter=@langchain/openai",
18
+ "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking",
18
19
  "build:deps": "yarn run turbo:command build --filter=@langchain/core",
19
20
  "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/",
20
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",
@@ -24,7 +25,7 @@
24
25
  "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
25
26
  "lint": "yarn lint:eslint && yarn lint:dpdm",
26
27
  "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
27
- "clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre",
28
+ "clean": "rm -rf .turbo dist/",
28
29
  "prepack": "yarn build",
29
30
  "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
30
31
  "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
@@ -48,7 +49,7 @@
48
49
  "devDependencies": {
49
50
  "@azure/identity": "^4.2.0",
50
51
  "@jest/globals": "^29.5.0",
51
- "@langchain/scripts": "~0.0",
52
+ "@langchain/scripts": "~0.0.14",
52
53
  "@swc/core": "^1.3.90",
53
54
  "@swc/jest": "^0.2.29",
54
55
  "dpdm": "^3.12.0",
@@ -1 +0,0 @@
1
- export {};