added documentation on retrieving a PG vectorstore (#4578)

This PR adds in documentation on querying an existing vectorstore in PG 

Fixes 3191 (issue)
parallel_dir_loader
Neil Ruaro 1 year ago committed by GitHub
parent 1e5d25b93c
commit 3a2855945b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -222,6 +222,63 @@
" print(doc.page_content)\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": {

Loading…
Cancel
Save