langchain 0.0.209 → 0.0.210
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.d.ts +8 -8
- package/dist/agents/chat/index.cjs +1 -1
- package/dist/agents/chat/index.d.ts +7 -7
- package/dist/agents/chat/index.js +1 -1
- package/dist/agents/chat_convo/index.d.ts +6 -6
- package/dist/agents/chat_convo/outputParser.cjs +3 -3
- package/dist/agents/chat_convo/outputParser.d.ts +5 -5
- package/dist/agents/chat_convo/outputParser.js +3 -3
- package/dist/agents/executor.cjs +6 -6
- package/dist/agents/executor.d.ts +5 -5
- package/dist/agents/executor.js +1 -1
- package/dist/agents/helpers.d.ts +3 -3
- package/dist/agents/initialize.d.ts +5 -5
- package/dist/agents/load.d.ts +4 -4
- package/dist/agents/mrkl/index.d.ts +8 -8
- package/dist/agents/openai/index.d.ts +6 -6
- package/dist/agents/structured_chat/index.d.ts +6 -6
- package/dist/agents/structured_chat/outputParser.d.ts +2 -2
- package/dist/agents/toolkits/aws_sfn.d.ts +2 -2
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.ts +2 -2
- package/dist/agents/toolkits/conversational_retrieval/tool.d.ts +2 -2
- package/dist/agents/toolkits/json/json.d.ts +4 -4
- package/dist/agents/toolkits/openapi/openapi.d.ts +5 -5
- package/dist/agents/toolkits/sql/sql.d.ts +5 -5
- package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +12 -12
- package/dist/agents/toolkits/zapier/zapier.d.ts +2 -2
- package/dist/agents/xml/index.d.ts +5 -5
- package/dist/base_language/index.d.ts +1 -1
- package/dist/chains/api/api_chain.d.ts +2 -2
- package/dist/chains/chat_vector_db_chain.d.ts +5 -5
- package/dist/chains/combine_docs_chain.d.ts +1 -1
- package/dist/chains/constitutional_ai/constitutional_chain.d.ts +2 -2
- package/dist/chains/conversational_retrieval_chain.cjs +2 -2
- package/dist/chains/conversational_retrieval_chain.d.ts +8 -8
- package/dist/chains/conversational_retrieval_chain.js +2 -2
- package/dist/chains/graph_qa/cypher.d.ts +4 -4
- package/dist/chains/llm_chain.cjs +2 -2
- package/dist/chains/llm_chain.d.ts +8 -5
- package/dist/chains/llm_chain.js +1 -1
- package/dist/chains/query_constructor/index.d.ts +3 -3
- package/dist/chains/question_answering/load.d.ts +7 -7
- package/dist/chains/retrieval_qa.d.ts +5 -5
- package/dist/chains/router/llm_router.d.ts +2 -2
- package/dist/chains/router/multi_prompt.d.ts +3 -3
- package/dist/chains/router/multi_retrieval_qa.cjs +1 -1
- package/dist/chains/router/multi_retrieval_qa.d.ts +7 -7
- package/dist/chains/router/multi_retrieval_qa.js +1 -1
- package/dist/chains/sql_db/sql_db_chain.d.ts +3 -3
- package/dist/chains/summarization/load.d.ts +4 -4
- package/dist/chains/vector_db_qa.d.ts +5 -5
- package/dist/embeddings/cache_backed.cjs +2 -2
- package/dist/embeddings/cache_backed.d.ts +4 -4
- package/dist/embeddings/cache_backed.js +1 -1
- package/dist/evaluation/agents/trajectory.d.ts +4 -4
- package/dist/evaluation/base.d.ts +4 -4
- package/dist/evaluation/comparison/pairwise.d.ts +4 -4
- package/dist/evaluation/criteria/criteria.d.ts +4 -4
- package/dist/evaluation/embedding_distance/base.d.ts +4 -4
- package/dist/evaluation/loader.d.ts +4 -4
- package/dist/evaluation/qa/eval_chain.d.ts +2 -2
- package/dist/experimental/autogpt/agent.d.ts +3 -3
- package/dist/experimental/autogpt/prompt.d.ts +2 -2
- package/dist/experimental/babyagi/agent.d.ts +5 -5
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.d.ts +4 -4
- package/dist/experimental/chat_models/anthropic_functions.d.ts +2 -2
- package/dist/experimental/generative_agents/generative_agent.d.ts +3 -3
- package/dist/experimental/generative_agents/generative_agent_memory.d.ts +5 -5
- package/dist/experimental/hubs/makersuite/googlemakersuitehub.d.ts +1 -1
- package/dist/experimental/plan_and_execute/agent_executor.d.ts +4 -4
- package/dist/llms/load.cjs +2 -2
- package/dist/llms/load.d.ts +1 -1
- package/dist/llms/load.js +1 -1
- package/dist/memory/buffer_token_memory.d.ts +3 -3
- package/dist/memory/entity_memory.d.ts +3 -3
- package/dist/memory/summary.d.ts +3 -3
- package/dist/memory/vector_store.d.ts +3 -3
- package/dist/output_parsers/fix.d.ts +2 -2
- package/dist/retrievers/contextual_compression.cjs +2 -2
- package/dist/retrievers/contextual_compression.d.ts +5 -5
- package/dist/retrievers/contextual_compression.js +1 -1
- package/dist/retrievers/document_compressors/chain_extract.cjs +2 -2
- package/dist/retrievers/document_compressors/chain_extract.d.ts +6 -6
- package/dist/retrievers/document_compressors/chain_extract.js +1 -1
- package/dist/retrievers/document_compressors/embeddings_filter.d.ts +5 -5
- package/dist/retrievers/document_compressors/index.d.ts +3 -3
- package/dist/retrievers/hyde.d.ts +3 -3
- package/dist/retrievers/multi_query.cjs +2 -2
- package/dist/retrievers/multi_query.d.ts +4 -4
- package/dist/retrievers/multi_query.js +1 -1
- package/dist/retrievers/multi_vector.cjs +2 -2
- package/dist/retrievers/multi_vector.d.ts +4 -4
- package/dist/retrievers/multi_vector.js +1 -1
- package/dist/retrievers/parent_document.d.ts +4 -4
- package/dist/retrievers/remote/base.cjs +2 -2
- package/dist/retrievers/remote/base.d.ts +1 -1
- package/dist/retrievers/remote/base.js +1 -1
- package/dist/retrievers/self_query/index.cjs +2 -2
- package/dist/retrievers/self_query/index.d.ts +1 -1
- package/dist/retrievers/self_query/index.js +1 -1
- package/dist/retrievers/time_weighted.cjs +2 -2
- package/dist/retrievers/time_weighted.d.ts +9 -9
- package/dist/retrievers/time_weighted.js +1 -1
- package/dist/schema/runnable/base.d.ts +1 -1
- package/dist/tools/convert_to_openai.d.ts +4 -4
- package/dist/tools/render.d.ts +3 -3
- package/dist/tools/sql.d.ts +2 -2
- package/dist/tools/vectorstore.d.ts +6 -6
- package/dist/tools/webbrowser.cjs +4 -4
- package/dist/tools/webbrowser.d.ts +4 -4
- package/dist/tools/webbrowser.js +1 -1
- package/dist/util/googlevertexai-connection.d.ts +1 -1
- package/dist/vectorstores/memory.d.ts +5 -5
- package/dist/vectorstores/mongo.d.ts +4 -4
- package/package.json +4 -4
package/dist/llms/load.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BaseLanguageModel } from "
|
|
1
|
+
import { BaseLanguageModel } from "@langchain/core/language_models/base";
|
|
2
2
|
export declare const loadLLM: (uri: string) => Promise<BaseLanguageModel>;
|
package/dist/llms/load.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { BaseLanguageModel } from "@langchain/core/language_models/base";
|
|
1
2
|
import { loadFromFile } from "../util/load.js";
|
|
2
|
-
import { BaseLanguageModel } from "../base_language/index.js";
|
|
3
3
|
import { parseFileConfig } from "../util/parse.js";
|
|
4
4
|
/**
|
|
5
5
|
* Load an LLM from a local file.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
1
2
|
import { InputValues, MemoryVariables, OutputValues } from "./base.js";
|
|
2
3
|
import { BaseChatMemory, BaseChatMemoryInput } from "./chat_memory.js";
|
|
3
|
-
import { BaseLanguageModel } from "../base_language/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Interface for the input parameters of the `BufferTokenMemory` class.
|
|
6
6
|
*/
|
|
7
7
|
export interface ConversationTokenBufferMemoryInput extends BaseChatMemoryInput {
|
|
8
8
|
humanPrefix?: string;
|
|
9
9
|
aiPrefix?: string;
|
|
10
|
-
llm:
|
|
10
|
+
llm: BaseLanguageModelInterface;
|
|
11
11
|
memoryKey?: string;
|
|
12
12
|
maxTokenLimit?: number;
|
|
13
13
|
}
|
|
@@ -36,7 +36,7 @@ export declare class ConversationTokenBufferMemory extends BaseChatMemory implem
|
|
|
36
36
|
aiPrefix: string;
|
|
37
37
|
memoryKey: string;
|
|
38
38
|
maxTokenLimit: number;
|
|
39
|
-
llm:
|
|
39
|
+
llm: BaseLanguageModelInterface;
|
|
40
40
|
constructor(fields: ConversationTokenBufferMemoryInput);
|
|
41
41
|
get memoryKeys(): string[];
|
|
42
42
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
2
2
|
import { BaseEntityStore } from "../schema/index.js";
|
|
3
3
|
import { BaseChatMemory, BaseChatMemoryInput } from "./chat_memory.js";
|
|
4
4
|
import { InputValues, MemoryVariables, OutputValues } from "./base.js";
|
|
@@ -7,7 +7,7 @@ import { PromptTemplate } from "../prompts/prompt.js";
|
|
|
7
7
|
* Interface for the input parameters required by the EntityMemory class.
|
|
8
8
|
*/
|
|
9
9
|
export interface EntityMemoryInput extends BaseChatMemoryInput {
|
|
10
|
-
llm:
|
|
10
|
+
llm: BaseLanguageModelInterface;
|
|
11
11
|
humanPrefix?: string;
|
|
12
12
|
aiPrefix?: string;
|
|
13
13
|
entityExtractionPrompt?: PromptTemplate;
|
|
@@ -59,7 +59,7 @@ export declare class EntityMemory extends BaseChatMemory implements EntityMemory
|
|
|
59
59
|
entityCache: string[];
|
|
60
60
|
k: number;
|
|
61
61
|
chatHistoryKey: string;
|
|
62
|
-
llm:
|
|
62
|
+
llm: BaseLanguageModelInterface;
|
|
63
63
|
entitiesKey: string;
|
|
64
64
|
humanPrefix?: string;
|
|
65
65
|
aiPrefix?: string;
|
package/dist/memory/summary.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
2
2
|
import { BasePromptTemplate } from "../prompts/base.js";
|
|
3
3
|
import { BaseMessage } from "../schema/index.js";
|
|
4
4
|
import { InputValues, MemoryVariables, OutputValues } from "./base.js";
|
|
@@ -14,7 +14,7 @@ export interface ConversationSummaryMemoryInput extends BaseConversationSummaryM
|
|
|
14
14
|
* class.
|
|
15
15
|
*/
|
|
16
16
|
export interface BaseConversationSummaryMemoryInput extends BaseChatMemoryInput {
|
|
17
|
-
llm:
|
|
17
|
+
llm: BaseLanguageModelInterface;
|
|
18
18
|
memoryKey?: string;
|
|
19
19
|
humanPrefix?: string;
|
|
20
20
|
aiPrefix?: string;
|
|
@@ -30,7 +30,7 @@ export declare abstract class BaseConversationSummaryMemory extends BaseChatMemo
|
|
|
30
30
|
memoryKey: string;
|
|
31
31
|
humanPrefix: string;
|
|
32
32
|
aiPrefix: string;
|
|
33
|
-
llm:
|
|
33
|
+
llm: BaseLanguageModelInterface;
|
|
34
34
|
prompt: BasePromptTemplate;
|
|
35
35
|
summaryChatMessageClass: new (content: string) => BaseMessage;
|
|
36
36
|
constructor(fields: BaseConversationSummaryMemoryInput);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VectorStoreRetrieverInterface } from "@langchain/core/vectorstores";
|
|
2
2
|
import { BaseMemory, InputValues, MemoryVariables, OutputValues } from "./base.js";
|
|
3
3
|
/**
|
|
4
4
|
* Interface for the parameters required to initialize a
|
|
5
5
|
* VectorStoreRetrieverMemory instance.
|
|
6
6
|
*/
|
|
7
7
|
export interface VectorStoreRetrieverMemoryParams {
|
|
8
|
-
vectorStoreRetriever:
|
|
8
|
+
vectorStoreRetriever: VectorStoreRetrieverInterface;
|
|
9
9
|
inputKey?: string;
|
|
10
10
|
outputKey?: string;
|
|
11
11
|
memoryKey?: string;
|
|
@@ -43,7 +43,7 @@ export interface VectorStoreRetrieverMemoryParams {
|
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
45
|
export declare class VectorStoreRetrieverMemory extends BaseMemory implements VectorStoreRetrieverMemoryParams {
|
|
46
|
-
vectorStoreRetriever:
|
|
46
|
+
vectorStoreRetriever: VectorStoreRetrieverInterface;
|
|
47
47
|
inputKey?: string;
|
|
48
48
|
memoryKey: string;
|
|
49
49
|
returnDocs: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
1
2
|
import { BaseOutputParser } from "../schema/output_parser.js";
|
|
2
3
|
import { BasePromptTemplate } from "../prompts/base.js";
|
|
3
4
|
import { LLMChain } from "../chains/llm_chain.js";
|
|
4
|
-
import { BaseLanguageModel } from "../base_language/index.js";
|
|
5
5
|
import { Callbacks } from "../callbacks/manager.js";
|
|
6
6
|
/**
|
|
7
7
|
* Class that extends the BaseOutputParser to handle situations where the
|
|
@@ -22,7 +22,7 @@ export declare class OutputFixingParser<T> extends BaseOutputParser<T> {
|
|
|
22
22
|
* @param fields Optional fields which may contain a prompt.
|
|
23
23
|
* @returns A new instance of OutputFixingParser.
|
|
24
24
|
*/
|
|
25
|
-
static fromLLM<T>(llm:
|
|
25
|
+
static fromLLM<T>(llm: BaseLanguageModelInterface, parser: BaseOutputParser<T>, fields?: {
|
|
26
26
|
prompt?: BasePromptTemplate;
|
|
27
27
|
}): OutputFixingParser<T>;
|
|
28
28
|
constructor({ parser, retryChain, }: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextualCompressionRetriever = void 0;
|
|
4
|
-
const
|
|
4
|
+
const retrievers_1 = require("@langchain/core/retrievers");
|
|
5
5
|
/**
|
|
6
6
|
* A retriever that wraps a base retriever and compresses the results. It
|
|
7
7
|
* retrieves relevant documents based on a given query and then compresses
|
|
@@ -17,7 +17,7 @@ const retriever_js_1 = require("../schema/retriever.cjs");
|
|
|
17
17
|
* );
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
class ContextualCompressionRetriever extends
|
|
20
|
+
class ContextualCompressionRetriever extends retrievers_1.BaseRetriever {
|
|
21
21
|
static lc_name() {
|
|
22
22
|
return "ContextualCompressionRetriever";
|
|
23
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { BaseRetriever, type BaseRetrieverInput, type BaseRetrieverInterface } from "@langchain/core/retrievers";
|
|
2
|
+
import type { DocumentInterface } from "@langchain/core/documents";
|
|
1
3
|
import { BaseDocumentCompressor } from "./document_compressors/index.js";
|
|
2
|
-
import { Document } from "../document.js";
|
|
3
|
-
import { BaseRetriever, BaseRetrieverInput } from "../schema/retriever.js";
|
|
4
4
|
import { CallbackManagerForRetrieverRun } from "../callbacks/manager.js";
|
|
5
5
|
/**
|
|
6
6
|
* Interface for the arguments required to construct a
|
|
@@ -9,7 +9,7 @@ import { CallbackManagerForRetrieverRun } from "../callbacks/manager.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export interface ContextualCompressionRetrieverArgs extends BaseRetrieverInput {
|
|
11
11
|
baseCompressor: BaseDocumentCompressor;
|
|
12
|
-
baseRetriever:
|
|
12
|
+
baseRetriever: BaseRetrieverInterface;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* A retriever that wraps a base retriever and compresses the results. It
|
|
@@ -30,7 +30,7 @@ export declare class ContextualCompressionRetriever extends BaseRetriever {
|
|
|
30
30
|
static lc_name(): string;
|
|
31
31
|
lc_namespace: string[];
|
|
32
32
|
baseCompressor: BaseDocumentCompressor;
|
|
33
|
-
baseRetriever:
|
|
33
|
+
baseRetriever: BaseRetrieverInterface;
|
|
34
34
|
constructor(fields: ContextualCompressionRetrieverArgs);
|
|
35
|
-
_getRelevantDocuments(query: string, runManager?: CallbackManagerForRetrieverRun): Promise<
|
|
35
|
+
_getRelevantDocuments(query: string, runManager?: CallbackManagerForRetrieverRun): Promise<DocumentInterface[]>;
|
|
36
36
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseRetriever } from "
|
|
1
|
+
import { BaseRetriever, } from "@langchain/core/retrievers";
|
|
2
2
|
/**
|
|
3
3
|
* A retriever that wraps a base retriever and compresses the results. It
|
|
4
4
|
* retrieves relevant documents based on a given query and then compresses
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LLMChainExtractor = void 0;
|
|
4
|
-
const
|
|
4
|
+
const documents_1 = require("@langchain/core/documents");
|
|
5
5
|
const llm_chain_js_1 = require("../../chains/llm_chain.cjs");
|
|
6
6
|
const index_js_1 = require("../../prompts/index.cjs");
|
|
7
7
|
const output_parser_js_1 = require("../../schema/output_parser.cjs");
|
|
@@ -84,7 +84,7 @@ class LLMChainExtractor extends index_js_2.BaseDocumentCompressor {
|
|
|
84
84
|
const input = this.getInput(query, doc);
|
|
85
85
|
const output = await this.llmChain.predict(input);
|
|
86
86
|
return output.length > 0
|
|
87
|
-
? new
|
|
87
|
+
? new documents_1.Document({
|
|
88
88
|
pageContent: output,
|
|
89
89
|
metadata: doc.metadata,
|
|
90
90
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
2
|
+
import { type DocumentInterface } from "@langchain/core/documents";
|
|
2
3
|
import { LLMChain } from "../../chains/llm_chain.js";
|
|
3
4
|
import { PromptTemplate } from "../../prompts/index.js";
|
|
4
|
-
import { BaseLanguageModel } from "../../base_language/index.js";
|
|
5
5
|
import { BaseDocumentCompressor } from "./index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Interface for the arguments required to create an instance of
|
|
@@ -9,7 +9,7 @@ import { BaseDocumentCompressor } from "./index.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export interface LLMChainExtractorArgs {
|
|
11
11
|
llmChain: LLMChain;
|
|
12
|
-
getInput: (query: string, doc:
|
|
12
|
+
getInput: (query: string, doc: DocumentInterface) => Record<string, unknown>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* A class that uses an LLM chain to extract relevant parts of documents.
|
|
@@ -17,7 +17,7 @@ export interface LLMChainExtractorArgs {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare class LLMChainExtractor extends BaseDocumentCompressor {
|
|
19
19
|
llmChain: LLMChain;
|
|
20
|
-
getInput: (query: string, doc:
|
|
20
|
+
getInput: (query: string, doc: DocumentInterface) => Record<string, unknown>;
|
|
21
21
|
constructor({ llmChain, getInput }: LLMChainExtractorArgs);
|
|
22
22
|
/**
|
|
23
23
|
* Compresses a list of documents based on the output of an LLM chain.
|
|
@@ -25,7 +25,7 @@ export declare class LLMChainExtractor extends BaseDocumentCompressor {
|
|
|
25
25
|
* @param query The query to be used for document compression.
|
|
26
26
|
* @returns A list of compressed documents.
|
|
27
27
|
*/
|
|
28
|
-
compressDocuments(documents:
|
|
28
|
+
compressDocuments(documents: DocumentInterface[], query: string): Promise<DocumentInterface[]>;
|
|
29
29
|
/**
|
|
30
30
|
* Creates a new instance of LLMChainExtractor from a given LLM, prompt
|
|
31
31
|
* template, and getInput function.
|
|
@@ -34,5 +34,5 @@ export declare class LLMChainExtractor extends BaseDocumentCompressor {
|
|
|
34
34
|
* @param getInput A function used for constructing the chain input from the query and a Document.
|
|
35
35
|
* @returns A new instance of LLMChainExtractor.
|
|
36
36
|
*/
|
|
37
|
-
static fromLLM(llm:
|
|
37
|
+
static fromLLM(llm: BaseLanguageModelInterface, prompt?: PromptTemplate, getInput?: (query: string, doc: DocumentInterface) => Record<string, unknown>): LLMChainExtractor;
|
|
38
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Document } from "
|
|
1
|
+
import { Document } from "@langchain/core/documents";
|
|
2
2
|
import { LLMChain } from "../../chains/llm_chain.js";
|
|
3
3
|
import { PromptTemplate } from "../../prompts/index.js";
|
|
4
4
|
import { BaseOutputParser } from "../../schema/output_parser.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { EmbeddingsInterface } from "@langchain/core/embeddings";
|
|
2
|
+
import type { DocumentInterface } from "@langchain/core/documents";
|
|
3
3
|
import { BaseDocumentCompressor } from "./index.js";
|
|
4
4
|
import { cosineSimilarity } from "../../util/math.js";
|
|
5
5
|
/**
|
|
6
6
|
* Interface for the parameters of the `EmbeddingsFilter` class.
|
|
7
7
|
*/
|
|
8
8
|
export interface EmbeddingsFilterParams {
|
|
9
|
-
embeddings:
|
|
9
|
+
embeddings: EmbeddingsInterface;
|
|
10
10
|
similarityFn?: (x: number[][], y: number[][]) => number[][];
|
|
11
11
|
similarityThreshold?: number;
|
|
12
12
|
k?: number;
|
|
@@ -32,7 +32,7 @@ export declare class EmbeddingsFilter extends BaseDocumentCompressor {
|
|
|
32
32
|
/**
|
|
33
33
|
* Embeddings to use for embedding document contents and queries.
|
|
34
34
|
*/
|
|
35
|
-
embeddings:
|
|
35
|
+
embeddings: EmbeddingsInterface;
|
|
36
36
|
/**
|
|
37
37
|
* Similarity function for comparing documents.
|
|
38
38
|
*/
|
|
@@ -48,5 +48,5 @@ export declare class EmbeddingsFilter extends BaseDocumentCompressor {
|
|
|
48
48
|
*/
|
|
49
49
|
k?: number | undefined;
|
|
50
50
|
constructor(params: EmbeddingsFilterParams);
|
|
51
|
-
compressDocuments(documents:
|
|
51
|
+
compressDocuments(documents: DocumentInterface[], query: string): Promise<DocumentInterface[]>;
|
|
52
52
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DocumentInterface } from "@langchain/core/documents";
|
|
2
2
|
import { BaseDocumentTransformer } from "../../schema/document.js";
|
|
3
3
|
import { Callbacks } from "../../callbacks/manager.js";
|
|
4
4
|
/**
|
|
@@ -14,7 +14,7 @@ export declare abstract class BaseDocumentCompressor {
|
|
|
14
14
|
* @param query A query string.
|
|
15
15
|
* @returns A Promise that resolves with an array of compressed `Document` objects.
|
|
16
16
|
*/
|
|
17
|
-
abstract compressDocuments(documents:
|
|
17
|
+
abstract compressDocuments(documents: DocumentInterface[], query: string, callbacks?: Callbacks): Promise<DocumentInterface[]>;
|
|
18
18
|
static isBaseDocumentCompressor(x: any): x is BaseDocumentCompressor;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -51,5 +51,5 @@ export declare class DocumentCompressorPipeline extends BaseDocumentCompressor {
|
|
|
51
51
|
constructor(fields: {
|
|
52
52
|
transformers: (BaseDocumentTransformer | BaseDocumentCompressor)[];
|
|
53
53
|
});
|
|
54
|
-
compressDocuments(documents:
|
|
54
|
+
compressDocuments(documents: DocumentInterface[], query: string, callbacks?: Callbacks): Promise<DocumentInterface[]>;
|
|
55
55
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
1
2
|
import { Document } from "../document.js";
|
|
2
3
|
import { BasePromptTemplate } from "../prompts/base.js";
|
|
3
4
|
import { VectorStore, VectorStoreRetriever, VectorStoreRetrieverInput } from "../vectorstores/base.js";
|
|
4
|
-
import { BaseLanguageModel } from "../base_language/index.js";
|
|
5
5
|
import { CallbackManagerForRetrieverRun } from "../callbacks/manager.js";
|
|
6
6
|
/**
|
|
7
7
|
* A string that corresponds to a specific prompt template.
|
|
@@ -13,7 +13,7 @@ export type PromptKey = "websearch" | "scifact" | "arguana" | "trec-covid" | "fi
|
|
|
13
13
|
* can either be a BasePromptTemplate instance or a PromptKey.
|
|
14
14
|
*/
|
|
15
15
|
export type HydeRetrieverOptions<V extends VectorStore> = VectorStoreRetrieverInput<V> & {
|
|
16
|
-
llm:
|
|
16
|
+
llm: BaseLanguageModelInterface;
|
|
17
17
|
promptTemplate?: BasePromptTemplate | PromptKey;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
@@ -44,7 +44,7 @@ export type HydeRetrieverOptions<V extends VectorStore> = VectorStoreRetrieverIn
|
|
|
44
44
|
export declare class HydeRetriever<V extends VectorStore = VectorStore> extends VectorStoreRetriever<V> {
|
|
45
45
|
static lc_name(): string;
|
|
46
46
|
get lc_namespace(): string[];
|
|
47
|
-
llm:
|
|
47
|
+
llm: BaseLanguageModelInterface;
|
|
48
48
|
promptTemplate?: BasePromptTemplate;
|
|
49
49
|
constructor(fields: HydeRetrieverOptions<V>);
|
|
50
50
|
_getRelevantDocuments(query: string, runManager?: CallbackManagerForRetrieverRun): Promise<Document[]>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MultiQueryRetriever = void 0;
|
|
4
|
+
const retrievers_1 = require("@langchain/core/retrievers");
|
|
4
5
|
const llm_chain_js_1 = require("../chains/llm_chain.cjs");
|
|
5
6
|
const prompt_js_1 = require("../prompts/prompt.cjs");
|
|
6
7
|
const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
7
|
-
const retriever_js_1 = require("../schema/retriever.cjs");
|
|
8
8
|
class LineListOutputParser extends output_parser_js_1.BaseOutputParser {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
@@ -67,7 +67,7 @@ Original question: {question}`,
|
|
|
67
67
|
* );
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
|
-
class MultiQueryRetriever extends
|
|
70
|
+
class MultiQueryRetriever extends retrievers_1.BaseRetriever {
|
|
71
71
|
static lc_name() {
|
|
72
72
|
return "MultiQueryRetriever";
|
|
73
73
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
2
|
+
import { BaseRetriever, type BaseRetrieverInput, type BaseRetrieverInterface } from "@langchain/core/retrievers";
|
|
1
3
|
import { LLMChain } from "../chains/llm_chain.js";
|
|
2
4
|
import { Document } from "../document.js";
|
|
3
|
-
import { BaseRetriever, BaseRetrieverInput } from "../schema/retriever.js";
|
|
4
5
|
import { CallbackManagerForRetrieverRun } from "../callbacks/index.js";
|
|
5
|
-
import { BaseLanguageModel } from "../base_language/index.js";
|
|
6
6
|
import { BasePromptTemplate } from "../prompts/base.js";
|
|
7
7
|
interface LineList {
|
|
8
8
|
lines: string[];
|
|
9
9
|
}
|
|
10
10
|
export interface MultiQueryRetrieverInput extends BaseRetrieverInput {
|
|
11
|
-
retriever:
|
|
11
|
+
retriever: BaseRetrieverInterface;
|
|
12
12
|
llmChain: LLMChain<LineList>;
|
|
13
13
|
queryCount?: number;
|
|
14
14
|
parserKey?: string;
|
|
@@ -35,7 +35,7 @@ export declare class MultiQueryRetriever extends BaseRetriever {
|
|
|
35
35
|
private parserKey;
|
|
36
36
|
constructor(fields: MultiQueryRetrieverInput);
|
|
37
37
|
static fromLLM(fields: Omit<MultiQueryRetrieverInput, "llmChain"> & {
|
|
38
|
-
llm:
|
|
38
|
+
llm: BaseLanguageModelInterface;
|
|
39
39
|
prompt?: BasePromptTemplate;
|
|
40
40
|
}): MultiQueryRetriever;
|
|
41
41
|
private _generateQueries;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BaseRetriever, } from "@langchain/core/retrievers";
|
|
1
2
|
import { LLMChain } from "../chains/llm_chain.js";
|
|
2
3
|
import { PromptTemplate } from "../prompts/prompt.js";
|
|
3
4
|
import { BaseOutputParser } from "../schema/output_parser.js";
|
|
4
|
-
import { BaseRetriever } from "../schema/retriever.js";
|
|
5
5
|
class LineListOutputParser extends BaseOutputParser {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MultiVectorRetriever = void 0;
|
|
4
|
-
const
|
|
4
|
+
const retrievers_1 = require("@langchain/core/retrievers");
|
|
5
5
|
/**
|
|
6
6
|
* A retriever that retrieves documents from a vector store and a document
|
|
7
7
|
* store. It uses the vector store to find relevant documents based on a
|
|
@@ -20,7 +20,7 @@ const retriever_js_1 = require("../schema/retriever.cjs");
|
|
|
20
20
|
* console.log(retrieverResult[0].pageContent.length);
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
class MultiVectorRetriever extends
|
|
23
|
+
class MultiVectorRetriever extends retrievers_1.BaseRetriever {
|
|
24
24
|
static lc_name() {
|
|
25
25
|
return "MultiVectorRetriever";
|
|
26
26
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { BaseRetriever, type BaseRetrieverInput } from "@langchain/core/retrievers";
|
|
2
|
+
import type { VectorStoreInterface } from "@langchain/core/vectorstores";
|
|
1
3
|
import { BaseStoreInterface } from "../schema/storage.js";
|
|
2
4
|
import { Document } from "../document.js";
|
|
3
|
-
import { BaseRetriever, BaseRetrieverInput } from "../schema/retriever.js";
|
|
4
|
-
import { VectorStore } from "../vectorstores/base.js";
|
|
5
5
|
/**
|
|
6
6
|
* Arguments for the MultiVectorRetriever class.
|
|
7
7
|
*/
|
|
8
8
|
export interface MultiVectorRetrieverInput extends BaseRetrieverInput {
|
|
9
|
-
vectorstore:
|
|
9
|
+
vectorstore: VectorStoreInterface;
|
|
10
10
|
docstore: BaseStoreInterface<string, Document>;
|
|
11
11
|
idKey?: string;
|
|
12
12
|
childK?: number;
|
|
@@ -33,7 +33,7 @@ export interface MultiVectorRetrieverInput extends BaseRetrieverInput {
|
|
|
33
33
|
export declare class MultiVectorRetriever extends BaseRetriever {
|
|
34
34
|
static lc_name(): string;
|
|
35
35
|
lc_namespace: string[];
|
|
36
|
-
vectorstore:
|
|
36
|
+
vectorstore: VectorStoreInterface;
|
|
37
37
|
docstore: BaseStoreInterface<string, Document>;
|
|
38
38
|
protected idKey: string;
|
|
39
39
|
protected childK?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseRetriever } from "
|
|
1
|
+
import { BaseRetriever, } from "@langchain/core/retrievers";
|
|
2
2
|
/**
|
|
3
3
|
* A retriever that retrieves documents from a vector store and a document
|
|
4
4
|
* store. It uses the vector store to find relevant documents based on a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type VectorStoreInterface, type VectorStoreRetrieverInterface } from "@langchain/core/vectorstores";
|
|
1
2
|
import { Document } from "../document.js";
|
|
2
|
-
import { VectorStore, VectorStoreRetriever } from "../vectorstores/base.js";
|
|
3
3
|
import { TextSplitter } from "../text_splitter.js";
|
|
4
4
|
import { MultiVectorRetriever, type MultiVectorRetrieverInput } from "./multi_vector.js";
|
|
5
5
|
/**
|
|
@@ -13,7 +13,7 @@ export type ParentDocumentRetrieverFields = MultiVectorRetrieverInput & {
|
|
|
13
13
|
* A custom retriever to use when retrieving instead of
|
|
14
14
|
* the `.similaritySearch` method of the vectorstore.
|
|
15
15
|
*/
|
|
16
|
-
childDocumentRetriever?:
|
|
16
|
+
childDocumentRetriever?: VectorStoreRetrieverInterface<VectorStoreInterface>;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* A type of document retriever that splits input documents into smaller chunks
|
|
@@ -48,13 +48,13 @@ export type ParentDocumentRetrieverFields = MultiVectorRetrieverInput & {
|
|
|
48
48
|
export declare class ParentDocumentRetriever extends MultiVectorRetriever {
|
|
49
49
|
static lc_name(): string;
|
|
50
50
|
lc_namespace: string[];
|
|
51
|
-
vectorstore:
|
|
51
|
+
vectorstore: VectorStoreInterface;
|
|
52
52
|
protected childSplitter: TextSplitter;
|
|
53
53
|
protected parentSplitter?: TextSplitter;
|
|
54
54
|
protected idKey: string;
|
|
55
55
|
protected childK?: number;
|
|
56
56
|
protected parentK?: number;
|
|
57
|
-
childDocumentRetriever:
|
|
57
|
+
childDocumentRetriever: VectorStoreRetrieverInterface<VectorStoreInterface> | undefined;
|
|
58
58
|
constructor(fields: ParentDocumentRetrieverFields);
|
|
59
59
|
_getRelevantDocuments(query: string): Promise<Document[]>;
|
|
60
60
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoteRetriever = void 0;
|
|
4
|
-
const
|
|
4
|
+
const retrievers_1 = require("@langchain/core/retrievers");
|
|
5
5
|
const async_caller_js_1 = require("../../util/async_caller.cjs");
|
|
6
6
|
/**
|
|
7
7
|
* Abstract class for interacting with a remote server to retrieve
|
|
8
8
|
* relevant documents based on a given query.
|
|
9
9
|
*/
|
|
10
|
-
class RemoteRetriever extends
|
|
10
|
+
class RemoteRetriever extends retrievers_1.BaseRetriever {
|
|
11
11
|
get lc_secrets() {
|
|
12
12
|
return {
|
|
13
13
|
"auth.bearer": "REMOTE_RETRIEVER_AUTH_BEARER",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseRetriever, BaseRetrieverInput } from "
|
|
1
|
+
import { BaseRetriever, type BaseRetrieverInput } from "@langchain/core/retrievers";
|
|
2
2
|
import { AsyncCaller, AsyncCallerParams } from "../../util/async_caller.js";
|
|
3
3
|
import { Document } from "../../document.js";
|
|
4
4
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SelfQueryRetriever = exports.FunctionalTranslator = exports.BasicTranslator = exports.BaseTranslator = void 0;
|
|
4
|
+
const retrievers_1 = require("@langchain/core/retrievers");
|
|
4
5
|
const index_js_1 = require("../../chains/query_constructor/index.cjs");
|
|
5
|
-
const retriever_js_1 = require("../../schema/retriever.cjs");
|
|
6
6
|
const functional_js_1 = require("./functional.cjs");
|
|
7
7
|
Object.defineProperty(exports, "FunctionalTranslator", { enumerable: true, get: function () { return functional_js_1.FunctionalTranslator; } });
|
|
8
8
|
const base_js_1 = require("./base.cjs");
|
|
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "BasicTranslator", { enumerable: true, get: funct
|
|
|
26
26
|
* );
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
class SelfQueryRetriever extends
|
|
29
|
+
class SelfQueryRetriever extends retrievers_1.BaseRetriever {
|
|
30
30
|
static lc_name() {
|
|
31
31
|
return "SelfQueryRetriever";
|
|
32
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BaseRetriever, type BaseRetrieverInput } from "@langchain/core/retrievers";
|
|
1
2
|
import { LLMChain } from "../../chains/llm_chain.js";
|
|
2
3
|
import { QueryConstructorChainOptions } from "../../chains/query_constructor/index.js";
|
|
3
4
|
import { Document } from "../../document.js";
|
|
4
|
-
import { BaseRetriever, BaseRetrieverInput } from "../../schema/retriever.js";
|
|
5
5
|
import { VectorStore } from "../../vectorstores/base.js";
|
|
6
6
|
import { FunctionalTranslator } from "./functional.js";
|
|
7
7
|
import { BaseTranslator, BasicTranslator } from "./base.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { BaseRetriever, } from "@langchain/core/retrievers";
|
|
1
2
|
import { loadQueryConstructorChain, } from "../../chains/query_constructor/index.js";
|
|
2
|
-
import { BaseRetriever } from "../../schema/retriever.js";
|
|
3
3
|
import { FunctionalTranslator } from "./functional.js";
|
|
4
4
|
import { BaseTranslator, BasicTranslator } from "./base.js";
|
|
5
5
|
export { BaseTranslator, BasicTranslator, FunctionalTranslator };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimeWeightedVectorStoreRetriever = exports.BUFFER_IDX = exports.LAST_ACCESSED_AT_KEY = void 0;
|
|
4
|
-
const
|
|
4
|
+
const retrievers_1 = require("@langchain/core/retrievers");
|
|
5
5
|
exports.LAST_ACCESSED_AT_KEY = "last_accessed_at";
|
|
6
6
|
exports.BUFFER_IDX = "buffer_idx";
|
|
7
7
|
/**
|
|
@@ -24,7 +24,7 @@ exports.BUFFER_IDX = "buffer_idx";
|
|
|
24
24
|
* );
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
class TimeWeightedVectorStoreRetriever extends
|
|
27
|
+
class TimeWeightedVectorStoreRetriever extends retrievers_1.BaseRetriever {
|
|
28
28
|
static lc_name() {
|
|
29
29
|
return "TimeWeightedVectorStoreRetriever";
|
|
30
30
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { BaseRetriever, BaseRetrieverInput } from "@langchain/core/retrievers";
|
|
2
|
+
import type { VectorStoreInterface } from "@langchain/core/vectorstores";
|
|
3
|
+
import type { DocumentInterface } from "@langchain/core/documents";
|
|
4
4
|
import { CallbackManagerForRetrieverRun } from "../callbacks/manager.js";
|
|
5
5
|
/**
|
|
6
6
|
* Interface for the fields required to initialize a
|
|
7
7
|
* TimeWeightedVectorStoreRetriever instance.
|
|
8
8
|
*/
|
|
9
9
|
export interface TimeWeightedVectorStoreRetrieverFields extends BaseRetrieverInput {
|
|
10
|
-
vectorStore:
|
|
10
|
+
vectorStore: VectorStoreInterface;
|
|
11
11
|
searchKwargs?: number;
|
|
12
|
-
memoryStream?:
|
|
12
|
+
memoryStream?: DocumentInterface[];
|
|
13
13
|
decayRate?: number;
|
|
14
14
|
k?: number;
|
|
15
15
|
otherScoreKeys?: string[];
|
|
@@ -77,18 +77,18 @@ export declare class TimeWeightedVectorStoreRetriever extends BaseRetriever {
|
|
|
77
77
|
* Get the memory stream of documents.
|
|
78
78
|
* @returns The memory stream of documents.
|
|
79
79
|
*/
|
|
80
|
-
getMemoryStream():
|
|
80
|
+
getMemoryStream(): DocumentInterface[];
|
|
81
81
|
/**
|
|
82
82
|
* Set the memory stream of documents.
|
|
83
83
|
* @param memoryStream The new memory stream of documents.
|
|
84
84
|
*/
|
|
85
|
-
setMemoryStream(memoryStream:
|
|
85
|
+
setMemoryStream(memoryStream: DocumentInterface[]): void;
|
|
86
86
|
/**
|
|
87
87
|
* Get relevant documents based on time-weighted relevance
|
|
88
88
|
* @param query - The query to search for
|
|
89
89
|
* @returns The relevant documents
|
|
90
90
|
*/
|
|
91
|
-
_getRelevantDocuments(query: string, runManager?: CallbackManagerForRetrieverRun): Promise<
|
|
91
|
+
_getRelevantDocuments(query: string, runManager?: CallbackManagerForRetrieverRun): Promise<DocumentInterface[]>;
|
|
92
92
|
/**
|
|
93
93
|
* NOTE: When adding documents to a vector store, use addDocuments
|
|
94
94
|
* via retriever instead of directly to the vector store.
|
|
@@ -97,7 +97,7 @@ export declare class TimeWeightedVectorStoreRetriever extends BaseRetriever {
|
|
|
97
97
|
*
|
|
98
98
|
* @param docs - The documents to add to vector store in the retriever
|
|
99
99
|
*/
|
|
100
|
-
addDocuments(docs:
|
|
100
|
+
addDocuments(docs: DocumentInterface[]): Promise<void>;
|
|
101
101
|
/**
|
|
102
102
|
* Get memory documents and their scores
|
|
103
103
|
* @returns An object containing memory documents and their scores
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type RunnableFunc, type RunnableLike, type RunnableBatchOptions, type RunnableRetryFailedAttemptHandler, Runnable, type RunnableBindingArgs, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableParallel, RunnableLambda, RunnableWithFallbacks, _coerceToRunnable, } from "@langchain/core/runnables";
|
|
1
|
+
export { type RunnableFunc, type RunnableLike, type RunnableBatchOptions, type RunnableRetryFailedAttemptHandler, Runnable, type RunnableInterface, type RunnableBindingArgs, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableParallel, RunnableLambda, RunnableWithFallbacks, _coerceToRunnable, } from "@langchain/core/runnables";
|