-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration[patch]: feat: implement max marginal relevance search for…
… Weaviate vector store (#3395) * feat: implement max marginal relevance search for Weaviate vector store * formatting * Adds docs --------- Co-authored-by: jacoblee93 <[email protected]>
- Loading branch information
1 parent
85470e4
commit ed51ace
Showing
3 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import weaviate from "weaviate-ts-client"; | ||
import { WeaviateStore } from "langchain/vectorstores/weaviate"; | ||
import { OpenAIEmbeddings } from "langchain/embeddings/openai"; | ||
|
||
export async function run() { | ||
// Something wrong with the weaviate-ts-client types, so we need to disable | ||
const client = (weaviate as any).client({ | ||
scheme: process.env.WEAVIATE_SCHEME || "https", | ||
host: process.env.WEAVIATE_HOST || "localhost", | ||
apiKey: new (weaviate as any).ApiKey( | ||
process.env.WEAVIATE_API_KEY || "default" | ||
), | ||
}); | ||
|
||
// Create a store for an existing index | ||
const store = await WeaviateStore.fromExistingIndex(new OpenAIEmbeddings(), { | ||
client, | ||
indexName: "Test", | ||
metadataKeys: ["foo"], | ||
}); | ||
|
||
const resultOne = await store.maxMarginalRelevanceSearch("Hello world", { | ||
k: 1, | ||
}); | ||
|
||
console.log(resultOne); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ed51ace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
langchainjs-api-refs – ./docs/api_refs
langchainjs-api-refs-git-main-langchain.vercel.app
langchainjs-api-refs-langchain.vercel.app
langchainjs-api-docs.vercel.app
api.js.langchain.com