langchain 0.1.17 → 0.1.18

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.
@@ -22,6 +22,13 @@ const CYPHER_QA_TEMPLATE = `You are an assistant that helps to form nice and hum
22
22
  The information part contains the provided information that you must use to construct an answer.
23
23
  The provided information is authoritative, you must never doubt it or try to use your internal knowledge to correct it.
24
24
  Make the answer sound as a response to the question. Do not mention that you based the result on the given information.
25
+ Here is an example:
26
+
27
+ Question: Which managers own Neo4j stocks?
28
+ Context:[manager:CTL LLC, manager:JANE STREET GROUP LLC]
29
+ Helpful Answer: CTL LLC, JANE STREET GROUP LLC owns Neo4j stocks.
30
+
31
+ Follow this example when generating answers.
25
32
  If the provided information is empty, say that you don't know the answer.
26
33
  Information:
27
34
  {context}
@@ -19,6 +19,13 @@ const CYPHER_QA_TEMPLATE = `You are an assistant that helps to form nice and hum
19
19
  The information part contains the provided information that you must use to construct an answer.
20
20
  The provided information is authoritative, you must never doubt it or try to use your internal knowledge to correct it.
21
21
  Make the answer sound as a response to the question. Do not mention that you based the result on the given information.
22
+ Here is an example:
23
+
24
+ Question: Which managers own Neo4j stocks?
25
+ Context:[manager:CTL LLC, manager:JANE STREET GROUP LLC]
26
+ Helpful Answer: CTL LLC, JANE STREET GROUP LLC owns Neo4j stocks.
27
+
28
+ Follow this example when generating answers.
22
29
  If the provided information is empty, say that you don't know the answer.
23
30
  Information:
24
31
  {context}
@@ -1,7 +1,7 @@
1
1
  import type { BaseRetrieverInterface } from "@langchain/core/retrievers";
2
2
  import { type Runnable, type RunnableInterface } from "@langchain/core/runnables";
3
3
  import type { BaseMessage } from "@langchain/core/messages";
4
- import type { DocumentInterface } from "@langchain/core/documents";
4
+ import type { DocumentInterface, Document } from "@langchain/core/documents";
5
5
  /**
6
6
  * Parameters for the createRetrievalChain method.
7
7
  */
