langchain 0.0.134 → 0.0.136
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/dist/agents/chat_convo/outputParser.cjs +13 -10
- package/dist/agents/chat_convo/outputParser.js +13 -10
- package/dist/callbacks/base.d.ts +6 -3
- package/dist/callbacks/handlers/tracer.cjs +2 -2
- package/dist/callbacks/handlers/tracer.d.ts +2 -2
- package/dist/callbacks/handlers/tracer.js +2 -2
- package/dist/callbacks/manager.cjs +2 -2
- package/dist/callbacks/manager.d.ts +2 -2
- package/dist/callbacks/manager.js +2 -2
- package/dist/chains/question_answering/map_reduce_prompts.d.ts +2 -2
- package/dist/chains/retrieval_qa.cjs +1 -1
- package/dist/chains/retrieval_qa.js +1 -1
- package/dist/chat_models/openai.cjs +10 -5
- package/dist/chat_models/openai.js +10 -5
- package/dist/llms/writer.cjs +167 -0
- package/dist/llms/writer.d.ts +60 -0
- package/dist/llms/writer.js +163 -0
- package/dist/load/import_constants.cjs +2 -0
- package/dist/load/import_constants.js +2 -0
- package/dist/load/import_map.cjs +2 -1
- package/dist/load/import_map.d.ts +1 -0
- package/dist/load/import_map.js +1 -0
- package/dist/memory/summary_buffer.d.ts +1 -1
- package/dist/output_parsers/prompts.d.ts +1 -1
- package/dist/prompts/prompt.cjs +3 -1
- package/dist/prompts/prompt.d.ts +12 -1
- package/dist/prompts/prompt.js +3 -1
- package/dist/retrievers/parent_document.cjs +8 -1
- package/dist/retrievers/parent_document.d.ts +2 -0
- package/dist/retrievers/parent_document.js +8 -1
- package/dist/retrievers/score_threshold.cjs +45 -0
- package/dist/retrievers/score_threshold.d.ts +15 -0
- package/dist/retrievers/score_threshold.js +41 -0
- package/dist/sql_db.cjs +8 -1
- package/dist/sql_db.d.ts +1 -0
- package/dist/sql_db.js +8 -1
- package/dist/stores/message/mongodb.cjs +48 -0
- package/dist/stores/message/mongodb.d.ts +15 -0
- package/dist/stores/message/mongodb.js +44 -0
- package/dist/tools/index.cjs +3 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +1 -0
- package/dist/tools/wolframalpha.cjs +40 -0
- package/dist/tools/wolframalpha.d.ts +12 -0
- package/dist/tools/wolframalpha.js +36 -0
- package/dist/util/sql_utils.cjs +8 -2
- package/dist/util/sql_utils.d.ts +2 -1
- package/dist/util/sql_utils.js +8 -2
- package/dist/vectorstores/chroma.cjs +8 -0
- package/dist/vectorstores/chroma.d.ts +4 -1
- package/dist/vectorstores/chroma.js +8 -0
- package/dist/vectorstores/redis.cjs +9 -1
- package/dist/vectorstores/redis.js +9 -1
- package/dist/vectorstores/vectara.cjs +1 -1
- package/dist/vectorstores/vectara.js +1 -1
- package/llms/writer.cjs +1 -0
- package/llms/writer.d.ts +1 -0
- package/llms/writer.js +1 -0
- package/package.json +30 -1
- package/retrievers/score_threshold.cjs +1 -0
- package/retrievers/score_threshold.d.ts +1 -0
- package/retrievers/score_threshold.js +1 -0
- package/stores/message/mongodb.cjs +1 -0
- package/stores/message/mongodb.d.ts +1 -0
- package/stores/message/mongodb.js +1 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ObjectId } from "mongodb";
|
|
2
|
+
import { BaseListChatMessageHistory } from "../../schema/index.js";
|
|
3
|
+
import { mapChatMessagesToStoredMessages, mapStoredMessagesToChatMessages, } from "./utils.js";
|
|
4
|
+
export class MongoDBChatMessageHistory extends BaseListChatMessageHistory {
|
|
5
|
+
constructor({ collection, sessionId }) {
|
|
6
|
+
super();
|
|
7
|
+
Object.defineProperty(this, "lc_namespace", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: ["langchain", "stores", "message", "mongodb"]
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "collection", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(this, "sessionId", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
this.collection = collection;
|
|
26
|
+
this.sessionId = sessionId;
|
|
27
|
+
}
|
|
28
|
+
async getMessages() {
|
|
29
|
+
const document = await this.collection.findOne({
|
|
30
|
+
_id: new ObjectId(this.sessionId),
|
|
31
|
+
});
|
|
32
|
+
const messages = document?.messages || [];
|
|
33
|
+
return mapStoredMessagesToChatMessages(messages);
|
|
34
|
+
}
|
|
35
|
+
async addMessage(message) {
|
|
36
|
+
const messages = mapChatMessagesToStoredMessages([message]);
|
|
37
|
+
await this.collection.updateOne({ _id: new ObjectId(this.sessionId) }, {
|
|
38
|
+
$push: { messages: { $each: messages } },
|
|
39
|
+
}, { upsert: true });
|
|
40
|
+
}
|
|
41
|
+
async clear() {
|
|
42
|
+
await this.collection.deleteOne({ _id: new ObjectId(this.sessionId) });
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/tools/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SearxngSearch = exports.DataForSeoAPISearch = exports.WikipediaQueryRun = exports.BraveSearch = exports.WriteFileTool = exports.ReadFileTool = exports.AIPluginTool = exports.GoogleCustomSearch = exports.Serper = exports.ZapierNLAWrapper = exports.ZapierNLARunAction = exports.VectorStoreQATool = exports.RequestsPostTool = exports.RequestsGetTool = exports.JsonGetValueTool = exports.JsonListKeysTool = exports.JsonSpec = exports.ChainTool = exports.IFTTTWebhook = exports.DynamicStructuredTool = exports.DynamicTool = exports.StructuredTool = exports.Tool = exports.BingSerpAPI = exports.DadJokeAPI = exports.SerpAPI = void 0;
|
|
3
|
+
exports.SearxngSearch = exports.DataForSeoAPISearch = exports.WolframAlphaTool = exports.WikipediaQueryRun = exports.BraveSearch = exports.WriteFileTool = exports.ReadFileTool = exports.AIPluginTool = exports.GoogleCustomSearch = exports.Serper = exports.ZapierNLAWrapper = exports.ZapierNLARunAction = exports.VectorStoreQATool = exports.RequestsPostTool = exports.RequestsGetTool = exports.JsonGetValueTool = exports.JsonListKeysTool = exports.JsonSpec = exports.ChainTool = exports.IFTTTWebhook = exports.DynamicStructuredTool = exports.DynamicTool = exports.StructuredTool = exports.Tool = exports.BingSerpAPI = exports.DadJokeAPI = exports.SerpAPI = void 0;
|
|
4
4
|
var serpapi_js_1 = require("./serpapi.cjs");
|
|
5
5
|
Object.defineProperty(exports, "SerpAPI", { enumerable: true, get: function () { return serpapi_js_1.SerpAPI; } });
|
|
6
6
|
var dadjokeapi_js_1 = require("./dadjokeapi.cjs");
|
|
@@ -42,6 +42,8 @@ var brave_search_js_1 = require("./brave_search.cjs");
|
|
|
42
42
|
Object.defineProperty(exports, "BraveSearch", { enumerable: true, get: function () { return brave_search_js_1.BraveSearch; } });
|
|
43
43
|
var wikipedia_query_run_js_1 = require("./wikipedia_query_run.cjs");
|
|
44
44
|
Object.defineProperty(exports, "WikipediaQueryRun", { enumerable: true, get: function () { return wikipedia_query_run_js_1.WikipediaQueryRun; } });
|
|
45
|
+
var wolframalpha_js_1 = require("./wolframalpha.cjs");
|
|
46
|
+
Object.defineProperty(exports, "WolframAlphaTool", { enumerable: true, get: function () { return wolframalpha_js_1.WolframAlphaTool; } });
|
|
45
47
|
var dataforseo_api_search_js_1 = require("./dataforseo_api_search.cjs");
|
|
46
48
|
Object.defineProperty(exports, "DataForSeoAPISearch", { enumerable: true, get: function () { return dataforseo_api_search_js_1.DataForSeoAPISearch; } });
|
|
47
49
|
var searxng_search_js_1 = require("./searxng_search.cjs");
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export { AIPluginTool } from "./aiplugin.js";
|
|
|
15
15
|
export { ReadFileTool, WriteFileTool } from "./fs.js";
|
|
16
16
|
export { BraveSearch, BraveSearchParams } from "./brave_search.js";
|
|
17
17
|
export { WikipediaQueryRun, WikipediaQueryRunParams, } from "./wikipedia_query_run.js";
|
|
18
|
+
export { WolframAlphaTool } from "./wolframalpha.js";
|
|
18
19
|
export { DataForSeoAPISearch, DataForSeoApiConfig, } from "./dataforseo_api_search.js";
|
|
19
20
|
export { SearxngSearch } from "./searxng_search.js";
|
package/dist/tools/index.js
CHANGED
|
@@ -15,5 +15,6 @@ export { AIPluginTool } from "./aiplugin.js";
|
|
|
15
15
|
export { ReadFileTool, WriteFileTool } from "./fs.js";
|
|
16
16
|
export { BraveSearch } from "./brave_search.js";
|
|
17
17
|
export { WikipediaQueryRun, } from "./wikipedia_query_run.js";
|
|
18
|
+
export { WolframAlphaTool } from "./wolframalpha.js";
|
|
18
19
|
export { DataForSeoAPISearch, } from "./dataforseo_api_search.js";
|
|
19
20
|
export { SearxngSearch } from "./searxng_search.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WolframAlphaTool = void 0;
|
|
4
|
+
const base_js_1 = require("./base.cjs");
|
|
5
|
+
class WolframAlphaTool extends base_js_1.Tool {
|
|
6
|
+
constructor(fields) {
|
|
7
|
+
super(fields);
|
|
8
|
+
Object.defineProperty(this, "appid", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "name", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: "wolfram_alpha"
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "description", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: `A wrapper around Wolfram Alpha. Useful for when you need to answer questions about Math, Science, Technology, Culture, Society and Everyday Life. Input should be a search query.`
|
|
25
|
+
});
|
|
26
|
+
this.appid = fields.appid;
|
|
27
|
+
}
|
|
28
|
+
get lc_namespace() {
|
|
29
|
+
return [...super.lc_namespace, "wolframalpha"];
|
|
30
|
+
}
|
|
31
|
+
static lc_name() {
|
|
32
|
+
return "WolframAlphaTool";
|
|
33
|
+
}
|
|
34
|
+
async _call(query) {
|
|
35
|
+
const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${query}`;
|
|
36
|
+
const res = await fetch(url);
|
|
37
|
+
return res.text();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.WolframAlphaTool = WolframAlphaTool;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tool, ToolParams } from "./base.js";
|
|
2
|
+
export declare class WolframAlphaTool extends Tool {
|
|
3
|
+
appid: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
constructor(fields: ToolParams & {
|
|
7
|
+
appid: string;
|
|
8
|
+
});
|
|
9
|
+
get lc_namespace(): string[];
|
|
10
|
+
static lc_name(): string;
|
|
11
|
+
_call(query: string): Promise<string>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Tool } from "./base.js";
|
|
2
|
+
export class WolframAlphaTool extends Tool {
|
|
3
|
+
constructor(fields) {
|
|
4
|
+
super(fields);
|
|
5
|
+
Object.defineProperty(this, "appid", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true,
|
|
9
|
+
value: void 0
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(this, "name", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: "wolfram_alpha"
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "description", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: `A wrapper around Wolfram Alpha. Useful for when you need to answer questions about Math, Science, Technology, Culture, Society and Everyday Life. Input should be a search query.`
|
|
22
|
+
});
|
|
23
|
+
this.appid = fields.appid;
|
|
24
|
+
}
|
|
25
|
+
get lc_namespace() {
|
|
26
|
+
return [...super.lc_namespace, "wolframalpha"];
|
|
27
|
+
}
|
|
28
|
+
static lc_name() {
|
|
29
|
+
return "WolframAlphaTool";
|
|
30
|
+
}
|
|
31
|
+
async _call(query) {
|
|
32
|
+
const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${query}`;
|
|
33
|
+
const res = await fetch(url);
|
|
34
|
+
return res.text();
|
|
35
|
+
}
|
|
36
|
+
}
|
package/dist/util/sql_utils.cjs
CHANGED
|
@@ -139,12 +139,17 @@ const formatSqlResponseToSimpleTableString = (rawResult) => {
|
|
|
139
139
|
}
|
|
140
140
|
return globalString;
|
|
141
141
|
};
|
|
142
|
-
const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow) => {
|
|
142
|
+
const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow, customDescription) => {
|
|
143
143
|
if (!tables) {
|
|
144
144
|
return "";
|
|
145
145
|
}
|
|
146
146
|
let globalString = "";
|
|
147
147
|
for (const currentTable of tables) {
|
|
148
|
+
// Add the custom info of the table
|
|
149
|
+
const tableCustomDescription = customDescription &&
|
|
150
|
+
Object.keys(customDescription).includes(currentTable.tableName)
|
|
151
|
+
? `${customDescription[currentTable.tableName]}\n`
|
|
152
|
+
: "";
|
|
148
153
|
// Add the creation of the table in SQL
|
|
149
154
|
let schema = null;
|
|
150
155
|
if (appDataSource.options.type === "postgres") {
|
|
@@ -199,7 +204,8 @@ const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow) =
|
|
|
199
204
|
// If the request fails we catch it and only display a log message
|
|
200
205
|
console.log(error);
|
|
201
206
|
}
|
|
202
|
-
globalString = globalString.concat(
|
|
207
|
+
globalString = globalString.concat(tableCustomDescription +
|
|
208
|
+
sqlCreateTableQuery +
|
|
203
209
|
sqlSelectInfoQuery +
|
|
204
210
|
columnNamesConcatString +
|
|
205
211
|
sample);
|
package/dist/util/sql_utils.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface SqlDatabaseParams {
|
|
|
4
4
|
includesTables?: Array<string>;
|
|
5
5
|
ignoreTables?: Array<string>;
|
|
6
6
|
sampleRowsInTableInfo?: number;
|
|
7
|
+
customDescription?: Record<string, string>;
|
|
7
8
|
}
|
|
8
9
|
export interface SqlDatabaseOptionsParams extends SqlDatabaseParams {
|
|
9
10
|
appDataSourceOptions: DataSourceOptions;
|
|
@@ -27,5 +28,5 @@ export declare const verifyListTablesExistInDatabase: (tablesFromDatabase: Array
|
|
|
27
28
|
export declare const verifyIncludeTablesExistInDatabase: (tablesFromDatabase: Array<SqlTable>, includeTables: Array<string>) => void;
|
|
28
29
|
export declare const verifyIgnoreTablesExistInDatabase: (tablesFromDatabase: Array<SqlTable>, ignoreTables: Array<string>) => void;
|
|
29
30
|
export declare const getTableAndColumnsName: (appDataSource: DataSource) => Promise<Array<SqlTable>>;
|
|
30
|
-
export declare const generateTableInfoFromTables: (tables: Array<SqlTable> | undefined, appDataSource: DataSource, nbSampleRow: number) => Promise<string>;
|
|
31
|
+
export declare const generateTableInfoFromTables: (tables: Array<SqlTable> | undefined, appDataSource: DataSource, nbSampleRow: number, customDescription?: Record<string, string>) => Promise<string>;
|
|
31
32
|
export declare const getPromptTemplateFromDataSource: (appDataSource: DataSource) => PromptTemplate;
|
package/dist/util/sql_utils.js
CHANGED
|
@@ -132,12 +132,17 @@ const formatSqlResponseToSimpleTableString = (rawResult) => {
|
|
|
132
132
|
}
|
|
133
133
|
return globalString;
|
|
134
134
|
};
|
|
135
|
-
export const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow) => {
|
|
135
|
+
export const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow, customDescription) => {
|
|
136
136
|
if (!tables) {
|
|
137
137
|
return "";
|
|
138
138
|
}
|
|
139
139
|
let globalString = "";
|
|
140
140
|
for (const currentTable of tables) {
|
|
141
|
+
// Add the custom info of the table
|
|
142
|
+
const tableCustomDescription = customDescription &&
|
|
143
|
+
Object.keys(customDescription).includes(currentTable.tableName)
|
|
144
|
+
? `${customDescription[currentTable.tableName]}\n`
|
|
145
|
+
: "";
|
|
141
146
|
// Add the creation of the table in SQL
|
|
142
147
|
let schema = null;
|
|
143
148
|
if (appDataSource.options.type === "postgres") {
|
|
@@ -192,7 +197,8 @@ export const generateTableInfoFromTables = async (tables, appDataSource, nbSampl
|
|
|
192
197
|
// If the request fails we catch it and only display a log message
|
|
193
198
|
console.log(error);
|
|
194
199
|
}
|
|
195
|
-
globalString = globalString.concat(
|
|
200
|
+
globalString = globalString.concat(tableCustomDescription +
|
|
201
|
+
sqlCreateTableQuery +
|
|
196
202
|
sqlSelectInfoQuery +
|
|
197
203
|
columnNamesConcatString +
|
|
198
204
|
sample);
|
|
@@ -56,6 +56,12 @@ class Chroma extends base_js_1.VectorStore {
|
|
|
56
56
|
writable: true,
|
|
57
57
|
value: void 0
|
|
58
58
|
});
|
|
59
|
+
Object.defineProperty(this, "collectionMetadata", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
value: void 0
|
|
64
|
+
});
|
|
59
65
|
Object.defineProperty(this, "numDimensions", {
|
|
60
66
|
enumerable: true,
|
|
61
67
|
configurable: true,
|
|
@@ -77,6 +83,7 @@ class Chroma extends base_js_1.VectorStore {
|
|
|
77
83
|
this.numDimensions = args.numDimensions;
|
|
78
84
|
this.embeddings = embeddings;
|
|
79
85
|
this.collectionName = ensureCollectionName(args.collectionName);
|
|
86
|
+
this.collectionMetadata = args.collectionMetadata;
|
|
80
87
|
if ("index" in args) {
|
|
81
88
|
this.index = args.index;
|
|
82
89
|
}
|
|
@@ -111,6 +118,7 @@ class Chroma extends base_js_1.VectorStore {
|
|
|
111
118
|
try {
|
|
112
119
|
this.collection = await this.index.getOrCreateCollection({
|
|
113
120
|
name: this.collectionName,
|
|
121
|
+
...(this.collectionMetadata && { metadata: this.collectionMetadata }),
|
|
114
122
|
});
|
|
115
123
|
}
|
|
116
124
|
catch (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChromaClient as ChromaClientT, Collection } from "chromadb";
|
|
2
|
-
import type { Where } from "chromadb/dist/main/types.js";
|
|
2
|
+
import type { CollectionMetadata, Where } from "chromadb/dist/main/types.js";
|
|
3
3
|
import { Embeddings } from "../embeddings/base.js";
|
|
4
4
|
import { VectorStore } from "./base.js";
|
|
5
5
|
import { Document } from "../document.js";
|
|
@@ -17,11 +17,13 @@ export type ChromaLibArgs = {
|
|
|
17
17
|
numDimensions?: number;
|
|
18
18
|
collectionName?: string;
|
|
19
19
|
filter?: object;
|
|
20
|
+
collectionMetadata?: CollectionMetadata;
|
|
20
21
|
} | {
|
|
21
22
|
index?: ChromaClientT;
|
|
22
23
|
numDimensions?: number;
|
|
23
24
|
collectionName?: string;
|
|
24
25
|
filter?: object;
|
|
26
|
+
collectionMetadata?: CollectionMetadata;
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
29
|
* Defines the parameters for the `delete` method in the `Chroma` class.
|
|
@@ -42,6 +44,7 @@ export declare class Chroma extends VectorStore {
|
|
|
42
44
|
index?: ChromaClientT;
|
|
43
45
|
collection?: Collection;
|
|
44
46
|
collectionName: string;
|
|
47
|
+
collectionMetadata?: CollectionMetadata;
|
|
45
48
|
numDimensions?: number;
|
|
46
49
|
url: string;
|
|
47
50
|
filter?: object;
|
|
@@ -30,6 +30,12 @@ export class Chroma extends VectorStore {
|
|
|
30
30
|
writable: true,
|
|
31
31
|
value: void 0
|
|
32
32
|
});
|
|
33
|
+
Object.defineProperty(this, "collectionMetadata", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: void 0
|
|
38
|
+
});
|
|
33
39
|
Object.defineProperty(this, "numDimensions", {
|
|
34
40
|
enumerable: true,
|
|
35
41
|
configurable: true,
|
|
@@ -51,6 +57,7 @@ export class Chroma extends VectorStore {
|
|
|
51
57
|
this.numDimensions = args.numDimensions;
|
|
52
58
|
this.embeddings = embeddings;
|
|
53
59
|
this.collectionName = ensureCollectionName(args.collectionName);
|
|
60
|
+
this.collectionMetadata = args.collectionMetadata;
|
|
54
61
|
if ("index" in args) {
|
|
55
62
|
this.index = args.index;
|
|
56
63
|
}
|
|
@@ -85,6 +92,7 @@ export class Chroma extends VectorStore {
|
|
|
85
92
|
try {
|
|
86
93
|
this.collection = await this.index.getOrCreateCollection({
|
|
87
94
|
name: this.collectionName,
|
|
95
|
+
...(this.collectionMetadata && { metadata: this.collectionMetadata }),
|
|
88
96
|
});
|
|
89
97
|
}
|
|
90
98
|
catch (err) {
|
|
@@ -99,9 +99,13 @@ class RedisVectorStore extends base_js_1.VectorStore {
|
|
|
99
99
|
async addVectors(vectors, documents, { keys, batchSize = 1000 } = {}) {
|
|
100
100
|
// check if the index exists and create it if it doesn't
|
|
101
101
|
await this.createIndex(vectors[0].length);
|
|
102
|
+
const info = await this.redisClient.ft.info(this.indexName);
|
|
103
|
+
const lastKeyCount = parseInt(info.numDocs, 10) || 0;
|
|
102
104
|
const multi = this.redisClient.multi();
|
|
103
105
|
vectors.map(async (vector, idx) => {
|
|
104
|
-
const key = keys && keys.length
|
|
106
|
+
const key = keys && keys.length
|
|
107
|
+
? keys[idx]
|
|
108
|
+
: `${this.keyPrefix}${idx + lastKeyCount}`;
|
|
105
109
|
const metadata = documents[idx] && documents[idx].metadata
|
|
106
110
|
? documents[idx].metadata
|
|
107
111
|
: {};
|
|
@@ -195,6 +199,10 @@ class RedisVectorStore extends base_js_1.VectorStore {
|
|
|
195
199
|
await this.redisClient.ft.info(this.indexName);
|
|
196
200
|
}
|
|
197
201
|
catch (err) {
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
203
|
+
if (err?.message.includes("unknown command")) {
|
|
204
|
+
throw new Error("Failed to run FT.INFO command. Please ensure that you are running a RediSearch-capable Redis instance: https://js.langchain.com/docs/modules/data_connection/vectorstores/integrations/redis#setup");
|
|
205
|
+
}
|
|
198
206
|
// index doesn't exist
|
|
199
207
|
return false;
|
|
200
208
|
}
|
|
@@ -96,9 +96,13 @@ export class RedisVectorStore extends VectorStore {
|
|
|
96
96
|
async addVectors(vectors, documents, { keys, batchSize = 1000 } = {}) {
|
|
97
97
|
// check if the index exists and create it if it doesn't
|
|
98
98
|
await this.createIndex(vectors[0].length);
|
|
99
|
+
const info = await this.redisClient.ft.info(this.indexName);
|
|
100
|
+
const lastKeyCount = parseInt(info.numDocs, 10) || 0;
|
|
99
101
|
const multi = this.redisClient.multi();
|
|
100
102
|
vectors.map(async (vector, idx) => {
|
|
101
|
-
const key = keys && keys.length
|
|
103
|
+
const key = keys && keys.length
|
|
104
|
+
? keys[idx]
|
|
105
|
+
: `${this.keyPrefix}${idx + lastKeyCount}`;
|
|
102
106
|
const metadata = documents[idx] && documents[idx].metadata
|
|
103
107
|
? documents[idx].metadata
|
|
104
108
|
: {};
|
|
@@ -192,6 +196,10 @@ export class RedisVectorStore extends VectorStore {
|
|
|
192
196
|
await this.redisClient.ft.info(this.indexName);
|
|
193
197
|
}
|
|
194
198
|
catch (err) {
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
|
+
if (err?.message.includes("unknown command")) {
|
|
201
|
+
throw new Error("Failed to run FT.INFO command. Please ensure that you are running a RediSearch-capable Redis instance: https://js.langchain.com/docs/modules/data_connection/vectorstores/integrations/redis#setup");
|
|
202
|
+
}
|
|
195
203
|
// index doesn't exist
|
|
196
204
|
return false;
|
|
197
205
|
}
|
|
@@ -260,7 +260,7 @@ class VectaraStore extends base_js_1.VectorStore {
|
|
|
260
260
|
documentMetadata.forEach((item) => {
|
|
261
261
|
combinedMetadata[item.name] = item.value;
|
|
262
262
|
});
|
|
263
|
-
responses[i].metadata =
|
|
263
|
+
responses[i].metadata = combinedMetadata;
|
|
264
264
|
}
|
|
265
265
|
const documentsAndScores = responses.map((response) => [
|
|
266
266
|
new document_js_1.Document({
|
|
@@ -257,7 +257,7 @@ export class VectaraStore extends VectorStore {
|
|
|
257
257
|
documentMetadata.forEach((item) => {
|
|
258
258
|
combinedMetadata[item.name] = item.value;
|
|
259
259
|
});
|
|
260
|
-
responses[i].metadata =
|
|
260
|
+
responses[i].metadata = combinedMetadata;
|
|
261
261
|
}
|
|
262
262
|
const documentsAndScores = responses.map((response) => [
|
|
263
263
|
new Document({
|
package/llms/writer.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/llms/writer.cjs');
|
package/llms/writer.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/llms/writer.js'
|
package/llms/writer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/llms/writer.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.136",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -145,6 +145,9 @@
|
|
|
145
145
|
"llms/bedrock.cjs",
|
|
146
146
|
"llms/bedrock.js",
|
|
147
147
|
"llms/bedrock.d.ts",
|
|
148
|
+
"llms/writer.cjs",
|
|
149
|
+
"llms/writer.js",
|
|
150
|
+
"llms/writer.d.ts",
|
|
148
151
|
"prompts.cjs",
|
|
149
152
|
"prompts.js",
|
|
150
153
|
"prompts.d.ts",
|
|
@@ -457,6 +460,9 @@
|
|
|
457
460
|
"retrievers/hyde.cjs",
|
|
458
461
|
"retrievers/hyde.js",
|
|
459
462
|
"retrievers/hyde.d.ts",
|
|
463
|
+
"retrievers/score_threshold.cjs",
|
|
464
|
+
"retrievers/score_threshold.js",
|
|
465
|
+
"retrievers/score_threshold.d.ts",
|
|
460
466
|
"retrievers/self_query.cjs",
|
|
461
467
|
"retrievers/self_query.js",
|
|
462
468
|
"retrievers/self_query.d.ts",
|
|
@@ -517,6 +523,9 @@
|
|
|
517
523
|
"stores/message/momento.cjs",
|
|
518
524
|
"stores/message/momento.js",
|
|
519
525
|
"stores/message/momento.d.ts",
|
|
526
|
+
"stores/message/mongodb.cjs",
|
|
527
|
+
"stores/message/mongodb.js",
|
|
528
|
+
"stores/message/mongodb.d.ts",
|
|
520
529
|
"stores/message/redis.cjs",
|
|
521
530
|
"stores/message/redis.js",
|
|
522
531
|
"stores/message/redis.d.ts",
|
|
@@ -645,6 +654,7 @@
|
|
|
645
654
|
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
|
646
655
|
"@typescript-eslint/parser": "^5.58.0",
|
|
647
656
|
"@upstash/redis": "^1.20.6",
|
|
657
|
+
"@writerai/writer-sdk": "^0.40.2",
|
|
648
658
|
"@xata.io/client": "^0.25.1",
|
|
649
659
|
"@zilliz/milvus2-sdk-node": ">=2.2.11",
|
|
650
660
|
"apify-client": "^2.7.1",
|
|
@@ -740,6 +750,7 @@
|
|
|
740
750
|
"@tensorflow/tfjs-core": "*",
|
|
741
751
|
"@tigrisdata/vector": "^1.1.0",
|
|
742
752
|
"@upstash/redis": "^1.20.6",
|
|
753
|
+
"@writerai/writer-sdk": "^0.40.2",
|
|
743
754
|
"@xata.io/client": "^0.25.1",
|
|
744
755
|
"@zilliz/milvus2-sdk-node": ">=2.2.7",
|
|
745
756
|
"apify-client": "^2.7.1",
|
|
@@ -887,6 +898,9 @@
|
|
|
887
898
|
"@upstash/redis": {
|
|
888
899
|
"optional": true
|
|
889
900
|
},
|
|
901
|
+
"@writerai/writer-sdk": {
|
|
902
|
+
"optional": true
|
|
903
|
+
},
|
|
890
904
|
"@xata.io/client": {
|
|
891
905
|
"optional": true
|
|
892
906
|
},
|
|
@@ -1283,6 +1297,11 @@
|
|
|
1283
1297
|
"import": "./llms/bedrock.js",
|
|
1284
1298
|
"require": "./llms/bedrock.cjs"
|
|
1285
1299
|
},
|
|
1300
|
+
"./llms/writer": {
|
|
1301
|
+
"types": "./llms/writer.d.ts",
|
|
1302
|
+
"import": "./llms/writer.js",
|
|
1303
|
+
"require": "./llms/writer.cjs"
|
|
1304
|
+
},
|
|
1286
1305
|
"./prompts": {
|
|
1287
1306
|
"types": "./prompts.d.ts",
|
|
1288
1307
|
"import": "./prompts.js",
|
|
@@ -1811,6 +1830,11 @@
|
|
|
1811
1830
|
"import": "./retrievers/hyde.js",
|
|
1812
1831
|
"require": "./retrievers/hyde.cjs"
|
|
1813
1832
|
},
|
|
1833
|
+
"./retrievers/score_threshold": {
|
|
1834
|
+
"types": "./retrievers/score_threshold.d.ts",
|
|
1835
|
+
"import": "./retrievers/score_threshold.js",
|
|
1836
|
+
"require": "./retrievers/score_threshold.cjs"
|
|
1837
|
+
},
|
|
1814
1838
|
"./retrievers/self_query": {
|
|
1815
1839
|
"types": "./retrievers/self_query.d.ts",
|
|
1816
1840
|
"import": "./retrievers/self_query.js",
|
|
@@ -1911,6 +1935,11 @@
|
|
|
1911
1935
|
"import": "./stores/message/momento.js",
|
|
1912
1936
|
"require": "./stores/message/momento.cjs"
|
|
1913
1937
|
},
|
|
1938
|
+
"./stores/message/mongodb": {
|
|
1939
|
+
"types": "./stores/message/mongodb.d.ts",
|
|
1940
|
+
"import": "./stores/message/mongodb.js",
|
|
1941
|
+
"require": "./stores/message/mongodb.cjs"
|
|
1942
|
+
},
|
|
1914
1943
|
"./stores/message/redis": {
|
|
1915
1944
|
"types": "./stores/message/redis.d.ts",
|
|
1916
1945
|
"import": "./stores/message/redis.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/retrievers/score_threshold.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/retrievers/score_threshold.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/retrievers/score_threshold.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/stores/message/mongodb.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/stores/message/mongodb.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/stores/message/mongodb.js'
|