langchain 0.3.33 → 0.3.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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ⚡ Building applications with LLMs through composability ⚡
4
4
 
5
- [![CI](https://github.com/langchain-ai/langchainjs/actions/workflows/ci.yml/badge.svg)](https://github.com/langchain-ai/langchainjs/actions/workflows/ci.yml) ![npm](https://img.shields.io/npm/dm/langchain) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai) [![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/langchain-ai/langchainjs)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![npm](https://img.shields.io/npm/dm/langchain) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai) [![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/langchain-ai/langchainjs)
6
6
  [<img src="https://github.com/codespaces/badge.svg" title="Open in Github Codespace" width="150" height="20">](https://codespaces.new/langchain-ai/langchainjs)
7
7
 
8
8
  Looking for the Python version? Check out [LangChain](https://github.com/langchain-ai/langchain).
@@ -43,15 +43,13 @@ This framework consists of several parts.
43
43
 
44
44
  The LangChain libraries themselves are made up of several different packages.
45
45
 
46
- - **[`@langchain/core`](https://github.com/langchain-ai/langchainjs/blob/main/langchain-core)**: Base abstractions and LangChain Expression Language.
46
+ - **[`@langchain/core`](https://github.com/langchain-ai/langchainjs/blob/main/langchain-core)**: Base abstractions.
47
47
  - **[`@langchain/community`](https://github.com/langchain-ai/langchainjs/blob/main/libs/langchain-community)**: Third party integrations.
48
48
  - **[`langchain`](https://github.com/langchain-ai/langchainjs/blob/main/langchain)**: Chains, agents, and retrieval strategies that make up an application's cognitive architecture.
49
49
  - **[LangGraph.js](https://langchain-ai.github.io/langgraphjs/)**: LangGraph powers production-grade agents, trusted by Linkedin, Uber, Klarna, GitLab, and many more. Build robust and stateful multi-actor applications with LLMs by modeling steps as edges and nodes in a graph. Integrates smoothly with LangChain, but can be used without it.
50
50
 
51
51
  Integrations may also be split into their own compatible packages.
52
52
 
53
- ![LangChain Stack](https://github.com/langchain-ai/langchainjs/blob/main/docs/core_docs/static/svg/langchain_stack_062024.svg)
54
-
55
53
  This library aims to assist in the development of those types of applications. Common examples of these applications include:
56
54
 
57
55
  **❓Question Answering over specific documents**
@@ -200,6 +200,9 @@ function _inferModelProvider(modelName) {
200
200
  else if (modelName.startsWith("amazon.")) {
201
201
  return "bedrock";
202
202
  }
203
+ else if (modelName.startsWith("mistral")) {
204
+ return "mistralai";
205
+ }
203
206
  else {
204
207
  return undefined;
205
208
  }
@@ -263,12 +266,13 @@ class ConfigurableModel extends chat_models_1.BaseChatModel {
263
266
  configurable: true,
264
267
  writable: true,
265
268
  value: (schema, ...args) => {
266
- this._queuedMethodOperations.withStructuredOutput = [schema, ...args];
269
+ const newQueuedOperations = { ...this._queuedMethodOperations };
270
+ newQueuedOperations.withStructuredOutput = [schema, ...args];
267
271
  return new ConfigurableModel({
268
272
  defaultConfig: this._defaultConfig,
269
273
  configurableFields: this._configurableFields,
270
274
  configPrefix: this._configPrefix,
271
- queuedMethodOperations: this._queuedMethodOperations,
275
+ queuedMethodOperations: newQueuedOperations,
272
276
  });
273
277
  }
274
278
  });
@@ -317,12 +321,13 @@ class ConfigurableModel extends chat_models_1.BaseChatModel {
317
321
  bindTools(tools,
318
322
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
319
323
  params) {
320
- this._queuedMethodOperations.bindTools = [tools, params];
324
+ const newQueuedOperations = { ...this._queuedMethodOperations };
325
+ newQueuedOperations.bindTools = [tools, params];
321
326
  return new ConfigurableModel({
322
327
  defaultConfig: this._defaultConfig,
323
328
  configurableFields: this._configurableFields,
324
329
  configPrefix: this._configPrefix,
325
- queuedMethodOperations: this._queuedMethodOperations,
330
+ queuedMethodOperations: newQueuedOperations,
326
331
  });
327
332
  }
328
333
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -162,6 +162,9 @@ export function _inferModelProvider(modelName) {
162
162
  else if (modelName.startsWith("amazon.")) {
163
163
  return "bedrock";
164
164
  }
165
+ else if (modelName.startsWith("mistral")) {
166
+ return "mistralai";
167
+ }
165
168
  else {
166
169
  return undefined;
167
170
  }
@@ -225,12 +228,13 @@ export class ConfigurableModel extends BaseChatModel {
225
228
  configurable: true,
226
229
  writable: true,
227
230
  value: (schema, ...args) => {
228
- this._queuedMethodOperations.withStructuredOutput = [schema, ...args];
231
+ const newQueuedOperations = { ...this._queuedMethodOperations };
232
+ newQueuedOperations.withStructuredOutput = [schema, ...args];
229
233
  return new ConfigurableModel({
230
234
  defaultConfig: this._defaultConfig,
231
235
  configurableFields: this._configurableFields,
232
236
  configPrefix: this._configPrefix,
233
- queuedMethodOperations: this._queuedMethodOperations,
237
+ queuedMethodOperations: newQueuedOperations,
234
238
  });
235
239
  }
236
240
  });
@@ -279,12 +283,13 @@ export class ConfigurableModel extends BaseChatModel {
279
283
  bindTools(tools,
280
284
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
281
285
  params) {
282
- this._queuedMethodOperations.bindTools = [tools, params];
286
+ const newQueuedOperations = { ...this._queuedMethodOperations };
287
+ newQueuedOperations.bindTools = [tools, params];
283
288
  return new ConfigurableModel({
284
289
  defaultConfig: this._defaultConfig,
285
290
  configurableFields: this._configurableFields,
286
291
  configPrefix: this._configPrefix,
287
- queuedMethodOperations: this._queuedMethodOperations,
292
+ queuedMethodOperations: newQueuedOperations,
288
293
  });
289
294
  }
290
295
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.BufferLoader = void 0;
37
37
  const env_1 = require("@langchain/core/utils/env");
38
- const base_js_1 = require("../base.cjs");
38
+ const base_1 = require("@langchain/core/document_loaders/base");
39
39
  /**
40
40
  * Abstract class that extends the `BaseDocumentLoader` class. It
41
41
  * represents a document loader that loads documents from a buffer. The
@@ -43,7 +43,7 @@ const base_js_1 = require("../base.cjs");
43
43
  * based on the type of `filePathOrBlob`, and then calls the `parse()`
44
44
  * method to parse the buffer and return the documents.
45
45
  */
46
- class BufferLoader extends base_js_1.BaseDocumentLoader {
46
+ class BufferLoader extends base_1.BaseDocumentLoader {
47
47
  constructor(filePathOrBlob) {
48
48
  super();
49
49
  Object.defineProperty(this, "filePathOrBlob", {
@@ -1,6 +1,6 @@
1
1
  import type { readFile as ReadFileT } from "node:fs/promises";
2
2
  import { Document } from "@langchain/core/documents";
3
- import { BaseDocumentLoader } from "../base.js";
3
+ import { BaseDocumentLoader } from "@langchain/core/document_loaders/base";
4
4
  /**
5
5
  * Abstract class that extends the `BaseDocumentLoader` class. It
6
6
  * represents a document loader that loads documents from a buffer. The
@@ -1,5 +1,5 @@
1
1
  import { getEnv } from "@langchain/core/utils/env";
2
- import { BaseDocumentLoader } from "../base.js";
2
+ import { BaseDocumentLoader } from "@langchain/core/document_loaders/base";
3
3
  /**
4
4
  * Abstract class that extends the `BaseDocumentLoader` class. It
5
5
  * represents a document loader that loads documents from a buffer. The
@@ -141,7 +141,19 @@ class JSONLinesLoader extends text_js_1.TextLoader {
141
141
  .filter(Boolean)
142
142
  .map((line) => JSON.parse(line));
143
143
  const pointer = jsonpointer_1.default.compile(this.pointer);
144
- return jsons.map((json) => pointer.get(json));
144
+ return jsons.map((json) => {
145
+ const data = pointer.get(json);
146
+ if (typeof data === "string") {
147
+ return data;
148
+ }
149
+ if (!data) {
150
+ return "";
151
+ }
152
+ if (typeof data === "object") {
153
+ return JSON.stringify(data);
154
+ }
155
+ return "";
156
+ });
145
157
  }
146
158
  }
147
159
  exports.JSONLinesLoader = JSONLinesLoader;
@@ -134,6 +134,18 @@ export class JSONLinesLoader extends TextLoader {
134
134
  .filter(Boolean)
135
135
  .map((line) => JSON.parse(line));
136
136
  const pointer = jsonpointer.compile(this.pointer);
137
- return jsons.map((json) => pointer.get(json));
137
+ return jsons.map((json) => {
138
+ const data = pointer.get(json);
139
+ if (typeof data === "string") {
140
+ return data;
141
+ }
142
+ if (!data) {
143
+ return "";
144
+ }
145
+ if (typeof data === "object") {
146
+ return JSON.stringify(data);
147
+ }
148
+ return "";
149
+ });
138
150
  }
139
151
  }
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.TextLoader = void 0;
37
37
  const documents_1 = require("@langchain/core/documents");
38
38
  const env_1 = require("@langchain/core/utils/env");
39
- const base_js_1 = require("../base.cjs");
39
+ const base_1 = require("@langchain/core/document_loaders/base");
40
40
  /**
41
41
  * A class that extends the `BaseDocumentLoader` class. It represents a
42
42
  * document loader that loads documents from a text file. The `load()`
@@ -50,7 +50,7 @@ const base_js_1 = require("../base.cjs");
50
50
  * const docs = await loader.load();
51
51
  * ```
52
52
  */
53
- class TextLoader extends base_js_1.BaseDocumentLoader {
53
+ class TextLoader extends base_1.BaseDocumentLoader {
54
54
  constructor(filePathOrBlob) {
55
55
  super();
56
56
  Object.defineProperty(this, "filePathOrBlob", {
@@ -1,6 +1,6 @@
1
1
  import type { readFile as ReadFileT } from "node:fs/promises";
2
2
  import { Document } from "@langchain/core/documents";
3
- import { BaseDocumentLoader } from "../base.js";
3
+ import { BaseDocumentLoader } from "@langchain/core/document_loaders/base";
4
4
  /**
5
5
  * A class that extends the `BaseDocumentLoader` class. It represents a
6
6
  * document loader that loads documents from a text file. The `load()`
@@ -1,6 +1,6 @@
1
1
  import { Document } from "@langchain/core/documents";
2
2
  import { getEnv } from "@langchain/core/utils/env";
3
- import { BaseDocumentLoader } from "../base.js";
3
+ import { BaseDocumentLoader } from "@langchain/core/document_loaders/base";
4
4
  /**
5
5
  * A class that extends the `BaseDocumentLoader` class. It represents a
6
6
  * document loader that loads documents from a text file. The `load()`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.3.33",
3
+ "version": "0.3.34",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -440,7 +440,7 @@
440
440
  "@types/ws": "^8",
441
441
  "@typescript-eslint/eslint-plugin": "^5.58.0",
442
442
  "@typescript-eslint/parser": "^5.58.0",
443
- "axios": "^1.11.0",
443
+ "axios": "^1.12.0",
444
444
  "cheerio": "1.0.0-rc.12",
445
445
  "dotenv": "^16.0.3",
446
446
  "dpdm": "^3.14.0",
@@ -545,7 +545,7 @@
545
545
  "js-tiktoken": "^1.0.12",
546
546
  "js-yaml": "^4.1.0",
547
547
  "jsonpointer": "^5.0.1",
548
- "langsmith": "^0.3.46",
548
+ "langsmith": "^0.3.67",
549
549
  "openapi-types": "^12.1.3",
550
550
  "p-retry": "4",
551
551
  "uuid": "^10.0.0",