mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-05 20:58:25 +00:00
added documentation on retrieving a PG vectorstore (#4578)
This PR adds in documentation on querying an existing vectorstore in PG Fixes 3191 (issue)
This commit is contained in:
parent
1e5d25b93c
commit
3a2855945b
@ -222,6 +222,63 @@
|
|||||||
" print(doc.page_content)\n",
|
" print(doc.page_content)\n",
|
||||||
" print(\"-\" * 80)\n"
|
" print(\"-\" * 80)\n"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"attachments": {},
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Working with vectorstore in PG"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"attachments": {},
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Uploading a vectorstore in PG "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"db = PGVector.from_documents(\n",
|
||||||
|
" documents=data,\n",
|
||||||
|
" embedding=embeddings,\n",
|
||||||
|
" collection_name=collection_name,\n",
|
||||||
|
" connection_string=connection_string,\n",
|
||||||
|
" distance_strategy=DistanceStrategy.COSINE,\n",
|
||||||
|
" openai_api_key=api_key,\n",
|
||||||
|
" pre_delete_collection=False \n",
|
||||||
|
")"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"attachments": {},
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Retrieving a vectorstore in PG"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"store = PGVector(\n",
|
||||||
|
" connection_string=connection_string, \n",
|
||||||
|
" embedding_function=embedding, \n",
|
||||||
|
" collection_name=collection_name,\n",
|
||||||
|
" distance_strategy=DistanceStrategy.COSINE\n",
|
||||||
|
")\n",
|
||||||
|
"\n",
|
||||||
|
"retriever = store.as_retriever()"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
Loading…
Reference in New Issue
Block a user