Skip to content

The agent engineering platform.

added documentation on retrieving a PG vectorstore (#4578)

Neil Ruaro3a2855945b6f
diff --git a/docs/modules/indexes/vectorstores/examples/pgvector.ipynb b/docs/modules/indexes/vectorstores/examples/pgvector.ipynb
index d6af1bf253..3674828ba3 100644
--- a/docs/modules/indexes/vectorstores/examples/pgvector.ipynb
+++ b/docs/modules/indexes/vectorstores/examples/pgvector.ipynb
@@ -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": {