From 90179e9f1de62c3546ecd4b541d53c659f725953 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Wed, 12 Jun 2024 15:40:38 -0700 Subject: [PATCH 1/2] all[patch]: Replace .getRelevantDocuments with .invoke --- docs/core_docs/docs/tutorials/agents.mdx | 2 +- docs/core_docs/docs/tutorials/rag.ipynb | 4 +-- .../parent_document_retriever_rerank.ts | 2 +- examples/src/retrievers/qdrant_self_query.ts | 8 ++--- langchain-core/src/retrievers/index.ts | 2 +- .../src/structured_query/functional.ts | 2 +- .../toolkits/conversational_retrieval/tool.ts | 2 +- .../chains/conversational_retrieval_chain.ts | 2 +- langchain/src/chains/retrieval_qa.ts | 2 +- langchain/src/experimental/autogpt/prompt.ts | 2 +- .../violation_of_expectations_chain.ts | 2 +- .../generative_agent_memory.ts | 2 +- langchain/src/memory/vector_store.ts | 2 +- .../src/retrievers/contextual_compression.ts | 4 +-- .../retrievers/document_compressors/index.ts | 2 +- langchain/src/retrievers/hyde.ts | 2 +- langchain/src/retrievers/multi_query.ts | 4 +-- langchain/src/retrievers/multi_vector.ts | 2 +- langchain/src/retrievers/parent_document.ts | 4 +-- langchain/src/retrievers/self_query/chroma.ts | 2 +- langchain/src/retrievers/self_query/index.ts | 2 +- .../src/retrievers/self_query/pinecone.ts | 2 +- .../src/retrievers/self_query/supabase.ts | 2 +- .../tests/memory_self_query.int.test.ts | 22 ++++++------- .../src/retrievers/self_query/weaviate.ts | 2 +- .../src/retrievers/tests/hyde.int.test.ts | 4 +-- .../tests/matryoshka_retriever.int.test.ts | 6 ++-- .../retrievers/tests/multi_query.int.test.ts | 4 +-- .../tests/parent_document.int.test.ts | 10 +++--- .../retrievers/tests/time_weighted.test.ts | 14 ++++---- .../src/retrievers/tests/vectorstores.test.ts | 2 +- langchain/src/retrievers/time_weighted.ts | 2 +- langchain/src/tools/retriever.ts | 2 +- .../src/vectorstores/tests/memory.test.ts | 2 +- .../src/retrievers/amazon_kendra.ts | 2 +- .../src/retrievers/amazon_knowledge_base.ts | 2 +- .../src/retrievers/chaindesk.ts | 2 +- .../src/retrievers/dria.ts | 2 +- .../src/retrievers/metal.ts | 2 +- .../tests/amazon_kendra.int.test.ts | 2 +- .../tests/amazon_knowledge_base.int.test.ts | 2 +- .../src/retrievers/tests/dria.int.test.ts | 2 +- .../src/retrievers/tests/metal.int.test.ts | 2 +- .../src/retrievers/tests/supabase.int.test.ts | 2 +- .../tests/tavily_search_api.int.test.ts | 2 +- .../src/retrievers/tests/vespa.int.test.ts | 2 +- .../src/retrievers/tests/zep.int.test.ts | 4 +-- .../src/retrievers/vespa.ts | 2 +- .../langchain-community/src/retrievers/zep.ts | 2 +- .../src/retrievers/zep_cloud.ts | 2 +- .../src/structured_query/chroma.ts | 2 +- .../src/structured_query/qdrant.ts | 2 +- .../src/structured_query/supabase.ts | 2 +- .../tests/chroma_self_query.int.test.ts | 8 ++--- .../tests/hnswlib_self_query.int.test.ts | 8 ++--- .../tests/qdrant_self_query.int.test.ts | 22 ++++++------- .../tests/supabase_self_query.int.test.ts | 32 +++++++++---------- .../tests/vectara_self_query.int.test.ts | 8 ++--- .../tests/azure_aisearch.int.test.ts | 6 ++-- .../tests/azure_cosmosdb.int.test.ts | 6 ++-- .../vectorstores/tests/hanavector.int.test.ts | 6 ++-- .../vectorstores/tests/vectara.int.test.ts | 2 +- libs/langchain-exa/src/retrievers.ts | 2 +- .../src/tests/retrievers.int.test.ts | 2 +- .../src/tests/vectorstores.int.test.ts | 6 ++-- .../src/tests/translator.int.test.ts | 20 ++++++------ libs/langchain-pinecone/src/translator.ts | 2 +- .../src/tests/translator.int.test.ts | 10 +++--- libs/langchain-weaviate/src/translator.ts | 2 +- 69 files changed, 156 insertions(+), 156 deletions(-) diff --git a/docs/core_docs/docs/tutorials/agents.mdx b/docs/core_docs/docs/tutorials/agents.mdx index 26085a14bdb2..73849c2aeb6c 100644 --- a/docs/core_docs/docs/tutorials/agents.mdx +++ b/docs/core_docs/docs/tutorials/agents.mdx @@ -83,7 +83,7 @@ const vectorstore = await MemoryVectorStore.fromDocuments( ); const retriever = vectorstore.asRetriever(); -const retrieverResult = await retriever.getRelevantDocuments( +const retrieverResult = await retriever.invoke( "how to upload a dataset" ); console.log(retrieverResult[0]); diff --git a/docs/core_docs/docs/tutorials/rag.ipynb b/docs/core_docs/docs/tutorials/rag.ipynb index 483190981af6..8db0dd70f6d1 100644 --- a/docs/core_docs/docs/tutorials/rag.ipynb +++ b/docs/core_docs/docs/tutorials/rag.ipynb @@ -136,7 +136,7 @@ " outputParser: new StringOutputParser(),\n", "})\n", "\n", - "const retrievedDocs = await retriever.getRelevantDocuments(\"what is task decomposition\")" + "const retrievedDocs = await retriever.invoke(\"what is task decomposition\")" ] }, { @@ -817,7 +817,7 @@ " prompt: customRagPrompt,\n", " outputParser: new StringOutputParser(),\n", "})\n", - "const context = await retriever.getRelevantDocuments(\"what is task decomposition\");\n", + "const context = await retriever.invoke(\"what is task decomposition\");\n", "\n", "await ragChain.invoke({\n", " question: \"What is Task Decomposition?\",\n", diff --git a/examples/src/retrievers/parent_document_retriever_rerank.ts b/examples/src/retrievers/parent_document_retriever_rerank.ts index 11726aae3396..ff5ce56cd7f5 100644 --- a/examples/src/retrievers/parent_document_retriever_rerank.ts +++ b/examples/src/retrievers/parent_document_retriever_rerank.ts @@ -69,7 +69,7 @@ await retriever.addDocuments(docs); // This will search for documents in vector store and return for LLM already reranked and sorted document // with appropriate minimum relevance score -const retrievedDocs = await retriever.getRelevantDocuments( +const retrievedDocs = await retriever.invoke( "What is Pam's favorite color?" ); diff --git a/examples/src/retrievers/qdrant_self_query.ts b/examples/src/retrievers/qdrant_self_query.ts index 44f5ab85d39f..becc23b62096 100644 --- a/examples/src/retrievers/qdrant_self_query.ts +++ b/examples/src/retrievers/qdrant_self_query.ts @@ -118,16 +118,16 @@ const selfQueryRetriever = SelfQueryRetriever.fromLLM({ * We can also ask questions like "Which movies are either comedy or drama and are less than 90 minutes?". * The retriever will automatically convert these questions into queries that can be used to retrieve documents. */ -const query1 = await selfQueryRetriever.getRelevantDocuments( +const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); -const query2 = await selfQueryRetriever.getRelevantDocuments( +const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); -const query3 = await selfQueryRetriever.getRelevantDocuments( +const query3 = await selfQueryRetriever.invoke( "Which cool movies are directed by Greta Gerwig?" ); -const query4 = await selfQueryRetriever.getRelevantDocuments( +const query4 = await selfQueryRetriever.invoke( "Which movies are either comedy or drama and are less than 90 minutes?" ); console.log(query1, query2, query3, query4); diff --git a/langchain-core/src/retrievers/index.ts b/langchain-core/src/retrievers/index.ts index a544dedce7b9..317d3a6c1d29 100644 --- a/langchain-core/src/retrievers/index.ts +++ b/langchain-core/src/retrievers/index.ts @@ -73,7 +73,7 @@ export abstract class BaseRetriever< input: string, options?: RunnableConfig ): Promise[]> { - return this.getRelevantDocuments(input, ensureConfig(options)); + return this.invoke(input, ensureConfig(options)); } /** diff --git a/langchain-core/src/structured_query/functional.ts b/langchain-core/src/structured_query/functional.ts index 7a0c2e894ad0..14172347e68e 100644 --- a/langchain-core/src/structured_query/functional.ts +++ b/langchain-core/src/structured_query/functional.ts @@ -37,7 +37,7 @@ export type FunctionFilter = (document: Document) => boolean; * @example * ```typescript * const functionalTranslator = new FunctionalTranslator(); - * const relevantDocuments = await functionalTranslator.getRelevantDocuments( + * const relevantDocuments = await functionalTranslator.invoke( * "Which movies are rated higher than 8.5?", * ); * ``` diff --git a/langchain/src/agents/toolkits/conversational_retrieval/tool.ts b/langchain/src/agents/toolkits/conversational_retrieval/tool.ts index 9d3df92e5856..bec9f279169e 100644 --- a/langchain/src/agents/toolkits/conversational_retrieval/tool.ts +++ b/langchain/src/agents/toolkits/conversational_retrieval/tool.ts @@ -16,7 +16,7 @@ export function createRetrieverTool( { input }: { input: string }, runManager?: CallbackManagerForToolRun ) => { - const docs = await retriever.getRelevantDocuments( + const docs = await retriever.invoke( input, runManager?.getChild("retriever") ); diff --git a/langchain/src/chains/conversational_retrieval_chain.ts b/langchain/src/chains/conversational_retrieval_chain.ts index c5b5b75f479d..5a66ce71f340 100644 --- a/langchain/src/chains/conversational_retrieval_chain.ts +++ b/langchain/src/chains/conversational_retrieval_chain.ts @@ -230,7 +230,7 @@ export class ConversationalRetrievalQAChain ); } } - const docs = await this.retriever.getRelevantDocuments( + const docs = await this.retriever.invoke( newQuestion, runManager?.getChild("retriever") ); diff --git a/langchain/src/chains/retrieval_qa.ts b/langchain/src/chains/retrieval_qa.ts index 84cd24c5f57a..d15874fe4bf9 100644 --- a/langchain/src/chains/retrieval_qa.ts +++ b/langchain/src/chains/retrieval_qa.ts @@ -100,7 +100,7 @@ export class RetrievalQAChain throw new Error(`Question key "${this.inputKey}" not found.`); } const question: string = values[this.inputKey]; - const docs = await this.retriever.getRelevantDocuments( + const docs = await this.retriever.invoke( question, runManager?.getChild("retriever") ); diff --git a/langchain/src/experimental/autogpt/prompt.ts b/langchain/src/experimental/autogpt/prompt.ts index cd4c14293397..de4d0dd60f5c 100644 --- a/langchain/src/experimental/autogpt/prompt.ts +++ b/langchain/src/experimental/autogpt/prompt.ts @@ -109,7 +109,7 @@ export class AutoGPTPrompt const usedTokens = (await this.tokenCounter(basePrompt.content)) + (await this.tokenCounter(timePrompt.content)); - const relevantDocs = await memory.getRelevantDocuments( + const relevantDocs = await memory.invoke( JSON.stringify(previousMessages.slice(-10)) ); const relevantMemory = relevantDocs.map( diff --git a/langchain/src/experimental/chains/violation_of_expectations/violation_of_expectations_chain.ts b/langchain/src/experimental/chains/violation_of_expectations/violation_of_expectations_chain.ts index 070c14ee77f6..31d74b285011 100644 --- a/langchain/src/experimental/chains/violation_of_expectations/violation_of_expectations_chain.ts +++ b/langchain/src/experimental/chains/violation_of_expectations/violation_of_expectations_chain.ts @@ -294,7 +294,7 @@ export class ViolationOfExpectationsChain // Only extract the first relevant doc from the retriever. We don't need more than one. const relevantInsightsDocuments = await Promise.all( insights.map(async (insight) => { - const relevantInsight = await this.retriever.getRelevantDocuments( + const relevantInsight = await this.retriever.invoke( insight ); return relevantInsight[0]; diff --git a/langchain/src/experimental/generative_agents/generative_agent_memory.ts b/langchain/src/experimental/generative_agents/generative_agent_memory.ts index 4625d8f3b67e..2718d3eea6ea 100644 --- a/langchain/src/experimental/generative_agents/generative_agent_memory.ts +++ b/langchain/src/experimental/generative_agents/generative_agent_memory.ts @@ -280,7 +280,7 @@ class GenerativeAgentMemoryChain extends BaseChain { _now?: Date, runManager?: CallbackManagerForChainRun ): Promise { - return this.memoryRetriever.getRelevantDocuments( + return this.memoryRetriever.invoke( observation, runManager?.getChild("memory_retriever") ); diff --git a/langchain/src/memory/vector_store.ts b/langchain/src/memory/vector_store.ts index 5da167519c91..7b3bab84abb6 100644 --- a/langchain/src/memory/vector_store.ts +++ b/langchain/src/memory/vector_store.ts @@ -98,7 +98,7 @@ export class VectorStoreRetrieverMemory */ async loadMemoryVariables(values: InputValues): Promise { const query = getInputValue(values, this.inputKey); - const results = await this.vectorStoreRetriever.getRelevantDocuments(query); + const results = await this.vectorStoreRetriever.invoke(query); return { [this.memoryKey]: this.returnDocs ? results diff --git a/langchain/src/retrievers/contextual_compression.ts b/langchain/src/retrievers/contextual_compression.ts index ebc400cf17e0..9aeb5f02e785 100644 --- a/langchain/src/retrievers/contextual_compression.ts +++ b/langchain/src/retrievers/contextual_compression.ts @@ -27,7 +27,7 @@ export interface ContextualCompressionRetrieverArgs extends BaseRetrieverInput { * baseCompressor: new LLMChainExtractor(), * baseRetriever: new HNSWLib().asRetriever(), * }); - * const retrievedDocs = await retriever.getRelevantDocuments( + * const retrievedDocs = await retriever.invoke( * "What did the speaker say about Justice Breyer?", * ); * ``` @@ -54,7 +54,7 @@ export class ContextualCompressionRetriever extends BaseRetriever { query: string, runManager?: CallbackManagerForRetrieverRun ): Promise { - const docs = await this.baseRetriever.getRelevantDocuments( + const docs = await this.baseRetriever.invoke( query, runManager?.getChild("base_retriever") ); diff --git a/langchain/src/retrievers/document_compressors/index.ts b/langchain/src/retrievers/document_compressors/index.ts index d0e978fdd33c..9c468bbebc1e 100644 --- a/langchain/src/retrievers/document_compressors/index.ts +++ b/langchain/src/retrievers/document_compressors/index.ts @@ -50,7 +50,7 @@ export abstract class BaseDocumentCompressor { * includeRawContent: true, * }), * }); - * const retrievedDocs = await retriever.getRelevantDocuments( + * const retrievedDocs = await retriever.invoke( * "What did the speaker say about Justice Breyer in the 2022 State of the Union?", * ); * console.log({ retrievedDocs }); diff --git a/langchain/src/retrievers/hyde.ts b/langchain/src/retrievers/hyde.ts index e720f4dd8650..068768f1d5ad 100644 --- a/langchain/src/retrievers/hyde.ts +++ b/langchain/src/retrievers/hyde.ts @@ -56,7 +56,7 @@ export type HydeRetrieverOptions = * "My favourite food is pasta.", * ].map((pageContent) => new Document({ pageContent })), * ); - * const results = await retriever.getRelevantDocuments( + * const results = await retriever.invoke( * "What is my favourite food?", * ); * ``` diff --git a/langchain/src/retrievers/multi_query.ts b/langchain/src/retrievers/multi_query.ts index 14d38f628de7..574277760fa2 100644 --- a/langchain/src/retrievers/multi_query.ts +++ b/langchain/src/retrievers/multi_query.ts @@ -82,7 +82,7 @@ export interface MultiQueryRetrieverInput extends BaseRetrieverInput { * retriever: new MemoryVectorStore().asRetriever(), * verbose: true, * }); - * const retrievedDocs = await retriever.getRelevantDocuments( + * const retrievedDocs = await retriever.invoke( * "What are mitochondria made of?", * ); * ``` @@ -159,7 +159,7 @@ export class MultiQueryRetriever extends BaseRetriever { const documents: Document[] = []; await Promise.all( queries.map(async (query) => { - const docs = await this.retriever.getRelevantDocuments( + const docs = await this.retriever.invoke( query, runManager?.getChild() ); diff --git a/langchain/src/retrievers/multi_vector.ts b/langchain/src/retrievers/multi_vector.ts index 2712ffc6cc29..c071fd526535 100644 --- a/langchain/src/retrievers/multi_vector.ts +++ b/langchain/src/retrievers/multi_vector.ts @@ -34,7 +34,7 @@ export interface MultiVectorRetrieverInput extends BaseRetrieverInput { * parentK: 5, * }); * - * const retrieverResult = await retriever.getRelevantDocuments("justice breyer"); + * const retrieverResult = await retriever.invoke("justice breyer"); * console.log(retrieverResult[0].pageContent.length); * ``` */ diff --git a/langchain/src/retrievers/parent_document.ts b/langchain/src/retrievers/parent_document.ts index ca06d4b760ea..941c4915dc25 100644 --- a/langchain/src/retrievers/parent_document.ts +++ b/langchain/src/retrievers/parent_document.ts @@ -61,7 +61,7 @@ export type ParentDocumentRetrieverFields = MultiVectorRetrieverInput & { * * const parentDocuments = await getDocuments(); * await retriever.addDocuments(parentDocuments); - * const retrievedDocs = await retriever.getRelevantDocuments("justice breyer"); + * const retrievedDocs = await retriever.invoke("justice breyer"); * ``` */ export class ParentDocumentRetriever extends MultiVectorRetriever { @@ -107,7 +107,7 @@ export class ParentDocumentRetriever extends MultiVectorRetriever { async _getRelevantDocuments(query: string): Promise { let subDocs: SubDocs = []; if (this.childDocumentRetriever) { - subDocs = await this.childDocumentRetriever.getRelevantDocuments(query); + subDocs = await this.childDocumentRetriever.invoke(query); } else { subDocs = await this.vectorstore.similaritySearch(query, this.childK); } diff --git a/langchain/src/retrievers/self_query/chroma.ts b/langchain/src/retrievers/self_query/chroma.ts index 1fa17f55fead..00799d4f34fe 100644 --- a/langchain/src/retrievers/self_query/chroma.ts +++ b/langchain/src/retrievers/self_query/chroma.ts @@ -28,7 +28,7 @@ import { logVersion020MigrationWarning } from "../../util/entrypoint_deprecation * structuredQueryTranslator: chromaTranslator, * }); * - * const relevantDocuments = await selfQueryRetriever.getRelevantDocuments( + * const relevantDocuments = await selfQueryRetriever.invoke( * "Which movies are directed by Greta Gerwig?", * ); * ``` diff --git a/langchain/src/retrievers/self_query/index.ts b/langchain/src/retrievers/self_query/index.ts index 6b348104a4b8..728a2bf3ad73 100644 --- a/langchain/src/retrievers/self_query/index.ts +++ b/langchain/src/retrievers/self_query/index.ts @@ -51,7 +51,7 @@ export interface SelfQueryRetrieverArgs * attributeInfo: attributeInfo, * structuredQueryTranslator: new FunctionalTranslator(), * }); - * const relevantDocuments = await selfQueryRetriever.getRelevantDocuments( + * const relevantDocuments = await selfQueryRetriever.invoke( * "Which movies are directed by Greta Gerwig?", * ); * ``` diff --git a/langchain/src/retrievers/self_query/pinecone.ts b/langchain/src/retrievers/self_query/pinecone.ts index b52dbddcb95f..d078393daaff 100644 --- a/langchain/src/retrievers/self_query/pinecone.ts +++ b/langchain/src/retrievers/self_query/pinecone.ts @@ -28,7 +28,7 @@ import { logVersion020MigrationWarning } from "../../util/entrypoint_deprecation * structuredQueryTranslator: new PineconeTranslator(), * }); * - * const queryResult = await selfQueryRetriever.getRelevantDocuments( + * const queryResult = await selfQueryRetriever.invoke( * "Which movies are directed by Greta Gerwig?", * ); * ``` diff --git a/langchain/src/retrievers/self_query/supabase.ts b/langchain/src/retrievers/self_query/supabase.ts index 4877702dd650..241dab1fd979 100644 --- a/langchain/src/retrievers/self_query/supabase.ts +++ b/langchain/src/retrievers/self_query/supabase.ts @@ -59,7 +59,7 @@ type SupabaseMetadata = any; * structuredQueryTranslator: new SupabaseTranslator(), * }); * - * const queryResult = await selfQueryRetriever.getRelevantDocuments( + * const queryResult = await selfQueryRetriever.invoke( * "Which movies are directed by Greta Gerwig?", * ); * ``` diff --git a/langchain/src/retrievers/self_query/tests/memory_self_query.int.test.ts b/langchain/src/retrievers/self_query/tests/memory_self_query.int.test.ts index b3e48b9fe655..89c941ead358 100644 --- a/langchain/src/retrievers/self_query/tests/memory_self_query.int.test.ts +++ b/langchain/src/retrievers/self_query/tests/memory_self_query.int.test.ts @@ -86,19 +86,19 @@ test("Memory Vector Store Self Query Retriever Test", async () => { structuredQueryTranslator: new FunctionalTranslator(), }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); console.log(query1); expect(query1.length).toEqual(0); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); console.log(query2); expect(query2.length).toEqual(2); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); console.log(query3); @@ -221,25 +221,25 @@ test("Memory Vector Store Self Query Retriever Test With Default Filter Or Merge }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); console.log(query1); expect(query1.length).toEqual(6); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); console.log(query2); expect(query2.length).toEqual(7); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); console.log(query3); expect(query3.length).toEqual(6); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Awawawa au au au wawawawa hello?" ); console.log(query4); @@ -362,25 +362,25 @@ test("Memory Vector Store Self Query Retriever Test With Default Filter And Merg }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); console.log(query1); expect(query1.length).toEqual(0); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); console.log(query2); expect(query2.length).toEqual(2); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); console.log(query3); expect(query3.length).toEqual(1); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Awawawa au au au wawawawa hello?" ); console.log(query4); diff --git a/langchain/src/retrievers/self_query/weaviate.ts b/langchain/src/retrievers/self_query/weaviate.ts index 6bd285081f33..19f85ee7475c 100644 --- a/langchain/src/retrievers/self_query/weaviate.ts +++ b/langchain/src/retrievers/self_query/weaviate.ts @@ -78,7 +78,7 @@ export type WeaviateStructuredQueryResult = { * structuredQueryTranslator: new WeaviateTranslator(), * }); * - * const relevantDocuments = await selfQueryRetriever.getRelevantDocuments( + * const relevantDocuments = await selfQueryRetriever.invoke( * "Which movies are rated higher than 8.5?", * ); * ``` diff --git a/langchain/src/retrievers/tests/hyde.int.test.ts b/langchain/src/retrievers/tests/hyde.int.test.ts index 9e75b5490547..f3fb99868f2b 100644 --- a/langchain/src/retrievers/tests/hyde.int.test.ts +++ b/langchain/src/retrievers/tests/hyde.int.test.ts @@ -23,7 +23,7 @@ test("Hyde retriever", async () => { ].map((pageContent) => new Document({ pageContent })) ); - const results = await retriever.getRelevantDocuments( + const results = await retriever.invoke( "What is my favourite food?" ); @@ -51,7 +51,7 @@ test("Hyde retriever with default prompt template", async () => { ].map((pageContent) => new Document({ pageContent })) ); - const results = await retriever.getRelevantDocuments( + const results = await retriever.invoke( "What is my favourite food?" ); diff --git a/langchain/src/retrievers/tests/matryoshka_retriever.int.test.ts b/langchain/src/retrievers/tests/matryoshka_retriever.int.test.ts index c00446ffadc1..bbb498ab1aa4 100644 --- a/langchain/src/retrievers/tests/matryoshka_retriever.int.test.ts +++ b/langchain/src/retrievers/tests/matryoshka_retriever.int.test.ts @@ -67,7 +67,7 @@ test("MatryoshkaRetriever can retrieve", async () => { const query = "What is LangChain?"; console.log("Querying documents"); - const results = await retriever.getRelevantDocuments(query); + const results = await retriever.invoke(query); const retrieverResultContents = new Set( results.map((doc) => doc.pageContent) @@ -104,7 +104,7 @@ test("Can change number of docs returned (largeK)", async () => { await retriever.addDocuments(docsWithId); const query = "hello world"; - const results = await retriever.getRelevantDocuments(query); + const results = await retriever.invoke(query); expect(results.length).toBe(10); }); @@ -133,7 +133,7 @@ test("AddDocunents adds large embeddings metadata field", async () => { await retriever.addDocuments([doc]); - const relevantDocs = await retriever.getRelevantDocuments("hello world"); + const relevantDocs = await retriever.invoke("hello world"); expect(relevantDocs[0].metadata.id).toBe(testId); expect(relevantDocs[0].metadata[retriever.largeEmbeddingKey]).toBeDefined(); expect( diff --git a/langchain/src/retrievers/tests/multi_query.int.test.ts b/langchain/src/retrievers/tests/multi_query.int.test.ts index 18792bfba613..e147a676c3a8 100644 --- a/langchain/src/retrievers/tests/multi_query.int.test.ts +++ b/langchain/src/retrievers/tests/multi_query.int.test.ts @@ -26,7 +26,7 @@ test("Should work with a question input", async () => { }); const query = "What are mitochondria made of?"; - const retrievedDocs = await retriever.getRelevantDocuments(query); + const retrievedDocs = await retriever.invoke(query); expect(retrievedDocs[0].pageContent).toContain("mitochondria"); }); @@ -52,6 +52,6 @@ test("Should work with a keyword", async () => { }); const query = "cars"; - const retrievedDocs = await retriever.getRelevantDocuments(query); + const retrievedDocs = await retriever.invoke(query); expect(retrievedDocs[0].pageContent).toContain("Cars"); }); diff --git a/langchain/src/retrievers/tests/parent_document.int.test.ts b/langchain/src/retrievers/tests/parent_document.int.test.ts index 005484a4dda2..90b00731aed0 100644 --- a/langchain/src/retrievers/tests/parent_document.int.test.ts +++ b/langchain/src/retrievers/tests/parent_document.int.test.ts @@ -24,7 +24,7 @@ test("Should return the full document if an unsplit parent document has been add await retriever.addDocuments(docs); const query = "justice breyer"; - const retrievedDocs = await retriever.getRelevantDocuments(query); + const retrievedDocs = await retriever.invoke(query); expect(retrievedDocs.length).toEqual(1); expect(retrievedDocs[0].pageContent.length).toBeGreaterThan(1000); }); @@ -49,7 +49,7 @@ test("Should return a part of a document if a parent splitter is passed", async ).load(); await retriever.addDocuments(docs); const query = "justice breyer"; - const retrievedDocs = await retriever.getRelevantDocuments(query); + const retrievedDocs = await retriever.invoke(query); const vectorstoreRetreivedDocs = await vectorstore.similaritySearch( "justice breyer" ); @@ -75,7 +75,7 @@ test("Should work with a backwards compatible docstore too", async () => { await retriever.addDocuments(docs); const query = "justice breyer"; - const retrievedDocs = await retriever.getRelevantDocuments(query); + const retrievedDocs = await retriever.invoke(query); expect(retrievedDocs.length).toEqual(1); expect(retrievedDocs[0].pageContent.length).toBeGreaterThan(1000); }); @@ -100,7 +100,7 @@ test("Should return a part of a document if a parent splitter is passed", async ).load(); await retriever.addDocuments(docs); const query = "justice breyer"; - const retrievedDocs = await retriever.getRelevantDocuments(query); + const retrievedDocs = await retriever.invoke(query); const vectorstoreRetreivedDocs = await vectorstore.similaritySearch( "justice breyer" ); @@ -138,7 +138,7 @@ test("Should use a custom retriever to retrieve one doc", async () => { ).load(); await retriever.addDocuments(docs); const query = "justice breyer"; - const retrievedDocs = await retriever.getRelevantDocuments(query); + const retrievedDocs = await retriever.invoke(query); const vectorstoreRetreivedDocs = await vectorstore.similaritySearch( "justice breyer" ); diff --git a/langchain/src/retrievers/tests/time_weighted.test.ts b/langchain/src/retrievers/tests/time_weighted.test.ts index 16f7db975544..22a85f17edc9 100644 --- a/langchain/src/retrievers/tests/time_weighted.test.ts +++ b/langchain/src/retrievers/tests/time_weighted.test.ts @@ -56,7 +56,7 @@ describe("Test getRelevantDocuments", () => { ]); const query = "aaa"; - await expect(() => retriever.getRelevantDocuments(query)).rejects.toThrow(); + await expect(() => retriever.invoke(query)).rejects.toThrow(); }); test("For different pageContent with the same lastAccessedAt, return in descending order of similar words.", async () => { const retriever = new TimeWeightedVectorStoreRetriever({ @@ -71,7 +71,7 @@ describe("Test getRelevantDocuments", () => { ]); const query = "aaa"; - const resultsDocs = await retriever.getRelevantDocuments(query); + const resultsDocs = await retriever.invoke(query); const expected = [ { pageContent: "aaa", @@ -116,7 +116,7 @@ describe("Test getRelevantDocuments", () => { ]); const query = "Test query"; - const resultsDocs = await retriever.getRelevantDocuments(query); + const resultsDocs = await retriever.invoke(query); const expected = [ { pageContent: samePageContent, @@ -161,7 +161,7 @@ describe("Test getRelevantDocuments", () => { await retriever.addDocuments([{ pageContent: "qux", metadata: {} }]); const query = "Test query"; - const resultsDocs = await retriever.getRelevantDocuments(query); + const resultsDocs = await retriever.invoke(query); const expected = [ { pageContent: "qux", @@ -208,7 +208,7 @@ describe("Test getRelevantDocuments", () => { await retriever.addDocuments([{ pageContent: "qux", metadata: {} }]); const query = "Test query"; - const resultsDocs = await retriever.getRelevantDocuments(query); + const resultsDocs = await retriever.invoke(query); const expected = [ { pageContent: "qux", @@ -254,7 +254,7 @@ describe("Test getRelevantDocuments", () => { await retriever.addDocuments([{ pageContent: "qux", metadata: {} }]); const query = "Test query"; - const resultsDocs = await retriever.getRelevantDocuments(query); + const resultsDocs = await retriever.invoke(query); const expected = [ { pageContent: "qux", @@ -296,7 +296,7 @@ describe("Test getRelevantDocuments", () => { ]); const query = "Test query"; - const resultsDocs = await retriever.getRelevantDocuments(query); + const resultsDocs = await retriever.invoke(query); const expected = [ { pageContent: "qux", diff --git a/langchain/src/retrievers/tests/vectorstores.test.ts b/langchain/src/retrievers/tests/vectorstores.test.ts index 851ffe99249b..f02f74c5d1d5 100644 --- a/langchain/src/retrievers/tests/vectorstores.test.ts +++ b/langchain/src/retrievers/tests/vectorstores.test.ts @@ -48,7 +48,7 @@ test("Test Memory Retriever with Callback", async () => { ], }); - const results = await retriever.getRelevantDocuments(queryStr); + const results = await retriever.invoke(queryStr); expect(results).toEqual([new Document({ metadata: { a: 1 }, pageContent })]); await startPromise; diff --git a/langchain/src/retrievers/time_weighted.ts b/langchain/src/retrievers/time_weighted.ts index 4a0e2004fc42..a51a4765523b 100644 --- a/langchain/src/retrievers/time_weighted.ts +++ b/langchain/src/retrievers/time_weighted.ts @@ -36,7 +36,7 @@ export const BUFFER_IDX = "buffer_idx"; * { pageContent: "My favourite food is pizza.", metadata: {} }, * * ]); - * const results = await retriever.getRelevantDocuments( + * const results = await retriever.invoke( * "What is my favourite food?", * ); * ``` diff --git a/langchain/src/tools/retriever.ts b/langchain/src/tools/retriever.ts index b9312b1936dd..d2a494cb9f27 100644 --- a/langchain/src/tools/retriever.ts +++ b/langchain/src/tools/retriever.ts @@ -15,7 +15,7 @@ export function createRetrieverTool( { query }: { query: string }, runManager?: CallbackManagerForToolRun ) => { - const docs = await retriever.getRelevantDocuments( + const docs = await retriever.invoke( query, runManager?.getChild("retriever") ); diff --git a/langchain/src/vectorstores/tests/memory.test.ts b/langchain/src/vectorstores/tests/memory.test.ts index d1f43bb4740e..e490010f2852 100644 --- a/langchain/src/vectorstores/tests/memory.test.ts +++ b/langchain/src/vectorstores/tests/memory.test.ts @@ -58,7 +58,7 @@ test("MemoryVectorStore as retriever can filter metadata", async () => { { pageContent: "hello", metadata: { namespace: 4 } }, ]); - const results = await retriever.getRelevantDocuments("hello"); + const results = await retriever.invoke("hello"); expect(results).toHaveLength(2); diff --git a/libs/langchain-community/src/retrievers/amazon_kendra.ts b/libs/langchain-community/src/retrievers/amazon_kendra.ts index d61600fbe76a..c498324b2e19 100644 --- a/libs/langchain-community/src/retrievers/amazon_kendra.ts +++ b/libs/langchain-community/src/retrievers/amazon_kendra.ts @@ -44,7 +44,7 @@ export interface AmazonKendraRetrieverArgs { * }, * }); * - * const docs = await retriever.getRelevantDocuments("How are clouds formed?"); + * const docs = await retriever.invoke("How are clouds formed?"); * ``` */ export class AmazonKendraRetriever extends BaseRetriever { diff --git a/libs/langchain-community/src/retrievers/amazon_knowledge_base.ts b/libs/langchain-community/src/retrievers/amazon_knowledge_base.ts index 5973af27ceda..faced05fcb59 100644 --- a/libs/langchain-community/src/retrievers/amazon_knowledge_base.ts +++ b/libs/langchain-community/src/retrievers/amazon_knowledge_base.ts @@ -35,7 +35,7 @@ export interface AmazonKnowledgeBaseRetrieverArgs { * }, * }); * - * const docs = await retriever.getRelevantDocuments("How are clouds formed?"); + * const docs = await retriever.invoke("How are clouds formed?"); * ``` */ export class AmazonKnowledgeBaseRetriever extends BaseRetriever { diff --git a/libs/langchain-community/src/retrievers/chaindesk.ts b/libs/langchain-community/src/retrievers/chaindesk.ts index 08d6cd946fa1..90bbfae435dc 100644 --- a/libs/langchain-community/src/retrievers/chaindesk.ts +++ b/libs/langchain-community/src/retrievers/chaindesk.ts @@ -32,7 +32,7 @@ interface Berry { * apiKey: "CHAINDESK_API_KEY", * topK: 8, * }); - * const docs = await retriever.getRelevantDocuments("hello"); + * const docs = await retriever.invoke("hello"); * ``` */ export class ChaindeskRetriever extends BaseRetriever { diff --git a/libs/langchain-community/src/retrievers/dria.ts b/libs/langchain-community/src/retrievers/dria.ts index 60caec99553b..250509ced1c1 100644 --- a/libs/langchain-community/src/retrievers/dria.ts +++ b/libs/langchain-community/src/retrievers/dria.ts @@ -34,7 +34,7 @@ export interface DriaRetrieverArgs * const contractId = "-B64DjhUtCwBdXSpsRytlRQCu-bie-vSTvTIT8Ap3g0"; * const retriever = new DriaRetriever({ contractId }); * - * const docs = await retriever.getRelevantDocuments("What is a union type?"); + * const docs = await retriever.invoke("What is a union type?"); * console.log(docs); * ``` */ diff --git a/libs/langchain-community/src/retrievers/metal.ts b/libs/langchain-community/src/retrievers/metal.ts index da0bb4749912..b6dc7da8ccf1 100644 --- a/libs/langchain-community/src/retrievers/metal.ts +++ b/libs/langchain-community/src/retrievers/metal.ts @@ -37,7 +37,7 @@ interface ResponseItem { * process.env.METAL_INDEX_ID, * ), * }); - * const docs = await retriever.getRelevantDocuments("hello"); + * const docs = await retriever.invoke("hello"); * ``` */ export class MetalRetriever extends BaseRetriever { diff --git a/libs/langchain-community/src/retrievers/tests/amazon_kendra.int.test.ts b/libs/langchain-community/src/retrievers/tests/amazon_kendra.int.test.ts index 604930097aad..738cf9c8b642 100644 --- a/libs/langchain-community/src/retrievers/tests/amazon_kendra.int.test.ts +++ b/libs/langchain-community/src/retrievers/tests/amazon_kendra.int.test.ts @@ -16,7 +16,7 @@ test.skip("AmazonKendraRetriever", async () => { }, }); - const docs = await retriever.getRelevantDocuments("How are clouds formed?"); + const docs = await retriever.invoke("How are clouds formed?"); expect(docs.length).toBeGreaterThan(0); diff --git a/libs/langchain-community/src/retrievers/tests/amazon_knowledge_base.int.test.ts b/libs/langchain-community/src/retrievers/tests/amazon_knowledge_base.int.test.ts index 7a3fe8741dcd..07cb4e66d18e 100644 --- a/libs/langchain-community/src/retrievers/tests/amazon_knowledge_base.int.test.ts +++ b/libs/langchain-community/src/retrievers/tests/amazon_knowledge_base.int.test.ts @@ -17,6 +17,6 @@ test.skip("AmazonKnowledgeBaseRetriever", async () => { }, }); - const docs = await retriever.getRelevantDocuments("How are clouds formed?"); + const docs = await retriever.invoke("How are clouds formed?"); expect(docs.length).toBeGreaterThan(0); }); diff --git a/libs/langchain-community/src/retrievers/tests/dria.int.test.ts b/libs/langchain-community/src/retrievers/tests/dria.int.test.ts index 5b6c5350a64e..79542dcb1991 100644 --- a/libs/langchain-community/src/retrievers/tests/dria.int.test.ts +++ b/libs/langchain-community/src/retrievers/tests/dria.int.test.ts @@ -9,7 +9,7 @@ test.skip("DriaRetriever", async () => { const retriever = new DriaRetriever({ contractId, topK }); - const docs = await retriever.getRelevantDocuments("What is a union type?"); + const docs = await retriever.invoke("What is a union type?"); expect(docs.length).toBe(topK); console.log(docs[0].pageContent); diff --git a/libs/langchain-community/src/retrievers/tests/metal.int.test.ts b/libs/langchain-community/src/retrievers/tests/metal.int.test.ts index f462984ba66f..729ce88f8da3 100644 --- a/libs/langchain-community/src/retrievers/tests/metal.int.test.ts +++ b/libs/langchain-community/src/retrievers/tests/metal.int.test.ts @@ -14,7 +14,7 @@ test("MetalRetriever", async () => { ); const retriever = new MetalRetriever({ client }); - const docs = await retriever.getRelevantDocuments("hello"); + const docs = await retriever.invoke("hello"); expect(docs.length).toBeGreaterThan(0); diff --git a/libs/langchain-community/src/retrievers/tests/supabase.int.test.ts b/libs/langchain-community/src/retrievers/tests/supabase.int.test.ts index 14947d48a616..703466f8c8e7 100644 --- a/libs/langchain-community/src/retrievers/tests/supabase.int.test.ts +++ b/libs/langchain-community/src/retrievers/tests/supabase.int.test.ts @@ -21,7 +21,7 @@ test.skip("Supabase hybrid keyword search", async () => { expect(retriever).toBeDefined(); - const results = await retriever.getRelevantDocuments("hello bye"); + const results = await retriever.invoke("hello bye"); expect(results.length).toBeGreaterThan(0); }); diff --git a/libs/langchain-community/src/retrievers/tests/tavily_search_api.int.test.ts b/libs/langchain-community/src/retrievers/tests/tavily_search_api.int.test.ts index fd71faed7ee3..8a6ea81a9b74 100644 --- a/libs/langchain-community/src/retrievers/tests/tavily_search_api.int.test.ts +++ b/libs/langchain-community/src/retrievers/tests/tavily_search_api.int.test.ts @@ -10,7 +10,7 @@ test.skip("TavilySearchAPIRetriever", async () => { includeRawContent: true, }); - const docs = await retriever.getRelevantDocuments("what bear is best?"); + const docs = await retriever.invoke("what bear is best?"); expect(docs.length).toBeGreaterThan(0); console.log(docs); diff --git a/libs/langchain-community/src/retrievers/tests/vespa.int.test.ts b/libs/langchain-community/src/retrievers/tests/vespa.int.test.ts index 4c02d978df86..0a1dbac7eea3 100644 --- a/libs/langchain-community/src/retrievers/tests/vespa.int.test.ts +++ b/libs/langchain-community/src/retrievers/tests/vespa.int.test.ts @@ -20,7 +20,7 @@ test.skip("VespaRetriever", async () => { content_field, }); - const docs = await retriever.getRelevantDocuments("what is vespa?"); + const docs = await retriever.invoke("what is vespa?"); expect(docs.length).toBeGreaterThan(0); console.log(docs); diff --git a/libs/langchain-community/src/retrievers/tests/zep.int.test.ts b/libs/langchain-community/src/retrievers/tests/zep.int.test.ts index a7c4dd26a33c..a2c050a2a795 100644 --- a/libs/langchain-community/src/retrievers/tests/zep.int.test.ts +++ b/libs/langchain-community/src/retrievers/tests/zep.int.test.ts @@ -30,7 +30,7 @@ test.skip("ZepRetriever - memory exists", async () => { const sleep = promisify(setTimeout); await sleep(2000); - const docs = await zepRetriever.getRelevantDocuments("hello"); + const docs = await zepRetriever.invoke("hello"); expect(docs.length).toBeGreaterThanOrEqual(2); @@ -43,7 +43,7 @@ test.skip("ZepRetriever - does not exist", async () => { const zepRetriever = new ZepRetriever({ sessionId, url: baseURL, topK }); - const docs = await zepRetriever.getRelevantDocuments("hello"); + const docs = await zepRetriever.invoke("hello"); expect(docs.length).toBe(0); diff --git a/libs/langchain-community/src/retrievers/vespa.ts b/libs/langchain-community/src/retrievers/vespa.ts index f9a91fa2b1b3..04500a774f88 100644 --- a/libs/langchain-community/src/retrievers/vespa.ts +++ b/libs/langchain-community/src/retrievers/vespa.ts @@ -33,7 +33,7 @@ export interface VespaRetrieverParams extends RemoteRetrieverParams { * }, * content_field: "content", * }); - * const result = await retriever.getRelevantDocuments("what is vespa?"); + * const result = await retriever.invoke("what is vespa?"); * ``` */ export class VespaRetriever extends RemoteRetriever { diff --git a/libs/langchain-community/src/retrievers/zep.ts b/libs/langchain-community/src/retrievers/zep.ts index 5ea21ab6c83f..f2792d1a5aa3 100644 --- a/libs/langchain-community/src/retrievers/zep.ts +++ b/libs/langchain-community/src/retrievers/zep.ts @@ -42,7 +42,7 @@ export interface ZepRetrieverConfig extends BaseRetrieverInput { * topK: 3, * }); * const query = "Can I drive red cars in France?"; - * const docs = await retriever.getRelevantDocuments(query); + * const docs = await retriever.invoke(query); * ``` */ export class ZepRetriever extends BaseRetriever { diff --git a/libs/langchain-community/src/retrievers/zep_cloud.ts b/libs/langchain-community/src/retrievers/zep_cloud.ts index 3e9b83384a0a..d893f1388707 100644 --- a/libs/langchain-community/src/retrievers/zep_cloud.ts +++ b/libs/langchain-community/src/retrievers/zep_cloud.ts @@ -41,7 +41,7 @@ export interface ZepCloudRetrieverConfig extends BaseRetrieverInput { * topK: 3, * }); * const query = "Can I drive red cars in France?"; - * const docs = await retriever.getRelevantDocuments(query); + * const docs = await retriever.invoke(query); * ``` */ export class ZepCloudRetriever extends BaseRetriever { diff --git a/libs/langchain-community/src/structured_query/chroma.ts b/libs/langchain-community/src/structured_query/chroma.ts index 9bc7332117f9..1aea8a702c1a 100644 --- a/libs/langchain-community/src/structured_query/chroma.ts +++ b/libs/langchain-community/src/structured_query/chroma.ts @@ -21,7 +21,7 @@ import { Chroma } from "../vectorstores/chroma.js"; * structuredQueryTranslator: chromaTranslator, * }); * - * const relevantDocuments = await selfQueryRetriever.getRelevantDocuments( + * const relevantDocuments = await selfQueryRetriever.invoke( * "Which movies are directed by Greta Gerwig?", * ); * ``` diff --git a/libs/langchain-community/src/structured_query/qdrant.ts b/libs/langchain-community/src/structured_query/qdrant.ts index 65f11fa9f402..25ff8eed28fe 100644 --- a/libs/langchain-community/src/structured_query/qdrant.ts +++ b/libs/langchain-community/src/structured_query/qdrant.ts @@ -32,7 +32,7 @@ import { * structuredQueryTranslator: new QdrantTranslator(), * }); * - * const relevantDocuments = await selfQueryRetriever.getRelevantDocuments( + * const relevantDocuments = await selfQueryRetriever.invoke( * "Which movies are rated higher than 8.5?", * ); * ``` diff --git a/libs/langchain-community/src/structured_query/supabase.ts b/libs/langchain-community/src/structured_query/supabase.ts index 7f09b522d009..80af5d35b47c 100644 --- a/libs/langchain-community/src/structured_query/supabase.ts +++ b/libs/langchain-community/src/structured_query/supabase.ts @@ -50,7 +50,7 @@ type ValueType = { * structuredQueryTranslator: new SupabaseTranslator(), * }); * - * const queryResult = await selfQueryRetriever.getRelevantDocuments( + * const queryResult = await selfQueryRetriever.invoke( * "Which movies are directed by Greta Gerwig?", * ); * ``` diff --git a/libs/langchain-community/src/structured_query/tests/chroma_self_query.int.test.ts b/libs/langchain-community/src/structured_query/tests/chroma_self_query.int.test.ts index acad03175c9a..4f577e5172ed 100644 --- a/libs/langchain-community/src/structured_query/tests/chroma_self_query.int.test.ts +++ b/libs/langchain-community/src/structured_query/tests/chroma_self_query.int.test.ts @@ -86,16 +86,16 @@ test.skip("Chroma Store Self Query Retriever Test", async () => { structuredQueryTranslator: new ChromaTranslator(), }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Which movies are either comedy or drama and are less than 90 minutes?" ); console.log(query1, query2, query3, query4); diff --git a/libs/langchain-community/src/structured_query/tests/hnswlib_self_query.int.test.ts b/libs/langchain-community/src/structured_query/tests/hnswlib_self_query.int.test.ts index 28998f2b22c7..f90a88cbe7da 100644 --- a/libs/langchain-community/src/structured_query/tests/hnswlib_self_query.int.test.ts +++ b/libs/langchain-community/src/structured_query/tests/hnswlib_self_query.int.test.ts @@ -89,19 +89,19 @@ test("HNSWLib Store Self Query Retriever Test", async () => { structuredQueryTranslator: new FunctionalTranslator(), }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); console.log(query1); expect(query1.length).toEqual(0); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); console.log(query2); expect(query2.length).toEqual(2); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); console.log(query3); @@ -184,7 +184,7 @@ test("HNSWLib shouldn't throw an error if a filter can't be generated, but shoul structuredQueryTranslator: new FunctionalTranslator(), }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which sectionTitle talks about pools?" ); console.log(query1); diff --git a/libs/langchain-community/src/structured_query/tests/qdrant_self_query.int.test.ts b/libs/langchain-community/src/structured_query/tests/qdrant_self_query.int.test.ts index 2ce292d34d40..10badc783f97 100644 --- a/libs/langchain-community/src/structured_query/tests/qdrant_self_query.int.test.ts +++ b/libs/langchain-community/src/structured_query/tests/qdrant_self_query.int.test.ts @@ -92,19 +92,19 @@ test("Qdrant Vector Store Self Query Retriever Test", async () => { structuredQueryTranslator: new QdrantTranslator(), }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); expect(query1.length).toEqual(0); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); expect(query2.length).toEqual(2); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which cool movies are directed by Greta Gerwig?" ); @@ -233,25 +233,25 @@ test("Qdrant Vector Store Self Query Retriever Test With Default Filter Or Merge }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); expect(query1.length).toEqual(6); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); expect(query2.length).toEqual(7); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); expect(query3.length).toEqual(6); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Awawawa au au au wawawawa hello?" ); @@ -380,25 +380,25 @@ test("Qdrant Vector Store Self Query Retriever Test With Default Filter And Merg }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); expect(query1.length).toEqual(0); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); expect(query2.length).toEqual(2); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which cool movies are directed by Greta Gerwig?" ); expect(query3.length).toEqual(1); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Awawawa au au au wawawawa hello?" ); diff --git a/libs/langchain-community/src/structured_query/tests/supabase_self_query.int.test.ts b/libs/langchain-community/src/structured_query/tests/supabase_self_query.int.test.ts index ba7859b672bf..c262f7d74930 100644 --- a/libs/langchain-community/src/structured_query/tests/supabase_self_query.int.test.ts +++ b/libs/langchain-community/src/structured_query/tests/supabase_self_query.int.test.ts @@ -120,23 +120,23 @@ test("Supabase Store Self Query Retriever Test", async () => { structuredQueryTranslator: new SupabaseTranslator(), }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); console.log(query1); expect(query1.length).toEqual(0); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); console.log(query2); expect(query2.length).toEqual(3); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); console.log(query3); expect(query3.length).toEqual(1); - const query4 = await selfQueryRetriever.getRelevantDocuments("What is what"); // this should return empty since it'll create empty filter + const query4 = await selfQueryRetriever.invoke("What is what"); // this should return empty since it'll create empty filter console.log(query4); expect(query4.length).toEqual(0); }); @@ -273,23 +273,23 @@ test("Supabase Store Self Query Retriever Test With Default Filter And Merge Ope }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); console.log(query1); expect(query1.length).toEqual(0); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); console.log(query2); expect(query2.length).toEqual(2); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); console.log(query3); expect(query3.length).toEqual(1); - const query4 = await selfQueryRetriever.getRelevantDocuments("What is what"); // query4 has to empty document, since we can't use "or" operator + const query4 = await selfQueryRetriever.invoke("What is what"); // query4 has to empty document, since we can't use "or" operator console.log(query4); expect(query4.length).toEqual(0); }); @@ -428,23 +428,23 @@ test("Supabase Store Self Query Retriever Test With Default Filter Or Merge Oper }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); console.log(query1); expect(query1.length).toEqual(5); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); console.log(query2); expect(query2.length).toEqual(6); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); console.log(query3); expect(query3.length).toEqual(5); - const query4 = await selfQueryRetriever.getRelevantDocuments("What is what"); + const query4 = await selfQueryRetriever.invoke("What is what"); console.log(query4); expect(query4.length).toEqual(5); }); @@ -582,23 +582,23 @@ test("Supabase Store Self Query Retriever Test With Default Filter And Merge Ope }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); console.log(query1); expect(query1.length).toEqual(0); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); console.log(query2); expect(query2.length).toEqual(2); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); console.log(query3); expect(query3.length).toEqual(1); - const query4 = await selfQueryRetriever.getRelevantDocuments("What is what"); // query4 has to empty document, since we can't use "or" operator + const query4 = await selfQueryRetriever.invoke("What is what"); // query4 has to empty document, since we can't use "or" operator console.log(query4); expect(query4.length).toEqual(0); }); diff --git a/libs/langchain-community/src/structured_query/tests/vectara_self_query.int.test.ts b/libs/langchain-community/src/structured_query/tests/vectara_self_query.int.test.ts index ae5e2fc92ae7..74100772b5e8 100644 --- a/libs/langchain-community/src/structured_query/tests/vectara_self_query.int.test.ts +++ b/libs/langchain-community/src/structured_query/tests/vectara_self_query.int.test.ts @@ -93,16 +93,16 @@ test.skip("Vectara Self Query Retriever Test", async () => { structuredQueryTranslator: new VectaraTranslator(), }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "I want to watch a movie rated higher than 8.5" ); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are either comedy or science fiction and are rated higher than 8.5?" ); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Wau wau wau wau hello gello hello?" ); console.log(query1, query2, query3, query4); diff --git a/libs/langchain-community/src/vectorstores/tests/azure_aisearch.int.test.ts b/libs/langchain-community/src/vectorstores/tests/azure_aisearch.int.test.ts index 5630dbcc22c5..9f8487975cc9 100644 --- a/libs/langchain-community/src/vectorstores/tests/azure_aisearch.int.test.ts +++ b/libs/langchain-community/src/vectorstores/tests/azure_aisearch.int.test.ts @@ -138,7 +138,7 @@ describe.skip("AzureAISearchVectorStore e2e integration tests", () => { const retriever = vectorStore.asRetriever({}); - const docs = await retriever.getRelevantDocuments("house"); + const docs = await retriever.invoke("house"); expect(docs).toBeDefined(); expect(docs[0]).toMatchObject({ pageContent: "The house is open", @@ -184,7 +184,7 @@ describe.skip("AzureAISearchVectorStore e2e integration tests", () => { const standardRetriever = await vectorStore.asRetriever(); const standardRetrieverOutput = - await standardRetriever.getRelevantDocuments("foo"); + await standardRetriever.invoke("foo"); expect(output).toHaveLength(texts.length); const standardRetrieverActual = standardRetrieverOutput.map( @@ -201,7 +201,7 @@ describe.skip("AzureAISearchVectorStore e2e integration tests", () => { }, }); - const retrieverOutput = await retriever.getRelevantDocuments("foo"); + const retrieverOutput = await retriever.invoke("foo"); expect(output).toHaveLength(texts.length); const retrieverActual = retrieverOutput.map((doc) => doc.pageContent); diff --git a/libs/langchain-community/src/vectorstores/tests/azure_cosmosdb.int.test.ts b/libs/langchain-community/src/vectorstores/tests/azure_cosmosdb.int.test.ts index b408bfbc3b12..7529e3d915e1 100644 --- a/libs/langchain-community/src/vectorstores/tests/azure_cosmosdb.int.test.ts +++ b/libs/langchain-community/src/vectorstores/tests/azure_cosmosdb.int.test.ts @@ -95,7 +95,7 @@ describe.skip("AzureCosmosDBVectorStore", () => { const retriever = vectorStore.asRetriever({}); - const docs = await retriever.getRelevantDocuments("house"); + const docs = await retriever.invoke("house"); expect(docs).toBeDefined(); expect(docs[0]).toMatchObject({ pageContent: "The house is open", @@ -136,7 +136,7 @@ describe.skip("AzureCosmosDBVectorStore", () => { const standardRetriever = await vectorStore.asRetriever(); const standardRetrieverOutput = - await standardRetriever.getRelevantDocuments("foo"); + await standardRetriever.invoke("foo"); expect(output).toHaveLength(texts.length); const standardRetrieverActual = standardRetrieverOutput.map( @@ -153,7 +153,7 @@ describe.skip("AzureCosmosDBVectorStore", () => { }, }); - const retrieverOutput = await retriever.getRelevantDocuments("foo"); + const retrieverOutput = await retriever.invoke("foo"); expect(output).toHaveLength(texts.length); const retrieverActual = retrieverOutput.map((doc) => doc.pageContent); diff --git a/libs/langchain-community/src/vectorstores/tests/hanavector.int.test.ts b/libs/langchain-community/src/vectorstores/tests/hanavector.int.test.ts index 465d7736c2e2..5e47d12f8b3d 100644 --- a/libs/langchain-community/src/vectorstores/tests/hanavector.int.test.ts +++ b/libs/langchain-community/src/vectorstores/tests/hanavector.int.test.ts @@ -288,7 +288,7 @@ describe("add documents and similarity search tests", () => { const retriever = vectorStore.asRetriever({}); - const docs = await retriever.getRelevantDocuments("house"); + const docs = await retriever.invoke("house"); expect(docs).toBeDefined(); expect(docs[0]).toMatchObject({ pageContent: "The house is open", @@ -328,7 +328,7 @@ describe("add documents and similarity search tests", () => { const standardRetriever = vectorStore.asRetriever(); const standardRetrieverOutput = - await standardRetriever.getRelevantDocuments("foo"); + await standardRetriever.invoke("foo"); expect(output).toHaveLength(texts.length); const standardRetrieverActual = standardRetrieverOutput.map( @@ -345,7 +345,7 @@ describe("add documents and similarity search tests", () => { }, }); - const retrieverOutput = await retriever.getRelevantDocuments("foo"); + const retrieverOutput = await retriever.invoke("foo"); expect(output).toHaveLength(texts.length); const retrieverActual = retrieverOutput.map((doc) => doc.pageContent); diff --git a/libs/langchain-community/src/vectorstores/tests/vectara.int.test.ts b/libs/langchain-community/src/vectorstores/tests/vectara.int.test.ts index d8a7daf64eec..672e7a024849 100644 --- a/libs/langchain-community/src/vectorstores/tests/vectara.int.test.ts +++ b/libs/langchain-community/src/vectorstores/tests/vectara.int.test.ts @@ -226,7 +226,7 @@ describe("VectaraStore", () => { lambda: 0.025, }, }); - const result = await retriever.getRelevantDocuments("Was Gandalf dead?"); + const result = await retriever.invoke("Was Gandalf dead?"); expect(result.length).toBeGreaterThan(0); expect(result.length).toBe(topK + 1); // +1 for the summary expect(result[0].pageContent.length).toBeGreaterThan(0); diff --git a/libs/langchain-exa/src/retrievers.ts b/libs/langchain-exa/src/retrievers.ts index 77afd0c4185c..434775a56297 100644 --- a/libs/langchain-exa/src/retrievers.ts +++ b/libs/langchain-exa/src/retrievers.ts @@ -36,7 +36,7 @@ export function _getMetadata( * process.env.EXA_BASE_URL, * ), * }); - * const docs = await retriever.getRelevantDocuments("hello"); + * const docs = await retriever.invoke("hello"); * ``` */ export class ExaRetriever< diff --git a/libs/langchain-exa/src/tests/retrievers.int.test.ts b/libs/langchain-exa/src/tests/retrievers.int.test.ts index 263faf8177f9..353b8aa2700f 100644 --- a/libs/langchain-exa/src/tests/retrievers.int.test.ts +++ b/libs/langchain-exa/src/tests/retrievers.int.test.ts @@ -8,7 +8,7 @@ test("ExaRetriever can retrieve some data", async () => { client: new Exa(), }); - const results = await exaRetriever.getRelevantDocuments( + const results = await exaRetriever.invoke( "What does the AI company LangChain do?" ); diff --git a/libs/langchain-mongodb/src/tests/vectorstores.int.test.ts b/libs/langchain-mongodb/src/tests/vectorstores.int.test.ts index 069bb4ef3aff..719a52910efa 100644 --- a/libs/langchain-mongodb/src/tests/vectorstores.int.test.ts +++ b/libs/langchain-mongodb/src/tests/vectorstores.int.test.ts @@ -97,7 +97,7 @@ test("MongoDBAtlasVectorSearch with external ids", async () => { // }, // }); - // const docs = await retriever.getRelevantDocuments("That fence is purple"); + // const docs = await retriever.invoke("That fence is purple"); // expect(docs).toEqual([]); } finally { await client.close(); @@ -142,7 +142,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => { const standardRetriever = await vectorStore.asRetriever(); const standardRetrieverOutput = - await standardRetriever.getRelevantDocuments("foo"); + await standardRetriever.invoke("foo"); expect(output).toHaveLength(texts.length); const standardRetrieverActual = standardRetrieverOutput.map( @@ -159,7 +159,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => { }, }); - const retrieverOutput = await retriever.getRelevantDocuments("foo"); + const retrieverOutput = await retriever.invoke("foo"); expect(output).toHaveLength(texts.length); const retrieverActual = retrieverOutput.map((doc) => doc.pageContent); diff --git a/libs/langchain-pinecone/src/tests/translator.int.test.ts b/libs/langchain-pinecone/src/tests/translator.int.test.ts index 43b2751fbb23..476e2f73ab1e 100644 --- a/libs/langchain-pinecone/src/tests/translator.int.test.ts +++ b/libs/langchain-pinecone/src/tests/translator.int.test.ts @@ -144,19 +144,19 @@ describe("Pinecone self query", () => { }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Which movies are either comedy or drama and are less than 90 minutes?" ); - const query5 = await selfQueryRetriever.getRelevantDocuments( + const query5 = await selfQueryRetriever.invoke( "Awawawawa hello hello hello huh where am i?" ); console.log(query1, query2, query3, query4, query5); // query 5 should return documents @@ -296,19 +296,19 @@ describe("Pinecone self query", () => { }, }); - const query1 = await selfQueryRetriever.getRelevantDocuments( + const query1 = await selfQueryRetriever.invoke( "Which movies are less than 90 minutes?" ); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Which movies are either comedy or drama and are less than 90 minutes?" ); - const query5 = await selfQueryRetriever.getRelevantDocuments( + const query5 = await selfQueryRetriever.invoke( "Awawawawa hello hello hello huh where am i?" ); console.log(query1, query2, query3, query4, query5); // query 5 should return documents diff --git a/libs/langchain-pinecone/src/translator.ts b/libs/langchain-pinecone/src/translator.ts index 5dcf8de9afdc..64c0fa2ca670 100644 --- a/libs/langchain-pinecone/src/translator.ts +++ b/libs/langchain-pinecone/src/translator.ts @@ -21,7 +21,7 @@ import { * structuredQueryTranslator: new PineconeTranslator(), * }); * - * const queryResult = await selfQueryRetriever.getRelevantDocuments( + * const queryResult = await selfQueryRetriever.invoke( * "Which movies are directed by Greta Gerwig?", * ); * ``` diff --git a/libs/langchain-weaviate/src/tests/translator.int.test.ts b/libs/langchain-weaviate/src/tests/translator.int.test.ts index 4c3a85867f0a..510117884b42 100644 --- a/libs/langchain-weaviate/src/tests/translator.int.test.ts +++ b/libs/langchain-weaviate/src/tests/translator.int.test.ts @@ -105,13 +105,13 @@ test.skip("Weaviate Self Query Retriever Test", async () => { structuredQueryTranslator: new WeaviateTranslator(), }); - const query2 = await selfQueryRetriever.getRelevantDocuments( + const query2 = await selfQueryRetriever.invoke( "Which movies are rated higher than 8.5?" ); - const query3 = await selfQueryRetriever.getRelevantDocuments( + const query3 = await selfQueryRetriever.invoke( "Which movies are directed by Greta Gerwig?" ); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Wau wau wau wau hello gello hello?" ); console.log(query2, query3, query4); // query4 has to return empty array @@ -258,7 +258,7 @@ test.skip("Weaviate Vector Store Self Query Retriever Test With Default Filter O }, }); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Wau wau wau wau hello gello hello?" ); console.log(query4); // query4 has to return documents, since the default filter takes over with @@ -405,7 +405,7 @@ test.skip("Weaviate Vector Store Self Query Retriever Test With Default Filter A }, }); - const query4 = await selfQueryRetriever.getRelevantDocuments( + const query4 = await selfQueryRetriever.invoke( "Wau wau wau wau hello gello hello?" ); console.log(query4); // query4 has to return empty array, since the default filter takes over with and filter diff --git a/libs/langchain-weaviate/src/translator.ts b/libs/langchain-weaviate/src/translator.ts index 1302b7d06740..28c500809592 100644 --- a/libs/langchain-weaviate/src/translator.ts +++ b/libs/langchain-weaviate/src/translator.ts @@ -67,7 +67,7 @@ export type WeaviateStructuredQueryResult = { * structuredQueryTranslator: new WeaviateTranslator(), * }); * - * const relevantDocuments = await selfQueryRetriever.getRelevantDocuments( + * const relevantDocuments = await selfQueryRetriever.invoke( * "Which movies are rated higher than 8.5?", * ); * ``` From 54f75760630d62a42ab3b49122338d044c39f07c Mon Sep 17 00:00:00 2001 From: bracesproul Date: Wed, 12 Jun 2024 15:41:50 -0700 Subject: [PATCH 2/2] chore: lint files --- docs/core_docs/docs/tutorials/agents.mdx | 4 +--- .../src/retrievers/parent_document_retriever_rerank.ts | 4 +--- .../violation_of_expectations_chain.ts | 4 +--- langchain/src/retrievers/multi_query.ts | 5 +---- langchain/src/retrievers/tests/hyde.int.test.ts | 8 ++------ .../src/vectorstores/tests/azure_aisearch.int.test.ts | 3 +-- .../src/vectorstores/tests/azure_cosmosdb.int.test.ts | 3 +-- .../src/vectorstores/tests/hanavector.int.test.ts | 3 +-- libs/langchain-mongodb/src/tests/vectorstores.int.test.ts | 3 +-- 9 files changed, 10 insertions(+), 27 deletions(-) diff --git a/docs/core_docs/docs/tutorials/agents.mdx b/docs/core_docs/docs/tutorials/agents.mdx index 73849c2aeb6c..3dad19ed2029 100644 --- a/docs/core_docs/docs/tutorials/agents.mdx +++ b/docs/core_docs/docs/tutorials/agents.mdx @@ -83,9 +83,7 @@ const vectorstore = await MemoryVectorStore.fromDocuments( ); const retriever = vectorstore.asRetriever(); -const retrieverResult = await retriever.invoke( - "how to upload a dataset" -); +const retrieverResult = await retriever.invoke("how to upload a dataset"); console.log(retrieverResult[0]); /* diff --git a/examples/src/retrievers/parent_document_retriever_rerank.ts b/examples/src/retrievers/parent_document_retriever_rerank.ts index ff5ce56cd7f5..f0918b602a67 100644 --- a/examples/src/retrievers/parent_document_retriever_rerank.ts +++ b/examples/src/retrievers/parent_document_retriever_rerank.ts @@ -69,9 +69,7 @@ await retriever.addDocuments(docs); // This will search for documents in vector store and return for LLM already reranked and sorted document // with appropriate minimum relevance score -const retrievedDocs = await retriever.invoke( - "What is Pam's favorite color?" -); +const retrievedDocs = await retriever.invoke("What is Pam's favorite color?"); // Pam's favorite color is returned first! console.log(JSON.stringify(retrievedDocs, null, 2)); diff --git a/langchain/src/experimental/chains/violation_of_expectations/violation_of_expectations_chain.ts b/langchain/src/experimental/chains/violation_of_expectations/violation_of_expectations_chain.ts index 31d74b285011..10091ee3b613 100644 --- a/langchain/src/experimental/chains/violation_of_expectations/violation_of_expectations_chain.ts +++ b/langchain/src/experimental/chains/violation_of_expectations/violation_of_expectations_chain.ts @@ -294,9 +294,7 @@ export class ViolationOfExpectationsChain // Only extract the first relevant doc from the retriever. We don't need more than one. const relevantInsightsDocuments = await Promise.all( insights.map(async (insight) => { - const relevantInsight = await this.retriever.invoke( - insight - ); + const relevantInsight = await this.retriever.invoke(insight); return relevantInsight[0]; }) ); diff --git a/langchain/src/retrievers/multi_query.ts b/langchain/src/retrievers/multi_query.ts index 574277760fa2..410075f53ab0 100644 --- a/langchain/src/retrievers/multi_query.ts +++ b/langchain/src/retrievers/multi_query.ts @@ -159,10 +159,7 @@ export class MultiQueryRetriever extends BaseRetriever { const documents: Document[] = []; await Promise.all( queries.map(async (query) => { - const docs = await this.retriever.invoke( - query, - runManager?.getChild() - ); + const docs = await this.retriever.invoke(query, runManager?.getChild()); documents.push(...docs); }) ); diff --git a/langchain/src/retrievers/tests/hyde.int.test.ts b/langchain/src/retrievers/tests/hyde.int.test.ts index f3fb99868f2b..8cbff5c84525 100644 --- a/langchain/src/retrievers/tests/hyde.int.test.ts +++ b/langchain/src/retrievers/tests/hyde.int.test.ts @@ -23,9 +23,7 @@ test("Hyde retriever", async () => { ].map((pageContent) => new Document({ pageContent })) ); - const results = await retriever.invoke( - "What is my favourite food?" - ); + const results = await retriever.invoke("What is my favourite food?"); expect(results.length).toBe(1); console.log(results); @@ -51,9 +49,7 @@ test("Hyde retriever with default prompt template", async () => { ].map((pageContent) => new Document({ pageContent })) ); - const results = await retriever.invoke( - "What is my favourite food?" - ); + const results = await retriever.invoke("What is my favourite food?"); expect(results.length).toBe(1); console.log(results); diff --git a/libs/langchain-community/src/vectorstores/tests/azure_aisearch.int.test.ts b/libs/langchain-community/src/vectorstores/tests/azure_aisearch.int.test.ts index 9f8487975cc9..4945e9b7b024 100644 --- a/libs/langchain-community/src/vectorstores/tests/azure_aisearch.int.test.ts +++ b/libs/langchain-community/src/vectorstores/tests/azure_aisearch.int.test.ts @@ -183,8 +183,7 @@ describe.skip("AzureAISearchVectorStore e2e integration tests", () => { const standardRetriever = await vectorStore.asRetriever(); - const standardRetrieverOutput = - await standardRetriever.invoke("foo"); + const standardRetrieverOutput = await standardRetriever.invoke("foo"); expect(output).toHaveLength(texts.length); const standardRetrieverActual = standardRetrieverOutput.map( diff --git a/libs/langchain-community/src/vectorstores/tests/azure_cosmosdb.int.test.ts b/libs/langchain-community/src/vectorstores/tests/azure_cosmosdb.int.test.ts index 7529e3d915e1..75c78048eaa4 100644 --- a/libs/langchain-community/src/vectorstores/tests/azure_cosmosdb.int.test.ts +++ b/libs/langchain-community/src/vectorstores/tests/azure_cosmosdb.int.test.ts @@ -135,8 +135,7 @@ describe.skip("AzureCosmosDBVectorStore", () => { const standardRetriever = await vectorStore.asRetriever(); - const standardRetrieverOutput = - await standardRetriever.invoke("foo"); + const standardRetrieverOutput = await standardRetriever.invoke("foo"); expect(output).toHaveLength(texts.length); const standardRetrieverActual = standardRetrieverOutput.map( diff --git a/libs/langchain-community/src/vectorstores/tests/hanavector.int.test.ts b/libs/langchain-community/src/vectorstores/tests/hanavector.int.test.ts index 5e47d12f8b3d..330a027ecc4d 100644 --- a/libs/langchain-community/src/vectorstores/tests/hanavector.int.test.ts +++ b/libs/langchain-community/src/vectorstores/tests/hanavector.int.test.ts @@ -327,8 +327,7 @@ describe("add documents and similarity search tests", () => { const standardRetriever = vectorStore.asRetriever(); - const standardRetrieverOutput = - await standardRetriever.invoke("foo"); + const standardRetrieverOutput = await standardRetriever.invoke("foo"); expect(output).toHaveLength(texts.length); const standardRetrieverActual = standardRetrieverOutput.map( diff --git a/libs/langchain-mongodb/src/tests/vectorstores.int.test.ts b/libs/langchain-mongodb/src/tests/vectorstores.int.test.ts index 719a52910efa..a8930bff6089 100644 --- a/libs/langchain-mongodb/src/tests/vectorstores.int.test.ts +++ b/libs/langchain-mongodb/src/tests/vectorstores.int.test.ts @@ -141,8 +141,7 @@ test("MongoDBAtlasVectorSearch with Maximal Marginal Relevance", async () => { const standardRetriever = await vectorStore.asRetriever(); - const standardRetrieverOutput = - await standardRetriever.invoke("foo"); + const standardRetrieverOutput = await standardRetriever.invoke("foo"); expect(output).toHaveLength(texts.length); const standardRetrieverActual = standardRetrieverOutput.map(