langchain 0.0.168 → 0.0.170
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 +2 -2
- package/agents/format_scratchpad.cjs +1 -0
- package/agents/format_scratchpad.d.ts +1 -0
- package/agents/format_scratchpad.js +1 -0
- package/chat_models/yandex.cjs +1 -0
- package/chat_models/yandex.d.ts +1 -0
- package/chat_models/yandex.js +1 -0
- package/dist/agents/agent.cjs +49 -1
- package/dist/agents/agent.d.ts +19 -1
- package/dist/agents/agent.js +47 -0
- package/dist/agents/executor.cjs +10 -1
- package/dist/agents/executor.d.ts +22 -8
- package/dist/agents/executor.js +11 -2
- package/dist/agents/format_scratchpad.cjs +25 -0
- package/dist/agents/format_scratchpad.d.ts +10 -0
- package/dist/agents/format_scratchpad.js +21 -0
- package/dist/agents/toolkits/aws_sfn.d.ts +4 -1
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.ts +1 -1
- package/dist/agents/toolkits/json/json.d.ts +4 -1
- package/dist/agents/toolkits/openapi/openapi.cjs +8 -0
- package/dist/agents/toolkits/openapi/openapi.d.ts +12 -1
- package/dist/agents/toolkits/openapi/openapi.js +8 -0
- package/dist/agents/toolkits/sql/sql.d.ts +4 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +8 -2
- package/dist/agents/types.d.ts +13 -1
- package/dist/callbacks/handlers/llmonitor.cjs +21 -17
- package/dist/callbacks/handlers/llmonitor.js +21 -17
- package/dist/chains/sql_db/sql_db_chain.cjs +9 -0
- package/dist/chains/sql_db/sql_db_chain.d.ts +9 -0
- package/dist/chains/sql_db/sql_db_chain.js +9 -0
- package/dist/chat_models/baiduwenxin.cjs +12 -1
- package/dist/chat_models/baiduwenxin.d.ts +3 -1
- package/dist/chat_models/baiduwenxin.js +12 -1
- package/dist/chat_models/cloudflare_workersai.cjs +7 -2
- package/dist/chat_models/cloudflare_workersai.d.ts +1 -1
- package/dist/chat_models/cloudflare_workersai.js +7 -2
- package/dist/chat_models/yandex.cjs +117 -0
- package/dist/chat_models/yandex.d.ts +16 -0
- package/dist/chat_models/yandex.js +113 -0
- package/dist/document_loaders/web/assemblyai.cjs +63 -114
- package/dist/document_loaders/web/assemblyai.d.ts +38 -57
- package/dist/document_loaders/web/assemblyai.js +63 -100
- package/dist/evaluation/comparison/prompt.d.ts +2 -2
- package/dist/experimental/chains/violation_of_expectations/index.cjs +5 -0
- package/dist/experimental/chains/violation_of_expectations/index.d.ts +1 -0
- package/dist/experimental/chains/violation_of_expectations/index.js +1 -0
- package/dist/experimental/chains/violation_of_expectations/types.cjs +49 -0
- package/dist/experimental/chains/violation_of_expectations/types.d.ts +69 -0
- package/dist/experimental/chains/violation_of_expectations/types.js +46 -0
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.cjs +328 -0
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.d.ts +148 -0
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.js +324 -0
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.cjs +49 -0
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.d.ts +5 -0
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.js +46 -0
- package/dist/llms/cloudflare_workersai.cjs +14 -7
- package/dist/llms/cloudflare_workersai.d.ts +1 -1
- package/dist/llms/cloudflare_workersai.js +14 -7
- package/dist/load/import_constants.cjs +1 -0
- package/dist/load/import_constants.js +1 -0
- package/dist/load/import_map.cjs +5 -2
- package/dist/load/import_map.d.ts +3 -0
- package/dist/load/import_map.js +3 -0
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/retrievers/time_weighted.cjs +1 -1
- package/dist/retrievers/time_weighted.d.ts +1 -1
- package/dist/retrievers/time_weighted.js +1 -1
- package/dist/retrievers/zep.cjs +29 -3
- package/dist/retrievers/zep.d.ts +14 -0
- package/dist/retrievers/zep.js +29 -3
- package/dist/schema/runnable/base.cjs +4 -1
- package/dist/schema/runnable/base.d.ts +1 -0
- package/dist/schema/runnable/base.js +4 -1
- package/dist/schema/runnable/passthrough.cjs +33 -1
- package/dist/schema/runnable/passthrough.d.ts +11 -1
- package/dist/schema/runnable/passthrough.js +32 -1
- package/dist/sql_db.cjs +12 -0
- package/dist/sql_db.d.ts +12 -0
- package/dist/sql_db.js +12 -0
- package/dist/storage/ioredis.cjs +2 -1
- package/dist/storage/ioredis.js +2 -1
- package/dist/storage/upstash_redis.cjs +155 -0
- package/dist/storage/upstash_redis.d.ts +59 -0
- package/dist/storage/upstash_redis.js +151 -0
- package/dist/storage/vercel_kv.cjs +2 -1
- package/dist/storage/vercel_kv.js +2 -1
- package/dist/types/assemblyai-types.cjs +0 -150
- package/dist/types/assemblyai-types.d.ts +4 -670
- package/dist/types/assemblyai-types.js +1 -149
- package/dist/vectorstores/faiss.cjs +38 -6
- package/dist/vectorstores/faiss.d.ts +14 -2
- package/dist/vectorstores/faiss.js +38 -6
- package/dist/vectorstores/pgvector.cjs +1 -1
- package/dist/vectorstores/pgvector.js +1 -1
- package/dist/vectorstores/weaviate.cjs +13 -2
- package/dist/vectorstores/weaviate.js +13 -2
- package/experimental/chains/violation_of_expectations.cjs +1 -0
- package/experimental/chains/violation_of_expectations.d.ts +1 -0
- package/experimental/chains/violation_of_expectations.js +1 -0
- package/package.json +47 -10
- package/storage/upstash_redis.cjs +1 -0
- package/storage/upstash_redis.d.ts +1 -0
- package/storage/upstash_redis.js +1 -0
- package/dist/util/assemblyai-client.cjs +0 -173
- package/dist/util/assemblyai-client.d.ts +0 -63
- package/dist/util/assemblyai-client.js +0 -170
|
@@ -1,149 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The list of PII Redaction policies to enable.
|
|
3
|
-
* See [PII redaction]{@link https://www.assemblyai.com/docs/Models/pii_redaction} for more details.
|
|
4
|
-
*/
|
|
5
|
-
export const PiiPolicy = {
|
|
6
|
-
/**
|
|
7
|
-
* Medical process, including treatments, procedures, and tests (e.g., heart surgery, CT scan)
|
|
8
|
-
*/
|
|
9
|
-
MedicalProcess: "medical_process",
|
|
10
|
-
/**
|
|
11
|
-
* Name of a medical condition, disease, syndrome, deficit, or disorder (e.g., chronic fatigue syndrome, arrhythmia, depression)
|
|
12
|
-
*/
|
|
13
|
-
MedicalCondition: "medical_condition",
|
|
14
|
-
/**
|
|
15
|
-
* Blood type (e.g., O-, AB positive)
|
|
16
|
-
*/
|
|
17
|
-
BloodType: "blood_type",
|
|
18
|
-
/**
|
|
19
|
-
* Medications, vitamins, or supplements (e.g., Advil, Acetaminophen, Panadol)
|
|
20
|
-
*/
|
|
21
|
-
Drug: "drug",
|
|
22
|
-
/**
|
|
23
|
-
* Bodily injury (e.g., I broke my arm, I have a sprained wrist)
|
|
24
|
-
*/
|
|
25
|
-
Injury: "injury",
|
|
26
|
-
/**
|
|
27
|
-
* A "lazy" rule that will redact any sequence of numbers equal to or greater than 2
|
|
28
|
-
*/
|
|
29
|
-
NumberSequence: "number_sequence",
|
|
30
|
-
/**
|
|
31
|
-
* Email address (e.g., support@assemblyai.com)
|
|
32
|
-
*/
|
|
33
|
-
EmailAddress: "email_address",
|
|
34
|
-
/**
|
|
35
|
-
* Date of Birth (e.g., Date of Birth: March 7,1961)
|
|
36
|
-
*/
|
|
37
|
-
DateOfBirth: "date_of_birth",
|
|
38
|
-
/**
|
|
39
|
-
* Telephone or fax number
|
|
40
|
-
*/
|
|
41
|
-
PhoneNumber: "phone_number",
|
|
42
|
-
/**
|
|
43
|
-
* Social Security Number or equivalent
|
|
44
|
-
*/
|
|
45
|
-
UsSocialSecurityNumber: "us_social_security_number",
|
|
46
|
-
/**
|
|
47
|
-
* Credit card number
|
|
48
|
-
*/
|
|
49
|
-
CreditCardNumber: "credit_card_number",
|
|
50
|
-
/**
|
|
51
|
-
* Expiration date of a credit card
|
|
52
|
-
*/
|
|
53
|
-
CreditCardExpiration: "credit_card_expiration",
|
|
54
|
-
/**
|
|
55
|
-
* Credit card verification code (e.g., CVV: 080)
|
|
56
|
-
*/
|
|
57
|
-
CreditCardCvv: "credit_card_cvv",
|
|
58
|
-
/**
|
|
59
|
-
* Specific calendar date (e.g., December 18)
|
|
60
|
-
*/
|
|
61
|
-
Date: "date",
|
|
62
|
-
/**
|
|
63
|
-
* Terms indicating nationality, ethnicity, or race (e.g., American, Asian, Caucasian)
|
|
64
|
-
*/
|
|
65
|
-
Nationality: "nationality",
|
|
66
|
-
/**
|
|
67
|
-
* Name of an event or holiday (e.g., Olympics, Yom Kippur)
|
|
68
|
-
*/
|
|
69
|
-
Event: "event",
|
|
70
|
-
/**
|
|
71
|
-
* Name of a natural language (e.g., Spanish, French)
|
|
72
|
-
*/
|
|
73
|
-
Language: "language",
|
|
74
|
-
/**
|
|
75
|
-
* Any Location reference including mailing address, postal code, city, state, province, or country
|
|
76
|
-
*/
|
|
77
|
-
Location: "location",
|
|
78
|
-
/**
|
|
79
|
-
* Name and/or amount of currency (e.g., 15 pesos, $94.50)
|
|
80
|
-
*/
|
|
81
|
-
MoneyAmount: "money_amount",
|
|
82
|
-
/**
|
|
83
|
-
* Name of a person (e.g., Bob, Doug Jones)
|
|
84
|
-
*/
|
|
85
|
-
PersonName: "person_name",
|
|
86
|
-
/**
|
|
87
|
-
* Number associated with an age (e.g., 27, 75)
|
|
88
|
-
*/
|
|
89
|
-
PersonAge: "person_age",
|
|
90
|
-
/**
|
|
91
|
-
* Name of an organization (e.g., CNN, McDonalds, University of Alaska)
|
|
92
|
-
*/
|
|
93
|
-
Organization: "organization",
|
|
94
|
-
/**
|
|
95
|
-
* Terms referring to a political party, movement, or ideology (e.g., Republican, Liberal)
|
|
96
|
-
*/
|
|
97
|
-
PoliticalAffiliation: "political_affiliation",
|
|
98
|
-
/**
|
|
99
|
-
* Job title or profession (e.g., professor, actors, engineer, CPA)
|
|
100
|
-
*/
|
|
101
|
-
Occupation: "occupation",
|
|
102
|
-
/**
|
|
103
|
-
* Terms indicating religious affiliation (e.g., Hindu, Catholic)
|
|
104
|
-
*/
|
|
105
|
-
Religion: "religion",
|
|
106
|
-
/**
|
|
107
|
-
* Driver’s license number (e.g., DL# 356933-540)
|
|
108
|
-
*/
|
|
109
|
-
DriversLicense: "drivers_license",
|
|
110
|
-
/**
|
|
111
|
-
* Banking information, including account and routing numbers
|
|
112
|
-
*/
|
|
113
|
-
BankingInformation: "banking_information",
|
|
114
|
-
};
|
|
115
|
-
export const EntityType = {
|
|
116
|
-
BloodType: "Blood type (e.g., O-, AB positive)",
|
|
117
|
-
CreditCardCvv: "Credit card verification code (e.g., CVV: 080)",
|
|
118
|
-
CreditCardExpiration: "Expiration date of a credit card",
|
|
119
|
-
CreditCardNumber: "Credit card number",
|
|
120
|
-
Date: "Specific calendar date (e.g., December 18)",
|
|
121
|
-
DateOfBirth: "Date of Birth (e.g., Date of Birth: March 7, 1961)",
|
|
122
|
-
Drug: "Medications, vitamins, or supplements (e.g., Advil, Acetaminophen, Panadol)",
|
|
123
|
-
Event: "Name of an event or holiday (e.g., Olympics, Yom Kippur)",
|
|
124
|
-
EmailAddress: "Email address (e.g., support@assemblyai.com)",
|
|
125
|
-
Injury: "Bodily injury (e.g., I broke my arm, I have a sprained wrist)",
|
|
126
|
-
Language: "Name of a natural language (e.g., Spanish, French)",
|
|
127
|
-
Location: "Any location reference including mailing address, postal code, city, state, province, or country",
|
|
128
|
-
MedicalCondition: "Name of a medical condition, disease, syndrome, deficit, or disorder (e.g., chronic fatigue syndrome, arrhythmia, depression)",
|
|
129
|
-
MedicalProcess: "Medical process, including treatments, procedures, and tests (e.g., heart surgery, CT scan)",
|
|
130
|
-
MoneyAmount: "Name and/or amount of currency (e.g., 15 pesos, $94.50)",
|
|
131
|
-
Nationality: "Terms indicating nationality, ethnicity, or race (e.g., American, Asian, Caucasian)",
|
|
132
|
-
Occupation: "Job title or profession (e.g., professor, actors, engineer, CPA)",
|
|
133
|
-
Organization: "Name of an organization (e.g., CNN, McDonalds, University of Alaska)",
|
|
134
|
-
PersonAge: "Number associated with an age (e.g., 27, 75)",
|
|
135
|
-
PersonName: "Name of a person (e.g., Bob, Doug Jones)",
|
|
136
|
-
PhoneNumber: "Telephone or fax number",
|
|
137
|
-
PoliticalAffiliation: "Terms referring to a political party, movement, or ideology (e.g., Republican, Liberal)",
|
|
138
|
-
Religion: "Terms indicating religious affiliation (e.g., Hindu, Catholic)",
|
|
139
|
-
UsSocialSecurityNumber: "Social Security Number or equivalent",
|
|
140
|
-
DriversLicense: "Driver's license number (e.g., DL #356933-540)",
|
|
141
|
-
BankingInformation: "Banking information, including account and routing numbers",
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* The format of the subtitles.
|
|
145
|
-
*/
|
|
146
|
-
export const SubtitleFormat = {
|
|
147
|
-
Srt: "srt",
|
|
148
|
-
Vtt: "vtt",
|
|
149
|
-
};
|
|
1
|
+
export {};
|
|
@@ -80,9 +80,9 @@ class FaissStore extends base_js_1.SaveableVectorStore {
|
|
|
80
80
|
* @param documents An array of Document objects.
|
|
81
81
|
* @returns A Promise that resolves when the documents have been added.
|
|
82
82
|
*/
|
|
83
|
-
async addDocuments(documents) {
|
|
83
|
+
async addDocuments(documents, options) {
|
|
84
84
|
const texts = documents.map(({ pageContent }) => pageContent);
|
|
85
|
-
return this.addVectors(await this.embeddings.embedDocuments(texts), documents);
|
|
85
|
+
return this.addVectors(await this.embeddings.embedDocuments(texts), documents, options);
|
|
86
86
|
}
|
|
87
87
|
get index() {
|
|
88
88
|
if (!this._index) {
|
|
@@ -100,7 +100,7 @@ class FaissStore extends base_js_1.SaveableVectorStore {
|
|
|
100
100
|
* @param documents An array of Document objects corresponding to the vectors.
|
|
101
101
|
* @returns A Promise that resolves with an array of document IDs when the vectors and documents have been added.
|
|
102
102
|
*/
|
|
103
|
-
async addVectors(vectors, documents) {
|
|
103
|
+
async addVectors(vectors, documents, options) {
|
|
104
104
|
if (vectors.length === 0) {
|
|
105
105
|
return [];
|
|
106
106
|
}
|
|
@@ -117,10 +117,9 @@ class FaissStore extends base_js_1.SaveableVectorStore {
|
|
|
117
117
|
throw new Error(`Vectors must have the same length as the number of dimensions (${d})`);
|
|
118
118
|
}
|
|
119
119
|
const docstoreSize = this.index.ntotal();
|
|
120
|
-
const documentIds =
|
|
120
|
+
const documentIds = options?.ids ?? documents.map(() => uuid.v4());
|
|
121
121
|
for (let i = 0; i < vectors.length; i += 1) {
|
|
122
|
-
const documentId =
|
|
123
|
-
documentIds.push(documentId);
|
|
122
|
+
const documentId = documentIds[i];
|
|
124
123
|
const id = docstoreSize + i;
|
|
125
124
|
this.index.add(vectors[i]);
|
|
126
125
|
this._mapping[id] = documentId;
|
|
@@ -169,6 +168,39 @@ class FaissStore extends base_js_1.SaveableVectorStore {
|
|
|
169
168
|
])),
|
|
170
169
|
]);
|
|
171
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Method to delete documents.
|
|
173
|
+
* @param params Object containing the IDs of the documents to delete.
|
|
174
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
175
|
+
*/
|
|
176
|
+
async delete(params) {
|
|
177
|
+
const documentIds = params.ids;
|
|
178
|
+
if (documentIds == null) {
|
|
179
|
+
throw new Error("No documentIds provided to delete.");
|
|
180
|
+
}
|
|
181
|
+
const mappings = new Map(Object.entries(this._mapping).map(([key, value]) => [
|
|
182
|
+
parseInt(key, 10),
|
|
183
|
+
value,
|
|
184
|
+
]));
|
|
185
|
+
const reversedMappings = new Map(Array.from(mappings, (entry) => [entry[1], entry[0]]));
|
|
186
|
+
const missingIds = new Set(documentIds.filter((id) => !reversedMappings.has(id)));
|
|
187
|
+
if (missingIds.size > 0) {
|
|
188
|
+
throw new Error(`Some specified documentIds do not exist in the current store. DocumentIds not found: ${Array.from(missingIds).join(", ")}`);
|
|
189
|
+
}
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
191
|
+
const indexIdToDelete = documentIds.map((id) => reversedMappings.get(id));
|
|
192
|
+
// remove from index
|
|
193
|
+
this.index.removeIds(indexIdToDelete);
|
|
194
|
+
// remove from docstore
|
|
195
|
+
documentIds.forEach((id) => {
|
|
196
|
+
this.docstore._docs.delete(id);
|
|
197
|
+
});
|
|
198
|
+
// remove from mappings
|
|
199
|
+
indexIdToDelete.forEach((id) => {
|
|
200
|
+
mappings.delete(id);
|
|
201
|
+
});
|
|
202
|
+
this._mapping = { ...Array.from(mappings.values()) };
|
|
203
|
+
}
|
|
172
204
|
/**
|
|
173
205
|
* Merges the current FaissStore with another FaissStore.
|
|
174
206
|
* @param targetIndex The FaissStore to merge with.
|
|
@@ -32,7 +32,9 @@ export declare class FaissStore extends SaveableVectorStore {
|
|
|
32
32
|
* @param documents An array of Document objects.
|
|
33
33
|
* @returns A Promise that resolves when the documents have been added.
|
|
34
34
|
*/
|
|
35
|
-
addDocuments(documents: Document[]
|
|
35
|
+
addDocuments(documents: Document[], options?: {
|
|
36
|
+
ids?: string[];
|
|
37
|
+
}): Promise<string[]>;
|
|
36
38
|
get index(): IndexFlatL2;
|
|
37
39
|
private set index(value);
|
|
38
40
|
/**
|
|
@@ -42,7 +44,9 @@ export declare class FaissStore extends SaveableVectorStore {
|
|
|
42
44
|
* @param documents An array of Document objects corresponding to the vectors.
|
|
43
45
|
* @returns A Promise that resolves with an array of document IDs when the vectors and documents have been added.
|
|
44
46
|
*/
|
|
45
|
-
addVectors(vectors: number[][], documents: Document[]
|
|
47
|
+
addVectors(vectors: number[][], documents: Document[], options?: {
|
|
48
|
+
ids?: string[];
|
|
49
|
+
}): Promise<string[]>;
|
|
46
50
|
/**
|
|
47
51
|
* Performs a similarity search in the vector store using a query vector
|
|
48
52
|
* and returns the top k results along with their scores.
|
|
@@ -57,6 +61,14 @@ export declare class FaissStore extends SaveableVectorStore {
|
|
|
57
61
|
* @returns A Promise that resolves when the state has been saved.
|
|
58
62
|
*/
|
|
59
63
|
save(directory: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Method to delete documents.
|
|
66
|
+
* @param params Object containing the IDs of the documents to delete.
|
|
67
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
68
|
+
*/
|
|
69
|
+
delete(params: {
|
|
70
|
+
ids: string[];
|
|
71
|
+
}): Promise<void>;
|
|
60
72
|
/**
|
|
61
73
|
* Merges the current FaissStore with another FaissStore.
|
|
62
74
|
* @param targetIndex The FaissStore to merge with.
|
|
@@ -54,9 +54,9 @@ export class FaissStore extends SaveableVectorStore {
|
|
|
54
54
|
* @param documents An array of Document objects.
|
|
55
55
|
* @returns A Promise that resolves when the documents have been added.
|
|
56
56
|
*/
|
|
57
|
-
async addDocuments(documents) {
|
|
57
|
+
async addDocuments(documents, options) {
|
|
58
58
|
const texts = documents.map(({ pageContent }) => pageContent);
|
|
59
|
-
return this.addVectors(await this.embeddings.embedDocuments(texts), documents);
|
|
59
|
+
return this.addVectors(await this.embeddings.embedDocuments(texts), documents, options);
|
|
60
60
|
}
|
|
61
61
|
get index() {
|
|
62
62
|
if (!this._index) {
|
|
@@ -74,7 +74,7 @@ export class FaissStore extends SaveableVectorStore {
|
|
|
74
74
|
* @param documents An array of Document objects corresponding to the vectors.
|
|
75
75
|
* @returns A Promise that resolves with an array of document IDs when the vectors and documents have been added.
|
|
76
76
|
*/
|
|
77
|
-
async addVectors(vectors, documents) {
|
|
77
|
+
async addVectors(vectors, documents, options) {
|
|
78
78
|
if (vectors.length === 0) {
|
|
79
79
|
return [];
|
|
80
80
|
}
|
|
@@ -91,10 +91,9 @@ export class FaissStore extends SaveableVectorStore {
|
|
|
91
91
|
throw new Error(`Vectors must have the same length as the number of dimensions (${d})`);
|
|
92
92
|
}
|
|
93
93
|
const docstoreSize = this.index.ntotal();
|
|
94
|
-
const documentIds =
|
|
94
|
+
const documentIds = options?.ids ?? documents.map(() => uuid.v4());
|
|
95
95
|
for (let i = 0; i < vectors.length; i += 1) {
|
|
96
|
-
const documentId =
|
|
97
|
-
documentIds.push(documentId);
|
|
96
|
+
const documentId = documentIds[i];
|
|
98
97
|
const id = docstoreSize + i;
|
|
99
98
|
this.index.add(vectors[i]);
|
|
100
99
|
this._mapping[id] = documentId;
|
|
@@ -143,6 +142,39 @@ export class FaissStore extends SaveableVectorStore {
|
|
|
143
142
|
])),
|
|
144
143
|
]);
|
|
145
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Method to delete documents.
|
|
147
|
+
* @param params Object containing the IDs of the documents to delete.
|
|
148
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
149
|
+
*/
|
|
150
|
+
async delete(params) {
|
|
151
|
+
const documentIds = params.ids;
|
|
152
|
+
if (documentIds == null) {
|
|
153
|
+
throw new Error("No documentIds provided to delete.");
|
|
154
|
+
}
|
|
155
|
+
const mappings = new Map(Object.entries(this._mapping).map(([key, value]) => [
|
|
156
|
+
parseInt(key, 10),
|
|
157
|
+
value,
|
|
158
|
+
]));
|
|
159
|
+
const reversedMappings = new Map(Array.from(mappings, (entry) => [entry[1], entry[0]]));
|
|
160
|
+
const missingIds = new Set(documentIds.filter((id) => !reversedMappings.has(id)));
|
|
161
|
+
if (missingIds.size > 0) {
|
|
162
|
+
throw new Error(`Some specified documentIds do not exist in the current store. DocumentIds not found: ${Array.from(missingIds).join(", ")}`);
|
|
163
|
+
}
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
165
|
+
const indexIdToDelete = documentIds.map((id) => reversedMappings.get(id));
|
|
166
|
+
// remove from index
|
|
167
|
+
this.index.removeIds(indexIdToDelete);
|
|
168
|
+
// remove from docstore
|
|
169
|
+
documentIds.forEach((id) => {
|
|
170
|
+
this.docstore._docs.delete(id);
|
|
171
|
+
});
|
|
172
|
+
// remove from mappings
|
|
173
|
+
indexIdToDelete.forEach((id) => {
|
|
174
|
+
mappings.delete(id);
|
|
175
|
+
});
|
|
176
|
+
this._mapping = { ...Array.from(mappings.values()) };
|
|
177
|
+
}
|
|
146
178
|
/**
|
|
147
179
|
* Merges the current FaissStore with another FaissStore.
|
|
148
180
|
* @param targetIndex The FaissStore to merge with.
|
|
@@ -193,7 +193,7 @@ class PGVectorStore extends base_js_1.VectorStore {
|
|
|
193
193
|
const queryString = `
|
|
194
194
|
SELECT *, ${this.vectorColumnName} <=> $1 as "_distance"
|
|
195
195
|
FROM ${this.tableName}
|
|
196
|
-
WHERE ${this.metadataColumnName} @> $2
|
|
196
|
+
WHERE ${this.metadataColumnName}::jsonb @> $2
|
|
197
197
|
ORDER BY "_distance" ASC
|
|
198
198
|
LIMIT $3;`;
|
|
199
199
|
const documents = (await this.pool.query(queryString, [embeddingString, _filter, k])).rows;
|
|
@@ -187,7 +187,7 @@ export class PGVectorStore extends VectorStore {
|
|
|
187
187
|
const queryString = `
|
|
188
188
|
SELECT *, ${this.vectorColumnName} <=> $1 as "_distance"
|
|
189
189
|
FROM ${this.tableName}
|
|
190
|
-
WHERE ${this.metadataColumnName} @> $2
|
|
190
|
+
WHERE ${this.metadataColumnName}::jsonb @> $2
|
|
191
191
|
ORDER BY "_distance" ASC
|
|
192
192
|
LIMIT $3;`;
|
|
193
193
|
const documents = (await this.pool.query(queryString, [embeddingString, _filter, k])).rows;
|
|
@@ -159,13 +159,24 @@ class WeaviateStore extends base_js_1.VectorStore {
|
|
|
159
159
|
};
|
|
160
160
|
});
|
|
161
161
|
try {
|
|
162
|
-
await this.client.batch
|
|
162
|
+
const responses = await this.client.batch
|
|
163
163
|
.objectsBatcher()
|
|
164
164
|
.withObjects(...batch)
|
|
165
165
|
.do();
|
|
166
|
+
// if storing vectors fails, we need to know why
|
|
167
|
+
const errorMessages = [];
|
|
168
|
+
responses.forEach((response) => {
|
|
169
|
+
if (response?.result?.errors?.error) {
|
|
170
|
+
errorMessages.push(...response.result.errors.error.map((err) => err.message ??
|
|
171
|
+
"!! Unfortunately no error message was presented in the API response !!"));
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
if (errorMessages.length > 0) {
|
|
175
|
+
throw new Error(errorMessages.join("\n"));
|
|
176
|
+
}
|
|
166
177
|
}
|
|
167
178
|
catch (e) {
|
|
168
|
-
throw Error(`
|
|
179
|
+
throw Error(`Error adding vectors: ${e}`);
|
|
169
180
|
}
|
|
170
181
|
return documentIds;
|
|
171
182
|
}
|
|
@@ -132,13 +132,24 @@ export class WeaviateStore extends VectorStore {
|
|
|
132
132
|
};
|
|
133
133
|
});
|
|
134
134
|
try {
|
|
135
|
-
await this.client.batch
|
|
135
|
+
const responses = await this.client.batch
|
|
136
136
|
.objectsBatcher()
|
|
137
137
|
.withObjects(...batch)
|
|
138
138
|
.do();
|
|
139
|
+
// if storing vectors fails, we need to know why
|
|
140
|
+
const errorMessages = [];
|
|
141
|
+
responses.forEach((response) => {
|
|
142
|
+
if (response?.result?.errors?.error) {
|
|
143
|
+
errorMessages.push(...response.result.errors.error.map((err) => err.message ??
|
|
144
|
+
"!! Unfortunately no error message was presented in the API response !!"));
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
if (errorMessages.length > 0) {
|
|
148
|
+
throw new Error(errorMessages.join("\n"));
|
|
149
|
+
}
|
|
139
150
|
}
|
|
140
151
|
catch (e) {
|
|
141
|
-
throw Error(`
|
|
152
|
+
throw Error(`Error adding vectors: ${e}`);
|
|
142
153
|
}
|
|
143
154
|
return documentIds;
|
|
144
155
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/experimental/chains/violation_of_expectations/index.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/experimental/chains/violation_of_expectations/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/experimental/chains/violation_of_expectations/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.170",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
"agents/toolkits/sql.cjs",
|
|
32
32
|
"agents/toolkits/sql.js",
|
|
33
33
|
"agents/toolkits/sql.d.ts",
|
|
34
|
+
"agents/format_scratchpad.cjs",
|
|
35
|
+
"agents/format_scratchpad.js",
|
|
36
|
+
"agents/format_scratchpad.d.ts",
|
|
34
37
|
"base_language.cjs",
|
|
35
38
|
"base_language.js",
|
|
36
39
|
"base_language.d.ts",
|
|
@@ -472,6 +475,9 @@
|
|
|
472
475
|
"chat_models/minimax.cjs",
|
|
473
476
|
"chat_models/minimax.js",
|
|
474
477
|
"chat_models/minimax.d.ts",
|
|
478
|
+
"chat_models/yandex.cjs",
|
|
479
|
+
"chat_models/yandex.js",
|
|
480
|
+
"chat_models/yandex.d.ts",
|
|
475
481
|
"chat_models/fake.cjs",
|
|
476
482
|
"chat_models/fake.js",
|
|
477
483
|
"chat_models/fake.d.ts",
|
|
@@ -661,6 +667,9 @@
|
|
|
661
667
|
"storage/vercel_kv.cjs",
|
|
662
668
|
"storage/vercel_kv.js",
|
|
663
669
|
"storage/vercel_kv.d.ts",
|
|
670
|
+
"storage/upstash_redis.cjs",
|
|
671
|
+
"storage/upstash_redis.js",
|
|
672
|
+
"storage/upstash_redis.d.ts",
|
|
664
673
|
"graphs/neo4j_graph.cjs",
|
|
665
674
|
"graphs/neo4j_graph.js",
|
|
666
675
|
"graphs/neo4j_graph.d.ts",
|
|
@@ -700,6 +709,9 @@
|
|
|
700
709
|
"experimental/hubs/makersuite/googlemakersuitehub.cjs",
|
|
701
710
|
"experimental/hubs/makersuite/googlemakersuitehub.js",
|
|
702
711
|
"experimental/hubs/makersuite/googlemakersuitehub.d.ts",
|
|
712
|
+
"experimental/chains/violation_of_expectations.cjs",
|
|
713
|
+
"experimental/chains/violation_of_expectations.js",
|
|
714
|
+
"experimental/chains/violation_of_expectations.d.ts",
|
|
703
715
|
"evaluation.cjs",
|
|
704
716
|
"evaluation.js",
|
|
705
717
|
"evaluation.d.ts",
|
|
@@ -712,7 +724,7 @@
|
|
|
712
724
|
],
|
|
713
725
|
"repository": {
|
|
714
726
|
"type": "git",
|
|
715
|
-
"url": "git@github.com:
|
|
727
|
+
"url": "git@github.com:langchain-ai/langchainjs.git"
|
|
716
728
|
},
|
|
717
729
|
"scripts": {
|
|
718
730
|
"build": "yarn clean && yarn build:esm && yarn build:cjs && node scripts/create-entrypoints.js && node scripts/check-tree-shaking.js",
|
|
@@ -752,7 +764,7 @@
|
|
|
752
764
|
"@elastic/elasticsearch": "^8.4.0",
|
|
753
765
|
"@faker-js/faker": "^7.6.0",
|
|
754
766
|
"@getmetal/metal-sdk": "^4.0.0",
|
|
755
|
-
"@getzep/zep-js": "^0.
|
|
767
|
+
"@getzep/zep-js": "^0.8.0",
|
|
756
768
|
"@gomomento/sdk": "^1.41.2",
|
|
757
769
|
"@gomomento/sdk-core": "^1.41.2",
|
|
758
770
|
"@google-ai/generativelanguage": "^0.2.1",
|
|
@@ -802,6 +814,7 @@
|
|
|
802
814
|
"@xenova/transformers": "^2.5.4",
|
|
803
815
|
"@zilliz/milvus2-sdk-node": ">=2.2.11",
|
|
804
816
|
"apify-client": "^2.7.1",
|
|
817
|
+
"assemblyai": "^2.0.2",
|
|
805
818
|
"axios": "^0.26.0",
|
|
806
819
|
"cassandra-driver": "^4.6.4",
|
|
807
820
|
"cheerio": "^1.0.0-rc.12",
|
|
@@ -820,7 +833,7 @@
|
|
|
820
833
|
"eslint-plugin-import": "^2.27.5",
|
|
821
834
|
"eslint-plugin-no-instanceof": "^1.0.1",
|
|
822
835
|
"eslint-plugin-prettier": "^4.2.1",
|
|
823
|
-
"faiss-node": "^0.
|
|
836
|
+
"faiss-node": "^0.5.1",
|
|
824
837
|
"fast-xml-parser": "^4.2.7",
|
|
825
838
|
"firebase-admin": "^11.9.0",
|
|
826
839
|
"google-auth-library": "^8.9.0",
|
|
@@ -833,7 +846,7 @@
|
|
|
833
846
|
"jest": "^29.5.0",
|
|
834
847
|
"jest-environment-node": "^29.6.4",
|
|
835
848
|
"jsdom": "^22.1.0",
|
|
836
|
-
"llmonitor": "^0.5.
|
|
849
|
+
"llmonitor": "^0.5.8",
|
|
837
850
|
"lodash": "^4.17.21",
|
|
838
851
|
"mammoth": "^1.5.1",
|
|
839
852
|
"ml-matrix": "^6.10.4",
|
|
@@ -846,7 +859,7 @@
|
|
|
846
859
|
"peggy": "^3.0.2",
|
|
847
860
|
"pg": "^8.11.0",
|
|
848
861
|
"pg-copy-streams": "^6.0.5",
|
|
849
|
-
"pickleparser": "^0.1
|
|
862
|
+
"pickleparser": "^0.2.1",
|
|
850
863
|
"playwright": "^1.32.1",
|
|
851
864
|
"portkey-ai": "^0.1.11",
|
|
852
865
|
"prettier": "^2.8.3",
|
|
@@ -886,7 +899,7 @@
|
|
|
886
899
|
"@cloudflare/ai": "^1.0.12",
|
|
887
900
|
"@elastic/elasticsearch": "^8.4.0",
|
|
888
901
|
"@getmetal/metal-sdk": "*",
|
|
889
|
-
"@getzep/zep-js": "^0.
|
|
902
|
+
"@getzep/zep-js": "^0.8.0",
|
|
890
903
|
"@gomomento/sdk": "^1.41.2",
|
|
891
904
|
"@gomomento/sdk-core": "^1.41.2",
|
|
892
905
|
"@gomomento/sdk-web": "^1.41.2",
|
|
@@ -917,6 +930,7 @@
|
|
|
917
930
|
"@xenova/transformers": "^2.5.4",
|
|
918
931
|
"@zilliz/milvus2-sdk-node": ">=2.2.7",
|
|
919
932
|
"apify-client": "^2.7.1",
|
|
933
|
+
"assemblyai": "^2.0.2",
|
|
920
934
|
"axios": "*",
|
|
921
935
|
"cassandra-driver": "^4.6.4",
|
|
922
936
|
"cheerio": "^1.0.0-rc.12",
|
|
@@ -927,7 +941,7 @@
|
|
|
927
941
|
"cohere-ai": ">=6.0.0",
|
|
928
942
|
"d3-dsv": "^2.0.0",
|
|
929
943
|
"epub2": "^3.0.1",
|
|
930
|
-
"faiss-node": "^0.
|
|
944
|
+
"faiss-node": "^0.5.1",
|
|
931
945
|
"fast-xml-parser": "^4.2.7",
|
|
932
946
|
"firebase-admin": "^11.9.0",
|
|
933
947
|
"google-auth-library": "^8.9.0",
|
|
@@ -937,7 +951,7 @@
|
|
|
937
951
|
"ignore": "^5.2.0",
|
|
938
952
|
"ioredis": "^5.3.2",
|
|
939
953
|
"jsdom": "*",
|
|
940
|
-
"llmonitor": "
|
|
954
|
+
"llmonitor": "^0.5.8",
|
|
941
955
|
"lodash": "^4.17.21",
|
|
942
956
|
"mammoth": "*",
|
|
943
957
|
"mongodb": "^5.2.0",
|
|
@@ -949,7 +963,7 @@
|
|
|
949
963
|
"peggy": "^3.0.2",
|
|
950
964
|
"pg": "^8.11.0",
|
|
951
965
|
"pg-copy-streams": "^6.0.5",
|
|
952
|
-
"pickleparser": "^0.1
|
|
966
|
+
"pickleparser": "^0.2.1",
|
|
953
967
|
"playwright": "^1.32.1",
|
|
954
968
|
"portkey-ai": "^0.1.11",
|
|
955
969
|
"puppeteer": "^19.7.2",
|
|
@@ -1103,6 +1117,9 @@
|
|
|
1103
1117
|
"apify-client": {
|
|
1104
1118
|
"optional": true
|
|
1105
1119
|
},
|
|
1120
|
+
"assemblyai": {
|
|
1121
|
+
"optional": true
|
|
1122
|
+
},
|
|
1106
1123
|
"axios": {
|
|
1107
1124
|
"optional": true
|
|
1108
1125
|
},
|
|
@@ -1328,6 +1345,11 @@
|
|
|
1328
1345
|
"import": "./agents/toolkits/sql.js",
|
|
1329
1346
|
"require": "./agents/toolkits/sql.cjs"
|
|
1330
1347
|
},
|
|
1348
|
+
"./agents/format_scratchpad": {
|
|
1349
|
+
"types": "./agents/format_scratchpad.d.ts",
|
|
1350
|
+
"import": "./agents/format_scratchpad.js",
|
|
1351
|
+
"require": "./agents/format_scratchpad.cjs"
|
|
1352
|
+
},
|
|
1331
1353
|
"./base_language": {
|
|
1332
1354
|
"types": "./base_language.d.ts",
|
|
1333
1355
|
"import": "./base_language.js",
|
|
@@ -2063,6 +2085,11 @@
|
|
|
2063
2085
|
"import": "./chat_models/minimax.js",
|
|
2064
2086
|
"require": "./chat_models/minimax.cjs"
|
|
2065
2087
|
},
|
|
2088
|
+
"./chat_models/yandex": {
|
|
2089
|
+
"types": "./chat_models/yandex.d.ts",
|
|
2090
|
+
"import": "./chat_models/yandex.js",
|
|
2091
|
+
"require": "./chat_models/yandex.cjs"
|
|
2092
|
+
},
|
|
2066
2093
|
"./chat_models/fake": {
|
|
2067
2094
|
"types": "./chat_models/fake.d.ts",
|
|
2068
2095
|
"import": "./chat_models/fake.js",
|
|
@@ -2378,6 +2405,11 @@
|
|
|
2378
2405
|
"import": "./storage/vercel_kv.js",
|
|
2379
2406
|
"require": "./storage/vercel_kv.cjs"
|
|
2380
2407
|
},
|
|
2408
|
+
"./storage/upstash_redis": {
|
|
2409
|
+
"types": "./storage/upstash_redis.d.ts",
|
|
2410
|
+
"import": "./storage/upstash_redis.js",
|
|
2411
|
+
"require": "./storage/upstash_redis.cjs"
|
|
2412
|
+
},
|
|
2381
2413
|
"./graphs/neo4j_graph": {
|
|
2382
2414
|
"types": "./graphs/neo4j_graph.d.ts",
|
|
2383
2415
|
"import": "./graphs/neo4j_graph.js",
|
|
@@ -2443,6 +2475,11 @@
|
|
|
2443
2475
|
"import": "./experimental/hubs/makersuite/googlemakersuitehub.js",
|
|
2444
2476
|
"require": "./experimental/hubs/makersuite/googlemakersuitehub.cjs"
|
|
2445
2477
|
},
|
|
2478
|
+
"./experimental/chains/violation_of_expectations": {
|
|
2479
|
+
"types": "./experimental/chains/violation_of_expectations.d.ts",
|
|
2480
|
+
"import": "./experimental/chains/violation_of_expectations.js",
|
|
2481
|
+
"require": "./experimental/chains/violation_of_expectations.cjs"
|
|
2482
|
+
},
|
|
2446
2483
|
"./evaluation": {
|
|
2447
2484
|
"types": "./evaluation.d.ts",
|
|
2448
2485
|
"import": "./evaluation.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/storage/upstash_redis.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/storage/upstash_redis.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/storage/upstash_redis.js'
|