langchain 0.0.63 → 0.0.65
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/agent.cjs +3 -4
- package/dist/agents/agent.js +3 -4
- package/dist/agents/chat_convo/prompt.cjs +1 -1
- package/dist/agents/chat_convo/prompt.d.ts +1 -1
- package/dist/agents/chat_convo/prompt.js +1 -1
- package/dist/agents/initialize.cjs +1 -1
- package/dist/agents/initialize.d.ts +1 -1
- package/dist/agents/initialize.js +1 -1
- package/dist/agents/types.cjs +2 -2
- package/dist/agents/types.d.ts +2 -1
- package/dist/agents/types.js +1 -1
- package/dist/base_language/index.d.ts +4 -1
- package/dist/callbacks/manager.cjs +5 -1
- package/dist/callbacks/manager.js +5 -1
- package/dist/chains/analyze_documents_chain.cjs +3 -3
- package/dist/chains/analyze_documents_chain.d.ts +2 -1
- package/dist/chains/analyze_documents_chain.js +3 -3
- package/dist/chains/base.cjs +30 -11
- package/dist/chains/base.d.ts +7 -3
- package/dist/chains/base.js +30 -11
- package/dist/chains/chat_vector_db_chain.cjs +4 -4
- package/dist/chains/chat_vector_db_chain.d.ts +9 -15
- package/dist/chains/chat_vector_db_chain.js +4 -4
- package/dist/chains/combine_docs_chain.cjs +11 -11
- package/dist/chains/combine_docs_chain.d.ts +6 -5
- package/dist/chains/combine_docs_chain.js +11 -11
- package/dist/chains/conversational_retrieval_chain.cjs +4 -4
- package/dist/chains/conversational_retrieval_chain.d.ts +2 -1
- package/dist/chains/conversational_retrieval_chain.js +4 -4
- package/dist/chains/index.cjs +4 -3
- package/dist/chains/index.d.ts +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/chains/llm_chain.cjs +4 -4
- package/dist/chains/llm_chain.d.ts +3 -2
- package/dist/chains/llm_chain.js +4 -4
- package/dist/chains/retrieval_qa.cjs +3 -3
- package/dist/chains/retrieval_qa.d.ts +2 -1
- package/dist/chains/retrieval_qa.js +3 -3
- package/dist/chains/sequential_chain.cjs +262 -0
- package/dist/chains/{simple_sequential_chain.d.ts → sequential_chain.d.ts} +31 -2
- package/dist/chains/sequential_chain.js +257 -0
- package/dist/chains/serde.d.ts +7 -1
- package/dist/chains/sql_db/sql_db_chain.cjs +7 -5
- package/dist/chains/sql_db/sql_db_chain.d.ts +2 -1
- package/dist/chains/sql_db/sql_db_chain.js +7 -5
- package/dist/chains/vector_db_qa.cjs +3 -3
- package/dist/chains/vector_db_qa.d.ts +2 -1
- package/dist/chains/vector_db_qa.js +3 -3
- package/dist/chat_models/base.d.ts +10 -8
- package/dist/chat_models/openai.cjs +9 -5
- package/dist/chat_models/openai.d.ts +14 -5
- package/dist/chat_models/openai.js +10 -6
- package/dist/document_loaders/fs/unstructured.cjs +48 -1
- package/dist/document_loaders/fs/unstructured.d.ts +9 -1
- package/dist/document_loaders/fs/unstructured.js +46 -0
- package/dist/embeddings/tensorflow.cjs +67 -0
- package/dist/embeddings/tensorflow.d.ts +12 -0
- package/dist/embeddings/tensorflow.js +40 -0
- package/dist/experimental/autogpt/output_parser.cjs +2 -2
- package/dist/experimental/autogpt/output_parser.d.ts +1 -1
- package/dist/experimental/autogpt/output_parser.js +1 -1
- package/dist/experimental/babyagi/agent.cjs +194 -0
- package/dist/experimental/babyagi/agent.d.ts +47 -0
- package/dist/experimental/babyagi/agent.js +190 -0
- package/dist/experimental/babyagi/index.cjs +11 -0
- package/dist/experimental/babyagi/index.d.ts +4 -0
- package/dist/experimental/babyagi/index.js +4 -0
- package/dist/experimental/babyagi/task_creation.cjs +29 -0
- package/dist/experimental/babyagi/task_creation.d.ts +5 -0
- package/dist/experimental/babyagi/task_creation.js +25 -0
- package/dist/experimental/babyagi/task_execution.cjs +20 -0
- package/dist/experimental/babyagi/task_execution.d.ts +5 -0
- package/dist/experimental/babyagi/task_execution.js +16 -0
- package/dist/experimental/babyagi/task_prioritization.cjs +23 -0
- package/dist/experimental/babyagi/task_prioritization.d.ts +5 -0
- package/dist/experimental/babyagi/task_prioritization.js +19 -0
- package/dist/llms/base.cjs +0 -9
- package/dist/llms/base.d.ts +11 -12
- package/dist/llms/base.js +0 -9
- package/dist/llms/openai-chat.cjs +9 -5
- package/dist/llms/openai-chat.d.ts +16 -7
- package/dist/llms/openai-chat.js +9 -5
- package/dist/llms/openai.cjs +9 -5
- package/dist/llms/openai.d.ts +15 -12
- package/dist/llms/openai.js +10 -6
- package/dist/memory/base.d.ts +1 -0
- package/dist/memory/buffer_memory.cjs +3 -0
- package/dist/memory/buffer_memory.d.ts +1 -0
- package/dist/memory/buffer_memory.js +3 -0
- package/dist/memory/buffer_window_memory.cjs +5 -0
- package/dist/memory/buffer_window_memory.d.ts +1 -0
- package/dist/memory/buffer_window_memory.js +5 -0
- package/dist/memory/motorhead_memory.cjs +3 -0
- package/dist/memory/motorhead_memory.d.ts +1 -0
- package/dist/memory/motorhead_memory.js +3 -0
- package/dist/memory/summary.cjs +3 -0
- package/dist/memory/summary.d.ts +1 -0
- package/dist/memory/summary.js +3 -0
- package/dist/output_parsers/combining.cjs +4 -4
- package/dist/output_parsers/combining.d.ts +3 -2
- package/dist/output_parsers/combining.js +3 -3
- package/dist/output_parsers/fix.cjs +6 -6
- package/dist/output_parsers/fix.d.ts +3 -2
- package/dist/output_parsers/fix.js +4 -4
- package/dist/output_parsers/list.cjs +3 -3
- package/dist/output_parsers/list.d.ts +1 -1
- package/dist/output_parsers/list.js +1 -1
- package/dist/output_parsers/regex.cjs +3 -3
- package/dist/output_parsers/regex.d.ts +1 -1
- package/dist/output_parsers/regex.js +1 -1
- package/dist/output_parsers/structured.cjs +10 -4
- package/dist/output_parsers/structured.d.ts +1 -1
- package/dist/output_parsers/structured.js +9 -3
- package/dist/prompts/base.d.ts +2 -1
- package/dist/prompts/chat.cjs +16 -2
- package/dist/prompts/chat.d.ts +2 -2
- package/dist/prompts/chat.js +16 -2
- package/dist/retrievers/supabase.cjs +2 -2
- package/dist/retrievers/supabase.js +2 -2
- package/dist/schema/index.cjs +1 -21
- package/dist/schema/index.d.ts +0 -30
- package/dist/schema/index.js +0 -18
- package/dist/schema/output_parser.cjs +23 -0
- package/dist/schema/output_parser.d.ts +32 -0
- package/dist/schema/output_parser.js +18 -0
- package/dist/tools/base.cjs +4 -4
- package/dist/tools/base.d.ts +4 -7
- package/dist/tools/base.js +4 -4
- package/dist/tools/fs.cjs +4 -4
- package/dist/tools/fs.d.ts +2 -2
- package/dist/tools/fs.js +4 -4
- package/dist/tools/serpapi.cjs +17 -10
- package/dist/tools/serpapi.d.ts +4 -1
- package/dist/tools/serpapi.js +17 -10
- package/dist/tools/webbrowser.cjs +5 -5
- package/dist/tools/webbrowser.d.ts +6 -6
- package/dist/tools/webbrowser.js +5 -5
- package/dist/util/async_caller.cjs +9 -0
- package/dist/util/async_caller.js +9 -0
- package/dist/util/axios-fetch-adapter.cjs +6 -0
- package/dist/util/axios-fetch-adapter.js +6 -0
- package/dist/util/axios-types.d.ts +3 -1
- package/dist/util/flatten.cjs +21 -0
- package/dist/util/flatten.d.ts +1 -0
- package/dist/util/flatten.js +17 -0
- package/dist/util/set.cjs +41 -0
- package/dist/util/set.d.ts +15 -0
- package/dist/util/set.js +35 -0
- package/dist/vectorstores/pinecone.cjs +4 -0
- package/dist/vectorstores/pinecone.js +4 -0
- package/dist/vectorstores/supabase.cjs +1 -1
- package/dist/vectorstores/supabase.js +1 -1
- package/dist/vectorstores/weaviate.cjs +15 -9
- package/dist/vectorstores/weaviate.js +15 -9
- package/embeddings/tensorflow.cjs +1 -0
- package/embeddings/tensorflow.d.ts +1 -0
- package/embeddings/tensorflow.js +1 -0
- package/experimental/babyagi.cjs +1 -0
- package/experimental/babyagi.d.ts +1 -0
- package/experimental/babyagi.js +1 -0
- package/package.json +36 -5
- package/dist/chains/simple_sequential_chain.cjs +0 -124
- package/dist/chains/simple_sequential_chain.js +0 -120
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseOutputParser, OutputParserException } from "../schema/
|
|
1
|
+
import { BaseOutputParser, OutputParserException, } from "../schema/output_parser.js";
|
|
2
2
|
import { LLMChain } from "../chains/llm_chain.js";
|
|
3
3
|
import { NAIVE_FIX_PROMPT } from "./prompts.js";
|
|
4
4
|
export class OutputFixingParser extends BaseOutputParser {
|
|
@@ -24,9 +24,9 @@ export class OutputFixingParser extends BaseOutputParser {
|
|
|
24
24
|
this.parser = parser;
|
|
25
25
|
this.retryChain = retryChain;
|
|
26
26
|
}
|
|
27
|
-
async parse(completion) {
|
|
27
|
+
async parse(completion, callbacks) {
|
|
28
28
|
try {
|
|
29
|
-
return await this.parser.parse(completion);
|
|
29
|
+
return await this.parser.parse(completion, callbacks);
|
|
30
30
|
}
|
|
31
31
|
catch (e) {
|
|
32
32
|
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
@@ -35,7 +35,7 @@ export class OutputFixingParser extends BaseOutputParser {
|
|
|
35
35
|
instructions: this.parser.getFormatInstructions(),
|
|
36
36
|
completion,
|
|
37
37
|
error: e,
|
|
38
|
-
});
|
|
38
|
+
}, callbacks);
|
|
39
39
|
const newCompletion = result[this.retryChain.outputKey];
|
|
40
40
|
return this.parser.parse(newCompletion);
|
|
41
41
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommaSeparatedListOutputParser = exports.ListOutputParser = void 0;
|
|
4
|
-
const
|
|
4
|
+
const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
5
5
|
/**
|
|
6
6
|
* Class to parse the output of an LLM call to a list.
|
|
7
7
|
* @augments BaseOutputParser
|
|
8
8
|
*/
|
|
9
|
-
class ListOutputParser extends
|
|
9
|
+
class ListOutputParser extends output_parser_js_1.BaseOutputParser {
|
|
10
10
|
}
|
|
11
11
|
exports.ListOutputParser = ListOutputParser;
|
|
12
12
|
/**
|
|
@@ -22,7 +22,7 @@ class CommaSeparatedListOutputParser extends ListOutputParser {
|
|
|
22
22
|
.map((s) => s.trim());
|
|
23
23
|
}
|
|
24
24
|
catch (e) {
|
|
25
|
-
throw new
|
|
25
|
+
throw new output_parser_js_1.OutputParserException(`Could not parse output: ${text}`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
getFormatInstructions() {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RegexParser = void 0;
|
|
4
|
-
const
|
|
4
|
+
const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
5
5
|
/**
|
|
6
6
|
* Class to parse the output of an LLM call into a dictionary.
|
|
7
7
|
* @augments BaseOutputParser
|
|
8
8
|
*/
|
|
9
|
-
class RegexParser extends
|
|
9
|
+
class RegexParser extends output_parser_js_1.BaseOutputParser {
|
|
10
10
|
constructor(regex, outputKeys, defaultOutputKey) {
|
|
11
11
|
super();
|
|
12
12
|
Object.defineProperty(this, "regex", {
|
|
@@ -43,7 +43,7 @@ class RegexParser extends index_js_1.BaseOutputParser {
|
|
|
43
43
|
}, {});
|
|
44
44
|
}
|
|
45
45
|
if (this.defaultOutputKey === undefined) {
|
|
46
|
-
throw new
|
|
46
|
+
throw new output_parser_js_1.OutputParserException(`Could not parse output: ${text}`);
|
|
47
47
|
}
|
|
48
48
|
return this.outputKeys.reduce((acc, key) => {
|
|
49
49
|
acc[key] = key === this.defaultOutputKey ? text : "";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StructuredOutputParser = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
6
6
|
function printSchema(schema, depth = 0) {
|
|
7
7
|
if (schema._def.typeName === "ZodString" &&
|
|
8
8
|
schema._def.checks.some((check) => check.kind === "datetime")) {
|
|
@@ -25,6 +25,12 @@ function printSchema(schema, depth = 0) {
|
|
|
25
25
|
.map((value) => `"${value}"`)
|
|
26
26
|
.join(" | ");
|
|
27
27
|
}
|
|
28
|
+
if (schema._def.typeName === "ZodNativeEnum") {
|
|
29
|
+
return zod_1.util
|
|
30
|
+
.getValidEnumValues(schema._def.values)
|
|
31
|
+
.map((value) => `"${value}"`)
|
|
32
|
+
.join(" | ");
|
|
33
|
+
}
|
|
28
34
|
if (schema._def.typeName === "ZodNullable") {
|
|
29
35
|
return `${printSchema(schema._def.innerType, depth)} // Nullable`;
|
|
30
36
|
}
|
|
@@ -52,7 +58,7 @@ ${indent}}`;
|
|
|
52
58
|
}
|
|
53
59
|
throw new Error(`Unsupported type: ${schema._def.typeName}`);
|
|
54
60
|
}
|
|
55
|
-
class StructuredOutputParser extends
|
|
61
|
+
class StructuredOutputParser extends output_parser_js_1.BaseOutputParser {
|
|
56
62
|
constructor(schema) {
|
|
57
63
|
super();
|
|
58
64
|
Object.defineProperty(this, "schema", {
|
|
@@ -82,10 +88,10 @@ Including the leading and trailing "\`\`\`json" and "\`\`\`"
|
|
|
82
88
|
async parse(text) {
|
|
83
89
|
try {
|
|
84
90
|
const json = text.trim().split("```json")[1].split("```")[0].trim();
|
|
85
|
-
return this.schema.
|
|
91
|
+
return this.schema.parseAsync(JSON.parse(json));
|
|
86
92
|
}
|
|
87
93
|
catch (e) {
|
|
88
|
-
throw new
|
|
94
|
+
throw new output_parser_js_1.OutputParserException(`Failed to parse. Text: "${text}". Error: ${e}`);
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { BaseOutputParser } from "../schema/
|
|
2
|
+
import { BaseOutputParser } from "../schema/output_parser.js";
|
|
3
3
|
export declare class StructuredOutputParser<T extends z.ZodTypeAny> extends BaseOutputParser<z.infer<T>> {
|
|
4
4
|
schema: T;
|
|
5
5
|
constructor(schema: T);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { BaseOutputParser, OutputParserException } from "../schema/
|
|
1
|
+
import { z, util } from "zod";
|
|
2
|
+
import { BaseOutputParser, OutputParserException, } from "../schema/output_parser.js";
|
|
3
3
|
function printSchema(schema, depth = 0) {
|
|
4
4
|
if (schema._def.typeName === "ZodString" &&
|
|
5
5
|
schema._def.checks.some((check) => check.kind === "datetime")) {
|
|
@@ -22,6 +22,12 @@ function printSchema(schema, depth = 0) {
|
|
|
22
22
|
.map((value) => `"${value}"`)
|
|
23
23
|
.join(" | ");
|
|
24
24
|
}
|
|
25
|
+
if (schema._def.typeName === "ZodNativeEnum") {
|
|
26
|
+
return util
|
|
27
|
+
.getValidEnumValues(schema._def.values)
|
|
28
|
+
.map((value) => `"${value}"`)
|
|
29
|
+
.join(" | ");
|
|
30
|
+
}
|
|
25
31
|
if (schema._def.typeName === "ZodNullable") {
|
|
26
32
|
return `${printSchema(schema._def.innerType, depth)} // Nullable`;
|
|
27
33
|
}
|
|
@@ -79,7 +85,7 @@ Including the leading and trailing "\`\`\`json" and "\`\`\`"
|
|
|
79
85
|
async parse(text) {
|
|
80
86
|
try {
|
|
81
87
|
const json = text.trim().split("```json")[1].split("```")[0].trim();
|
|
82
|
-
return this.schema.
|
|
88
|
+
return this.schema.parseAsync(JSON.parse(json));
|
|
83
89
|
}
|
|
84
90
|
catch (e) {
|
|
85
91
|
throw new OutputParserException(`Failed to parse. Text: "${text}". Error: ${e}`);
|
package/dist/prompts/base.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BasePromptValue, Example, HumanChatMessage, InputValues, PartialValues } from "../schema/index.js";
|
|
2
|
+
import { BaseOutputParser } from "../schema/output_parser.js";
|
|
2
3
|
import { SerializedBasePromptTemplate } from "./serde.js";
|
|
3
4
|
export declare class StringPromptValue {
|
|
4
5
|
value: string;
|
package/dist/prompts/chat.cjs
CHANGED
|
@@ -218,15 +218,29 @@ class ChatPromptTemplate extends BaseChatPromptTemplate {
|
|
|
218
218
|
return new ChatPromptTemplate(promptDict);
|
|
219
219
|
}
|
|
220
220
|
static fromPromptMessages(promptMessages) {
|
|
221
|
+
const flattenedMessages = promptMessages.reduce((acc, promptMessage) => acc.concat(
|
|
222
|
+
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
223
|
+
promptMessage instanceof ChatPromptTemplate
|
|
224
|
+
? promptMessage.promptMessages
|
|
225
|
+
: [promptMessage]), []);
|
|
226
|
+
const flattenedPartialVariables = promptMessages.reduce((acc, promptMessage) =>
|
|
227
|
+
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
228
|
+
promptMessage instanceof ChatPromptTemplate
|
|
229
|
+
? Object.assign(acc, promptMessage.partialVariables)
|
|
230
|
+
: acc, Object.create(null));
|
|
221
231
|
const inputVariables = new Set();
|
|
222
|
-
for (const promptMessage of
|
|
232
|
+
for (const promptMessage of flattenedMessages) {
|
|
223
233
|
for (const inputVariable of promptMessage.inputVariables) {
|
|
234
|
+
if (inputVariable in flattenedPartialVariables) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
224
237
|
inputVariables.add(inputVariable);
|
|
225
238
|
}
|
|
226
239
|
}
|
|
227
240
|
return new ChatPromptTemplate({
|
|
228
241
|
inputVariables: [...inputVariables],
|
|
229
|
-
promptMessages,
|
|
242
|
+
promptMessages: flattenedMessages,
|
|
243
|
+
partialVariables: flattenedPartialVariables,
|
|
230
244
|
});
|
|
231
245
|
}
|
|
232
246
|
}
|
package/dist/prompts/chat.d.ts
CHANGED
|
@@ -71,6 +71,6 @@ export declare class ChatPromptTemplate extends BaseChatPromptTemplate implement
|
|
|
71
71
|
_getPromptType(): "chat";
|
|
72
72
|
formatMessages(values: InputValues): Promise<BaseChatMessage[]>;
|
|
73
73
|
serialize(): SerializedChatPromptTemplate;
|
|
74
|
-
partial(values: PartialValues): Promise<
|
|
75
|
-
static fromPromptMessages(promptMessages: BaseMessagePromptTemplate[]): ChatPromptTemplate;
|
|
74
|
+
partial(values: PartialValues): Promise<ChatPromptTemplate>;
|
|
75
|
+
static fromPromptMessages(promptMessages: (BaseMessagePromptTemplate | ChatPromptTemplate)[]): ChatPromptTemplate;
|
|
76
76
|
}
|
package/dist/prompts/chat.js
CHANGED
|
@@ -206,15 +206,29 @@ export class ChatPromptTemplate extends BaseChatPromptTemplate {
|
|
|
206
206
|
return new ChatPromptTemplate(promptDict);
|
|
207
207
|
}
|
|
208
208
|
static fromPromptMessages(promptMessages) {
|
|
209
|
+
const flattenedMessages = promptMessages.reduce((acc, promptMessage) => acc.concat(
|
|
210
|
+
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
211
|
+
promptMessage instanceof ChatPromptTemplate
|
|
212
|
+
? promptMessage.promptMessages
|
|
213
|
+
: [promptMessage]), []);
|
|
214
|
+
const flattenedPartialVariables = promptMessages.reduce((acc, promptMessage) =>
|
|
215
|
+
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
216
|
+
promptMessage instanceof ChatPromptTemplate
|
|
217
|
+
? Object.assign(acc, promptMessage.partialVariables)
|
|
218
|
+
: acc, Object.create(null));
|
|
209
219
|
const inputVariables = new Set();
|
|
210
|
-
for (const promptMessage of
|
|
220
|
+
for (const promptMessage of flattenedMessages) {
|
|
211
221
|
for (const inputVariable of promptMessage.inputVariables) {
|
|
222
|
+
if (inputVariable in flattenedPartialVariables) {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
212
225
|
inputVariables.add(inputVariable);
|
|
213
226
|
}
|
|
214
227
|
}
|
|
215
228
|
return new ChatPromptTemplate({
|
|
216
229
|
inputVariables: [...inputVariables],
|
|
217
|
-
promptMessages,
|
|
230
|
+
promptMessages: flattenedMessages,
|
|
231
|
+
partialVariables: flattenedPartialVariables,
|
|
218
232
|
});
|
|
219
233
|
}
|
|
220
234
|
}
|
|
@@ -70,7 +70,7 @@ class SupabaseHybridSearch extends index_js_1.BaseRetriever {
|
|
|
70
70
|
};
|
|
71
71
|
const { data: searches, error } = await this.client.rpc(this.similarityQueryName, matchDocumentsParams);
|
|
72
72
|
if (error) {
|
|
73
|
-
throw new Error(`Error searching for documents: ${error}`);
|
|
73
|
+
throw new Error(`Error searching for documents: ${error.code} ${error.message} ${error.details}`);
|
|
74
74
|
}
|
|
75
75
|
return searches.map((resp) => [
|
|
76
76
|
new document_js_1.Document({
|
|
@@ -88,7 +88,7 @@ class SupabaseHybridSearch extends index_js_1.BaseRetriever {
|
|
|
88
88
|
};
|
|
89
89
|
const { data: searches, error } = await this.client.rpc(this.keywordQueryName, kwMatchDocumentsParams);
|
|
90
90
|
if (error) {
|
|
91
|
-
throw new Error(`Error searching for documents: ${error}`);
|
|
91
|
+
throw new Error(`Error searching for documents: ${error.code} ${error.message} ${error.details}`);
|
|
92
92
|
}
|
|
93
93
|
return searches.map((resp) => [
|
|
94
94
|
new document_js_1.Document({
|
|
@@ -67,7 +67,7 @@ export class SupabaseHybridSearch extends BaseRetriever {
|
|
|
67
67
|
};
|
|
68
68
|
const { data: searches, error } = await this.client.rpc(this.similarityQueryName, matchDocumentsParams);
|
|
69
69
|
if (error) {
|
|
70
|
-
throw new Error(`Error searching for documents: ${error}`);
|
|
70
|
+
throw new Error(`Error searching for documents: ${error.code} ${error.message} ${error.details}`);
|
|
71
71
|
}
|
|
72
72
|
return searches.map((resp) => [
|
|
73
73
|
new Document({
|
|
@@ -85,7 +85,7 @@ export class SupabaseHybridSearch extends BaseRetriever {
|
|
|
85
85
|
};
|
|
86
86
|
const { data: searches, error } = await this.client.rpc(this.keywordQueryName, kwMatchDocumentsParams);
|
|
87
87
|
if (error) {
|
|
88
|
-
throw new Error(`Error searching for documents: ${error}`);
|
|
88
|
+
throw new Error(`Error searching for documents: ${error.code} ${error.message} ${error.details}`);
|
|
89
89
|
}
|
|
90
90
|
return searches.map((resp) => [
|
|
91
91
|
new Document({
|
package/dist/schema/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseFileStore = exports.BaseCache = exports.BaseChatMessageHistory = exports.
|
|
3
|
+
exports.BaseFileStore = exports.BaseCache = exports.BaseChatMessageHistory = exports.BaseRetriever = exports.BasePromptValue = exports.ChatMessage = exports.SystemChatMessage = exports.AIChatMessage = exports.HumanChatMessage = exports.BaseChatMessage = exports.RUN_KEY = void 0;
|
|
4
4
|
exports.RUN_KEY = "__run";
|
|
5
5
|
class BaseChatMessage {
|
|
6
6
|
constructor(text) {
|
|
@@ -68,26 +68,6 @@ exports.BasePromptValue = BasePromptValue;
|
|
|
68
68
|
class BaseRetriever {
|
|
69
69
|
}
|
|
70
70
|
exports.BaseRetriever = BaseRetriever;
|
|
71
|
-
/** Class to parse the output of an LLM call.
|
|
72
|
-
*/
|
|
73
|
-
class BaseOutputParser {
|
|
74
|
-
async parseWithPrompt(text, _prompt) {
|
|
75
|
-
return this.parse(text);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Return the string type key uniquely identifying this class of parser
|
|
79
|
-
*/
|
|
80
|
-
_type() {
|
|
81
|
-
throw new Error("_type not implemented");
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.BaseOutputParser = BaseOutputParser;
|
|
85
|
-
class OutputParserException extends Error {
|
|
86
|
-
constructor(message) {
|
|
87
|
-
super(message);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.OutputParserException = OutputParserException;
|
|
91
71
|
class BaseChatMessageHistory {
|
|
92
72
|
}
|
|
93
73
|
exports.BaseChatMessageHistory = BaseChatMessageHistory;
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -92,36 +92,6 @@ export type ChainValues = Record<string, any>;
|
|
|
92
92
|
export declare abstract class BaseRetriever {
|
|
93
93
|
abstract getRelevantDocuments(query: string): Promise<Document[]>;
|
|
94
94
|
}
|
|
95
|
-
/** Class to parse the output of an LLM call.
|
|
96
|
-
*/
|
|
97
|
-
export declare abstract class BaseOutputParser<T = unknown> {
|
|
98
|
-
/**
|
|
99
|
-
* Parse the output of an LLM call.
|
|
100
|
-
*
|
|
101
|
-
* @param text - LLM output to parse.
|
|
102
|
-
* @returns Parsed output.
|
|
103
|
-
*/
|
|
104
|
-
abstract parse(text: string): Promise<T>;
|
|
105
|
-
parseWithPrompt(text: string, _prompt: BasePromptValue): Promise<T>;
|
|
106
|
-
/**
|
|
107
|
-
* Return a string describing the format of the output.
|
|
108
|
-
* @returns Format instructions.
|
|
109
|
-
* @example
|
|
110
|
-
* ```json
|
|
111
|
-
* {
|
|
112
|
-
* "foo": "bar"
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
abstract getFormatInstructions(): string;
|
|
117
|
-
/**
|
|
118
|
-
* Return the string type key uniquely identifying this class of parser
|
|
119
|
-
*/
|
|
120
|
-
_type(): string;
|
|
121
|
-
}
|
|
122
|
-
export declare class OutputParserException extends Error {
|
|
123
|
-
constructor(message: string);
|
|
124
|
-
}
|
|
125
95
|
export declare abstract class BaseChatMessageHistory {
|
|
126
96
|
abstract getMessages(): Promise<BaseChatMessage[]>;
|
|
127
97
|
abstract addUserMessage(message: string): Promise<void>;
|
package/dist/schema/index.js
CHANGED
|
@@ -58,24 +58,6 @@ export class BasePromptValue {
|
|
|
58
58
|
*/
|
|
59
59
|
export class BaseRetriever {
|
|
60
60
|
}
|
|
61
|
-
/** Class to parse the output of an LLM call.
|
|
62
|
-
*/
|
|
63
|
-
export class BaseOutputParser {
|
|
64
|
-
async parseWithPrompt(text, _prompt) {
|
|
65
|
-
return this.parse(text);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Return the string type key uniquely identifying this class of parser
|
|
69
|
-
*/
|
|
70
|
-
_type() {
|
|
71
|
-
throw new Error("_type not implemented");
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export class OutputParserException extends Error {
|
|
75
|
-
constructor(message) {
|
|
76
|
-
super(message);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
61
|
export class BaseChatMessageHistory {
|
|
80
62
|
}
|
|
81
63
|
export class BaseCache {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutputParserException = exports.BaseOutputParser = void 0;
|
|
4
|
+
/** Class to parse the output of an LLM call.
|
|
5
|
+
*/
|
|
6
|
+
class BaseOutputParser {
|
|
7
|
+
async parseWithPrompt(text, _prompt, callbacks) {
|
|
8
|
+
return this.parse(text, callbacks);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Return the string type key uniquely identifying this class of parser
|
|
12
|
+
*/
|
|
13
|
+
_type() {
|
|
14
|
+
throw new Error("_type not implemented");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.BaseOutputParser = BaseOutputParser;
|
|
18
|
+
class OutputParserException extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.OutputParserException = OutputParserException;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Callbacks } from "../callbacks/manager.js";
|
|
2
|
+
import { BasePromptValue } from "./index.js";
|
|
3
|
+
/** Class to parse the output of an LLM call.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class BaseOutputParser<T = unknown> {
|
|
6
|
+
/**
|
|
7
|
+
* Parse the output of an LLM call.
|
|
8
|
+
*
|
|
9
|
+
* @param text - LLM output to parse.
|
|
10
|
+
* @returns Parsed output.
|
|
11
|
+
*/
|
|
12
|
+
abstract parse(text: string, callbacks?: Callbacks): Promise<T>;
|
|
13
|
+
parseWithPrompt(text: string, _prompt: BasePromptValue, callbacks?: Callbacks): Promise<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Return a string describing the format of the output.
|
|
16
|
+
* @returns Format instructions.
|
|
17
|
+
* @example
|
|
18
|
+
* ```json
|
|
19
|
+
* {
|
|
20
|
+
* "foo": "bar"
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
abstract getFormatInstructions(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Return the string type key uniquely identifying this class of parser
|
|
27
|
+
*/
|
|
28
|
+
_type(): string;
|
|
29
|
+
}
|
|
30
|
+
export declare class OutputParserException extends Error {
|
|
31
|
+
constructor(message: string);
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Class to parse the output of an LLM call.
|
|
2
|
+
*/
|
|
3
|
+
export class BaseOutputParser {
|
|
4
|
+
async parseWithPrompt(text, _prompt, callbacks) {
|
|
5
|
+
return this.parse(text, callbacks);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Return the string type key uniquely identifying this class of parser
|
|
9
|
+
*/
|
|
10
|
+
_type() {
|
|
11
|
+
throw new Error("_type not implemented");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class OutputParserException extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/dist/tools/base.cjs
CHANGED
|
@@ -5,8 +5,8 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const manager_js_1 = require("../callbacks/manager.cjs");
|
|
6
6
|
const index_js_1 = require("../base_language/index.cjs");
|
|
7
7
|
class StructuredTool extends index_js_1.BaseLangChain {
|
|
8
|
-
constructor(
|
|
9
|
-
super(
|
|
8
|
+
constructor(fields) {
|
|
9
|
+
super(fields ?? {});
|
|
10
10
|
Object.defineProperty(this, "returnDirect", {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
configurable: true,
|
|
@@ -32,8 +32,8 @@ class StructuredTool extends index_js_1.BaseLangChain {
|
|
|
32
32
|
}
|
|
33
33
|
exports.StructuredTool = StructuredTool;
|
|
34
34
|
class Tool extends StructuredTool {
|
|
35
|
-
constructor() {
|
|
36
|
-
super(
|
|
35
|
+
constructor(verbose, callbacks) {
|
|
36
|
+
super({ verbose, callbacks });
|
|
37
37
|
Object.defineProperty(this, "schema", {
|
|
38
38
|
enumerable: true,
|
|
39
39
|
configurable: true,
|
package/dist/tools/base.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { CallbackManagerForToolRun, Callbacks } from "../callbacks/manager.js";
|
|
3
3
|
import { BaseLangChain, BaseLangChainParams } from "../base_language/index.js";
|
|
4
4
|
export interface ToolParams extends BaseLangChainParams {
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use `callbacks` instead
|
|
7
|
-
*/
|
|
8
|
-
callbackManager?: CallbackManager;
|
|
9
5
|
}
|
|
10
6
|
export declare abstract class StructuredTool<T extends z.ZodObject<any, any, any, any> = z.ZodObject<any, any, any, any>> extends BaseLangChain {
|
|
11
7
|
abstract schema: T | z.ZodEffects<T>;
|
|
12
|
-
constructor(
|
|
13
|
-
protected abstract _call(arg: z.output<T>,
|
|
8
|
+
constructor(fields?: ToolParams);
|
|
9
|
+
protected abstract _call(arg: z.output<T>, runManager?: CallbackManagerForToolRun): Promise<string>;
|
|
14
10
|
call(arg: (z.output<T> extends string ? string : never) | z.input<T>, callbacks?: Callbacks): Promise<string>;
|
|
15
11
|
abstract name: string;
|
|
16
12
|
abstract description: string;
|
|
@@ -26,5 +22,6 @@ export declare abstract class Tool extends StructuredTool {
|
|
|
26
22
|
}>, string | undefined, {
|
|
27
23
|
input?: string | undefined;
|
|
28
24
|
}>;
|
|
25
|
+
constructor(verbose?: boolean, callbacks?: Callbacks);
|
|
29
26
|
call(arg: string | undefined | z.input<this["schema"]>, callbacks?: Callbacks): Promise<string>;
|
|
30
27
|
}
|
package/dist/tools/base.js
CHANGED
|
@@ -2,8 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
import { CallbackManager, } from "../callbacks/manager.js";
|
|
3
3
|
import { BaseLangChain } from "../base_language/index.js";
|
|
4
4
|
export class StructuredTool extends BaseLangChain {
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
5
|
+
constructor(fields) {
|
|
6
|
+
super(fields ?? {});
|
|
7
7
|
Object.defineProperty(this, "returnDirect", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
configurable: true,
|
|
@@ -28,8 +28,8 @@ export class StructuredTool extends BaseLangChain {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
export class Tool extends StructuredTool {
|
|
31
|
-
constructor() {
|
|
32
|
-
super(
|
|
31
|
+
constructor(verbose, callbacks) {
|
|
32
|
+
super({ verbose, callbacks });
|
|
33
33
|
Object.defineProperty(this, "schema", {
|
|
34
34
|
enumerable: true,
|
|
35
35
|
configurable: true,
|
package/dist/tools/fs.cjs
CHANGED
|
@@ -4,8 +4,8 @@ exports.WriteFileTool = exports.ReadFileTool = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const base_js_1 = require("./base.cjs");
|
|
6
6
|
class ReadFileTool extends base_js_1.StructuredTool {
|
|
7
|
-
constructor({
|
|
8
|
-
super(
|
|
7
|
+
constructor({ store, ...rest }) {
|
|
8
|
+
super(rest);
|
|
9
9
|
Object.defineProperty(this, "schema", {
|
|
10
10
|
enumerable: true,
|
|
11
11
|
configurable: true,
|
|
@@ -40,8 +40,8 @@ class ReadFileTool extends base_js_1.StructuredTool {
|
|
|
40
40
|
}
|
|
41
41
|
exports.ReadFileTool = ReadFileTool;
|
|
42
42
|
class WriteFileTool extends base_js_1.StructuredTool {
|
|
43
|
-
constructor({
|
|
44
|
-
super(
|
|
43
|
+
constructor({ store, ...rest }) {
|
|
44
|
+
super(rest);
|
|
45
45
|
Object.defineProperty(this, "schema", {
|
|
46
46
|
enumerable: true,
|
|
47
47
|
configurable: true,
|
package/dist/tools/fs.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class ReadFileTool extends StructuredTool {
|
|
|
15
15
|
name: string;
|
|
16
16
|
description: string;
|
|
17
17
|
store: BaseFileStore;
|
|
18
|
-
constructor({
|
|
18
|
+
constructor({ store, ...rest }: ReadFileParams);
|
|
19
19
|
_call({ file_path }: z.infer<typeof this.schema>): Promise<string>;
|
|
20
20
|
}
|
|
21
21
|
interface WriteFileParams extends ToolParams {
|
|
@@ -35,7 +35,7 @@ export declare class WriteFileTool extends StructuredTool {
|
|
|
35
35
|
name: string;
|
|
36
36
|
description: string;
|
|
37
37
|
store: BaseFileStore;
|
|
38
|
-
constructor({
|
|
38
|
+
constructor({ store, ...rest }: WriteFileParams);
|
|
39
39
|
_call({ file_path, text }: z.infer<typeof this.schema>): Promise<string>;
|
|
40
40
|
}
|
|
41
41
|
export {};
|
package/dist/tools/fs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { StructuredTool } from "./base.js";
|
|
3
3
|
export class ReadFileTool extends StructuredTool {
|
|
4
|
-
constructor({
|
|
5
|
-
super(
|
|
4
|
+
constructor({ store, ...rest }) {
|
|
5
|
+
super(rest);
|
|
6
6
|
Object.defineProperty(this, "schema", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
configurable: true,
|
|
@@ -36,8 +36,8 @@ export class ReadFileTool extends StructuredTool {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
export class WriteFileTool extends StructuredTool {
|
|
39
|
-
constructor({
|
|
40
|
-
super(
|
|
39
|
+
constructor({ store, ...rest }) {
|
|
40
|
+
super(rest);
|
|
41
41
|
Object.defineProperty(this, "schema", {
|
|
42
42
|
enumerable: true,
|
|
43
43
|
configurable: true,
|