@@ -58,7 +58,7 @@ export declare function createRetrievalChain<RunOutput>({ retriever, combineDocs
58
58
  } & {
59
59
  [key: string]: unknown;
60
60
  }, {
61
- context: string;
61
+ context: Document[];
62
62
  answer: RunOutput;
63
63
  } & {
64
64
  [key: string]: unknown;
@@ -36,9 +36,9 @@ class SitemapLoader extends cheerio_js_1.CheerioWebBaseLoader {
36
36
  }
37
37
  _checkUrlPatterns(url) {
38
38
  if (!this.allowUrlPatterns) {
39
- return true;
39
+ return false;
40
40
  }
41
- return this.allowUrlPatterns.some((pattern) => new RegExp(pattern).test(url));
41
+ return !this.allowUrlPatterns.some((pattern) => !new RegExp(pattern).test(url));
42
42
  }
43
43
  async parseSitemap() {
44
44
  const $ = await cheerio_js_1.CheerioWebBaseLoader._scrape(this.webPath, this.caller, this.timeout, this.textDecoder, {
@@ -51,7 +51,7 @@ class SitemapLoader extends cheerio_js_1.CheerioWebBaseLoader {
51
51
  if (!loc) {
52
52
  return;
53
53
  }
54
- if (!this._checkUrlPatterns(loc)) {
54
+ if (this._checkUrlPatterns(loc)) {
55
55
  return;
56
56
  }
57
57
  const changefreq = $(element).find("changefreq").text();
@@ -7,10 +7,10 @@ import { CheerioWebBaseLoader, WebBaseLoaderParams } from "./cheerio.js";
7
7
  */
8
8
  export interface SitemapLoaderParams extends WebBaseLoaderParams {
9
9
  /**
10
- * @property {string[] | undefined} filterUrls - A list of regexes. Only URLs that match one of the filter URLs will be loaded.
10
+ * @property {(string | RegExp)[] | undefined} filterUrls - A list of regexes. Only URLs that match one of the filter URLs will be loaded.
11
11
  * WARNING: The filter URLs are interpreted as regular expressions. Escape special characters if needed.
12
12
  */
13
- filterUrls?: string[];
13
+ filterUrls?: (string | RegExp)[];
14
14
  /**
15
15
  * The size to chunk the sitemap URLs into for scraping.
16
16
  * @default {300}
@@ -25,7 +25,7 @@ type SiteMapElement = {
25
25
  };
26
26
  export declare class SitemapLoader extends CheerioWebBaseLoader implements SitemapLoaderParams {
27
27
  webPath: string;
28
- allowUrlPatterns: string[] | undefined;
28
+ allowUrlPatterns: (string | RegExp)[] | undefined;
29
29
  chunkSize: number;
30
30
  constructor(webPath: string, params?: SitemapLoaderParams);
31
31
  _checkUrlPatterns(url: string): boolean;
@@ -33,9 +33,9 @@ export class SitemapLoader extends CheerioWebBaseLoader {
33
33
  }
34
34
  _checkUrlPatterns(url) {
35
35
  if (!this.allowUrlPatterns) {
36
- return true;
36
+ return false;
37
37
  }
38
- return this.allowUrlPatterns.some((pattern) => new RegExp(pattern).test(url));
38
+ return !this.allowUrlPatterns.some((pattern) => !new RegExp(pattern).test(url));
39
39
  }
40
40
  async parseSitemap() {
41
41
  const $ = await CheerioWebBaseLoader._scrape(this.webPath, this.caller, this.timeout, this.textDecoder, {
@@ -48,7 +48,7 @@ export class SitemapLoader extends CheerioWebBaseLoader {
48
48
  if (!loc) {
49
49
  return;
50
50
  }
51
- if (!this._checkUrlPatterns(loc)) {
51
+ if (this._checkUrlPatterns(loc)) {
52
52
  return;
53
53
  }
54
54
  const changefreq = $(element).find("changefreq").text();
@@ -221,6 +221,8 @@ class OpenAIAssistantRunnable extends runnables_1.Runnable {
221
221
  return {
222
222
  returnValues: {
223
223
  output: answerString,
224
+ runId,
225
+ threadId,
224
226
  },
225
227
  log: "",
226
228
  runId,
@@ -218,6 +218,8 @@ export class OpenAIAssistantRunnable extends Runnable {
218
218
  return {
219
219
  returnValues: {
220
220
  output: answerString,
221
+ runId,
222
+ threadId,
221
223
  },
222
224
  log: "",
223
225
  runId,
@@ -68,7 +68,10 @@ class TextSplitter extends documents_1.BaseDocumentTransformer {
68
68
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
69
  metadatas = [], chunkHeaderOptions = {}) {
70
70
  // if no metadata is provided, we create an empty one for each text
71
- const _metadatas = metadatas.length > 0 ? metadatas : new Array(texts.length).fill({});
71
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
+ const _metadatas = metadatas.length > 0
73
+ ? metadatas
74
+ : [...Array(texts.length)].map(() => ({}));
72
75
  const { chunkHeader = "", chunkOverlapHeader = "(cont'd) ", appendChunkOverlapHeader = false, } = chunkHeaderOptions;
73
76
  const documents = new Array();
74
77
  for (let i = 0; i < texts.length; i += 1) {
@@ -65,7 +65,10 @@ export class TextSplitter extends BaseDocumentTransformer {
65
65
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
66
  metadatas = [], chunkHeaderOptions = {}) {
67
67
  // if no metadata is provided, we create an empty one for each text
68
- const _metadatas = metadatas.length > 0 ? metadatas : new Array(texts.length).fill({});
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ const _metadatas = metadatas.length > 0
70
+ ? metadatas
71
+ : [...Array(texts.length)].map(() => ({}));
69
72
  const { chunkHeader = "", chunkOverlapHeader = "(cont'd) ", appendChunkOverlapHeader = false, } = chunkHeaderOptions;
70
73
  const documents = new Array();
71
74
  for (let i = 0; i < texts.length; i += 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -1504,15 +1504,15 @@
1504
1504
  },
1505
1505
  "dependencies": {
1506
1506
  "@anthropic-ai/sdk": "^0.9.1",
1507
- "@langchain/community": "~0.0.20",
1508
- "@langchain/core": "~0.1.25",
1509
- "@langchain/openai": "~0.0.12",
1507
+ "@langchain/community": "~0.0.28",
1508
+ "@langchain/core": "~0.1.28",
1509
+ "@langchain/openai": "~0.0.14",
1510
1510
  "binary-extensions": "^2.2.0",
1511
1511
  "expr-eval": "^2.0.2",
1512
1512
  "js-tiktoken": "^1.0.7",
1513
1513
  "js-yaml": "^4.1.0",
1514
1514
  "jsonpointer": "^5.0.1",
1515
- "langchainhub": "~0.0.6",
1515
+ "langchainhub": "~0.0.8",
1516
1516
  "langsmith": "~0.0.59",
1517
1517
  "ml-distance": "^4.0.0",
1518
1518
  "openapi-types": "^12.1.3",