langchain 0.1.35 → 0.1.37

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.
Files changed (84) hide show
  1. package/dist/chains/conversational_retrieval_chain.cjs +61 -19
  2. package/dist/chains/conversational_retrieval_chain.d.ts +61 -19
  3. package/dist/chains/conversational_retrieval_chain.js +61 -19
  4. package/dist/chains/llm_chain.cjs +10 -5
  5. package/dist/chains/llm_chain.d.ts +10 -5
  6. package/dist/chains/llm_chain.js +10 -5
  7. package/dist/chains/openai_functions/base.cjs +2 -0
  8. package/dist/chains/openai_functions/base.d.ts +2 -0
  9. package/dist/chains/openai_functions/base.js +2 -0
  10. package/dist/chains/query_constructor/index.cjs +5 -8
  11. package/dist/chains/query_constructor/index.d.ts +5 -4
  12. package/dist/chains/query_constructor/index.js +3 -6
  13. package/dist/chains/query_constructor/ir.cjs +15 -139
  14. package/dist/chains/query_constructor/ir.d.ts +1 -138
  15. package/dist/chains/query_constructor/ir.js +1 -132
  16. package/dist/chains/query_constructor/prompt.cjs +2 -2
  17. package/dist/chains/query_constructor/prompt.d.ts +1 -1
  18. package/dist/chains/query_constructor/prompt.js +1 -1
  19. package/dist/chains/retrieval_qa.cjs +23 -14
  20. package/dist/chains/retrieval_qa.d.ts +23 -14
  21. package/dist/chains/retrieval_qa.js +23 -14
  22. package/dist/document_loaders/fs/unstructured.cjs +1 -1
  23. package/dist/document_loaders/fs/unstructured.js +1 -1
  24. package/dist/document_loaders/web/browserbase.cjs +87 -0
  25. package/dist/document_loaders/web/browserbase.d.ts +49 -0
  26. package/dist/document_loaders/web/browserbase.js +80 -0
  27. package/dist/document_loaders/web/firecrawl.cjs +88 -0
  28. package/dist/document_loaders/web/firecrawl.d.ts +48 -0
  29. package/dist/document_loaders/web/firecrawl.js +81 -0
  30. package/dist/document_loaders/web/s3.cjs +2 -2
  31. package/dist/document_loaders/web/s3.js +2 -2
  32. package/dist/load/import_constants.cjs +2 -0
  33. package/dist/load/import_constants.js +2 -0
  34. package/dist/output_parsers/expression.cjs +1 -1
  35. package/dist/output_parsers/expression.d.ts +1 -1
  36. package/dist/output_parsers/expression.js +1 -1
  37. package/dist/retrievers/self_query/base.cjs +3 -136
  38. package/dist/retrievers/self_query/base.d.ts +1 -69
  39. package/dist/retrievers/self_query/base.js +1 -134
  40. package/dist/retrievers/self_query/chroma.cjs +9 -10
  41. package/dist/retrievers/self_query/chroma.d.ts +1 -1
  42. package/dist/retrievers/self_query/chroma.js +1 -2
  43. package/dist/retrievers/self_query/functional.cjs +2 -195
  44. package/dist/retrievers/self_query/functional.d.ts +1 -87
  45. package/dist/retrievers/self_query/functional.js +1 -194
  46. package/dist/retrievers/self_query/index.cjs +9 -13
  47. package/dist/retrievers/self_query/index.d.ts +11 -8
  48. package/dist/retrievers/self_query/index.js +7 -11
  49. package/dist/retrievers/self_query/pinecone.cjs +9 -10
  50. package/dist/retrievers/self_query/pinecone.d.ts +1 -1
  51. package/dist/retrievers/self_query/pinecone.js +1 -2
  52. package/dist/retrievers/self_query/supabase.cjs +28 -30
  53. package/dist/retrievers/self_query/supabase.d.ts +1 -2
  54. package/dist/retrievers/self_query/supabase.js +1 -3
  55. package/dist/retrievers/self_query/supabase_utils.cjs +2 -2
  56. package/dist/retrievers/self_query/supabase_utils.d.ts +1 -1
  57. package/dist/retrievers/self_query/supabase_utils.js +1 -1
  58. package/dist/retrievers/self_query/vectara.cjs +15 -17
  59. package/dist/retrievers/self_query/vectara.d.ts +1 -2
  60. package/dist/retrievers/self_query/vectara.js +1 -3
  61. package/dist/retrievers/self_query/weaviate.cjs +19 -21
  62. package/dist/retrievers/self_query/weaviate.d.ts +1 -2
  63. package/dist/retrievers/self_query/weaviate.js +1 -3
  64. package/dist/smith/config.d.ts +4 -4
  65. package/dist/storage/in_memory.cjs +2 -81
  66. package/dist/storage/in_memory.d.ts +1 -49
  67. package/dist/storage/in_memory.js +1 -80
  68. package/dist/text_splitter.cjs +15 -727
  69. package/dist/text_splitter.d.ts +1 -77
  70. package/dist/text_splitter.js +1 -720
  71. package/dist/vectorstores/qdrant.cjs +2 -0
  72. package/dist/vectorstores/qdrant.js +2 -0
  73. package/document_loaders/web/browserbase.cjs +1 -0
  74. package/document_loaders/web/browserbase.d.cts +1 -0
  75. package/document_loaders/web/browserbase.d.ts +1 -0
  76. package/document_loaders/web/browserbase.js +1 -0
  77. package/document_loaders/web/firecrawl.cjs +1 -0
  78. package/document_loaders/web/firecrawl.d.cts +1 -0
  79. package/document_loaders/web/firecrawl.d.ts +1 -0
  80. package/document_loaders/web/firecrawl.js +1 -0
  81. package/package.json +40 -3
  82. package/dist/retrievers/self_query/utils.cjs +0 -94
  83. package/dist/retrievers/self_query/utils.d.ts +0 -29
  84. package/dist/retrievers/self_query/utils.js +0 -85
