[docs]: vector store integration pages (#24858)

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Isaac Francisco
2024-08-06 10:20:27 -07:00
committed by GitHub
parent 2c798622cd
commit a72fddbf8d
29 changed files with 5649 additions and 4436 deletions

View File

@@ -67,15 +67,13 @@
"import getpass\n",
"import os\n",
"\n",
"import os\n",
"\n",
"if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",
" import getpass\n",
" os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\"Enter your __ModuleName__ API key: \")"
]
},
{
"cell_type": "markdown",
"id": "7f98392b",
"metadata": {},
"source": [
"If you want to get automated tracing of your model calls you can also set your [LangSmith](https://docs.smith.langchain.com/) API key by uncommenting below:"
@@ -84,6 +82,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e7b6a6e0",
"metadata": {},
"outputs": [],
"source": [
@@ -96,9 +95,16 @@
"id": "93df377e",
"metadata": {},
"source": [
"## Instantiation\n",
"## Initialization\n",
"\n",
"- TODO: Fill out with relevant init params"
"- TODO: Fill out with relevant init params\n",
"\n",
"\n",
"```{=mdx}\n",
"import EmbeddingTabs from \"@theme/EmbeddingTabs\";\n",
"\n",
"<EmbeddingTabs/>\n",
"```"
]
},
{
@@ -112,7 +118,7 @@
"source": [
"from __module_name__.vectorstores import __ModuleName__VectorStore\n",
"\n",
"vector_store = __ModuleName__VectorStore()"
"vector_store = __ModuleName__VectorStore(embeddings=embeddings)"
]
},
{
@@ -146,14 +152,14 @@
" metadata={\"source\": \"https://example.com\"}\n",
")\n",
"\n",
"document_2 = Document(\n",
"document_3 = Document(\n",
" page_content=\"baz\",\n",
" metadata={\"source\": \"https://example.com\"}\n",
")\n",
"\n",
"documents = [document_1, document_2]\n",
"documents = [document_1, document_2, document_3]\n",
"\n",
"vector_store.add_documents(documents=documents,ids=[\"1\",\"2\"])"
"vector_store.add_documents(documents=documents,ids=[\"1\",\"2\",\"3\"])"
]
},
{
@@ -224,7 +230,7 @@
"metadata": {},
"outputs": [],
"source": [
"results = vector_store.similarity_search(query=\"thud\",k=1,filter={\"source\":\"https://example.com\"})\n",
"results = vector_store.similarity_search(query=\"thud\",k=1,filter={\"source\":\"https://another-example.com\"})\n",
"for doc in results:\n",
" print(f\"* {doc.page_content} [{doc.metadata}]\")"
]
@@ -270,7 +276,10 @@
"metadata": {},
"outputs": [],
"source": [
"retriever = vector_store.as_retriever()\n",
"retriever = vector_store.as_retriever(\n",
" search_type=\"mmr\",\n",
" search_kwargs={\"k\": 1}\n",
")\n",
"retriever.invoke(\"thud\")"
]
},
@@ -279,7 +288,15 @@
"id": "901c75dc",
"metadata": {},
"source": [
"Using retriever in a simple RAG chain:"
"## Chain usage\n",
"\n",
"The code below shows how to use the vector store as a retriever in a simple RAG chain:\n",
"\n",
"```{=mdx}\n",
"import ChatModelTabs from \"@theme/ChatModelTabs\";\n",
"\n",
"<ChatModelTabs customVarName=\"llm\" />\n",
"```"
]
},
{