@@ -1,6 +1,4 @@
1
- import { Comparators, Operators, } from "../../chains/query_constructor/ir.js";
2
- import { BaseTranslator } from "./base.js";
3
- import { isFilterEmpty, isString, isInt, isFloat } from "./utils.js";
1
+ import { isFilterEmpty, isString, isInt, isFloat, BaseTranslator, Comparators, Operators, } from "@langchain/core/structured_query";
4
2
  /**
5
3
  * A class that translates or converts data into a format that can be used
6
4
  * with Weaviate, a vector search engine. It extends the `BaseTranslator`
@@ -16,10 +16,10 @@ export type EvaluatorInputFormatter = ({ rawInput, rawPrediction, rawReferenceOu
16
16
  rawReferenceOutput?: any;
17
17
  run: Run;
18
18
  }) => EvaluatorInputs;
19
- export type DynamicRunEvaluatorParams = {
20
- input: Record<string, unknown>;
21
- prediction?: Record<string, unknown>;
22
- reference?: Record<string, unknown>;
19
+ export type DynamicRunEvaluatorParams<Input extends Record<string, any> = Record<string, unknown>, Prediction extends Record<string, any> = Record<string, unknown>, Reference extends Record<string, any> = Record<string, unknown>> = {
20
+ input: Input;
21
+ prediction?: Prediction;
22
+ reference?: Reference;
23
23
  run: Run;
24
24
  example?: Example;
25
25
  };
@@ -1,84 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InMemoryStore = void 0;
4
- const stores_1 = require("@langchain/core/stores");
5
- /**
6
- * In-memory implementation of the BaseStore using a dictionary. Used for
7
- * storing key-value pairs in memory.
8
- * @example
9
- * ```typescript
10
- * const store = new InMemoryStore<BaseMessage>();
11
- * await store.mset(
12
- * Array.from({ length: 5 }).map((_, index) => [
13
- * `message:id:${index}`,
14
- * index % 2 === 0
15
- * ? new AIMessage("ai stuff...")
16
- * : new HumanMessage("human stuff..."),
17
- * ]),
18
- * );
19
- *
20
- * const retrievedMessages = await store.mget(["message:id:0", "message:id:1"]);
21
- * await store.mdelete(await store.yieldKeys("message:id:").toArray());
22
- * ```
23
- */
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- class InMemoryStore extends stores_1.BaseStore {
26
- constructor() {
27
- super(...arguments);
28
- Object.defineProperty(this, "lc_namespace", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: ["langchain", "storage"]
33
- });
34
- Object.defineProperty(this, "store", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: {}
39
- });
40
- }
41
- /**
42
- * Retrieves the values associated with the given keys from the store.
43
- * @param keys Keys to retrieve values for.
44
- * @returns Array of values associated with the given keys.
45
- */
46
- async mget(keys) {
47
- return keys.map((key) => this.store[key]);
48
- }
49
- /**
50
- * Sets the values for the given keys in the store.
51
- * @param keyValuePairs Array of key-value pairs to set in the store.
52
- * @returns Promise that resolves when all key-value pairs have been set.
53
- */
54
- async mset(keyValuePairs) {
55
- for (const [key, value] of keyValuePairs) {
56
- this.store[key] = value;
57
- }
58
- }
59
- /**
60
- * Deletes the given keys and their associated values from the store.
61
- * @param keys Keys to delete from the store.
62
- * @returns Promise that resolves when all keys have been deleted.
63
- */
64
- async mdelete(keys) {
65
- for (const key of keys) {
66
- delete this.store[key];
67
- }
68
- }
69
- /**
70
- * Asynchronous generator that yields keys from the store. If a prefix is
71
- * provided, it only yields keys that start with the prefix.
72
- * @param prefix Optional prefix to filter keys.
73
- * @returns AsyncGenerator that yields keys from the store.
74
- */
75
- async *yieldKeys(prefix) {
76
- const keys = Object.keys(this.store);
77
- for (const key of keys) {
78
- if (prefix === undefined || key.startsWith(prefix)) {
79
- yield key;
80
- }
81
- }
82
- }
83
- }
84
- exports.InMemoryStore = InMemoryStore;
4
+ var stores_1 = require("@langchain/core/stores");
5
+ Object.defineProperty(exports, "InMemoryStore", { enumerable: true, get: function () { return stores_1.InMemoryStore; } });
@@ -1,49 +1 @@
1
- import { BaseStore } from "@langchain/core/stores";
2
- /**
3
- * In-memory implementation of the BaseStore using a dictionary. Used for
4
- * storing key-value pairs in memory.
5
- * @example
6
- * ```typescript
7
- * const store = new InMemoryStore<BaseMessage>();
8
- * await store.mset(
9
- * Array.from({ length: 5 }).map((_, index) => [
10
- * `message:id:${index}`,
11
- * index % 2 === 0
12
- * ? new AIMessage("ai stuff...")
13
- * : new HumanMessage("human stuff..."),
14
- * ]),
15
- * );
16
- *
17
- * const retrievedMessages = await store.mget(["message:id:0", "message:id:1"]);
18
- * await store.mdelete(await store.yieldKeys("message:id:").toArray());
19
- * ```
20
- */
21
- export declare class InMemoryStore<T = any> extends BaseStore<string, T> {
22
- lc_namespace: string[];
23
- protected store: Record<string, T>;
24
- /**
25
- * Retrieves the values associated with the given keys from the store.
26
- * @param keys Keys to retrieve values for.
27
- * @returns Array of values associated with the given keys.
28
- */
29
- mget(keys: string[]): Promise<T[]>;
30
- /**
31
- * Sets the values for the given keys in the store.
32
- * @param keyValuePairs Array of key-value pairs to set in the store.
33
- * @returns Promise that resolves when all key-value pairs have been set.
34
- */
35
- mset(keyValuePairs: [string, T][]): Promise<void>;
36
- /**
37
- * Deletes the given keys and their associated values from the store.
38
- * @param keys Keys to delete from the store.
39
- * @returns Promise that resolves when all keys have been deleted.
40
- */
41
- mdelete(keys: string[]): Promise<void>;
42
- /**
43
- * Asynchronous generator that yields keys from the store. If a prefix is
44
- * provided, it only yields keys that start with the prefix.
45
- * @param prefix Optional prefix to filter keys.
46
- * @returns AsyncGenerator that yields keys from the store.
47
- */
48
- yieldKeys(prefix?: string | undefined): AsyncGenerator<string>;
49
- }
1
+ export { InMemoryStore } from "@langchain/core/stores";
@@ -1,80 +1 @@
1
- import { BaseStore } from "@langchain/core/stores";
2
- /**
3
- * In-memory implementation of the BaseStore using a dictionary. Used for
4
- * storing key-value pairs in memory.
5
- * @example
6
- * ```typescript
7
- * const store = new InMemoryStore<BaseMessage>();
8
- * await store.mset(
9
- * Array.from({ length: 5 }).map((_, index) => [
10
- * `message:id:${index}`,
11
- * index % 2 === 0
12
- * ? new AIMessage("ai stuff...")
13
- * : new HumanMessage("human stuff..."),
14
- * ]),
15
- * );
16
- *
17
- * const retrievedMessages = await store.mget(["message:id:0", "message:id:1"]);
18
- * await store.mdelete(await store.yieldKeys("message:id:").toArray());
19
- * ```
20
- */
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- export class InMemoryStore extends BaseStore {
23
- constructor() {
24
- super(...arguments);
25
- Object.defineProperty(this, "lc_namespace", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: ["langchain", "storage"]
30
- });
31
- Object.defineProperty(this, "store", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: {}
36
- });
37
- }
38
- /**
39
- * Retrieves the values associated with the given keys from the store.
40
- * @param keys Keys to retrieve values for.
41
- * @returns Array of values associated with the given keys.
42
- */
43
- async mget(keys) {
44
- return keys.map((key) => this.store[key]);
45
- }
46
- /**
47
- * Sets the values for the given keys in the store.
48
- * @param keyValuePairs Array of key-value pairs to set in the store.
49
- * @returns Promise that resolves when all key-value pairs have been set.
50
- */
51
- async mset(keyValuePairs) {
52
- for (const [key, value] of keyValuePairs) {
53
- this.store[key] = value;
54
- }
55
- }
56
- /**
57
- * Deletes the given keys and their associated values from the store.
58
- * @param keys Keys to delete from the store.
59
- * @returns Promise that resolves when all keys have been deleted.
60
- */
61
- async mdelete(keys) {
62
- for (const key of keys) {
63
- delete this.store[key];
64
- }
65
- }
66
- /**
67
- * Asynchronous generator that yields keys from the store. If a prefix is
68
- * provided, it only yields keys that start with the prefix.
69
- * @param prefix Optional prefix to filter keys.
70
- * @returns AsyncGenerator that yields keys from the store.
71
- */
72
- async *yieldKeys(prefix) {
73
- const keys = Object.keys(this.store);
74
- for (const key of keys) {
75
- if (prefix === undefined || key.startsWith(prefix)) {
76
- yield key;
77
- }
78
- }
79
- }
80
- }
1
+ export { InMemoryStore } from "@langchain/core/stores";