diff --git a/docs/docs/integrations/vectorstores/azure_db_for_postgresql.ipynb b/docs/docs/integrations/vectorstores/azure_db_for_postgresql.ipynb new file mode 100644 index 0000000000000..d739849ac4060 --- /dev/null +++ b/docs/docs/integrations/vectorstores/azure_db_for_postgresql.ipynb @@ -0,0 +1,769 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "7679dd7b-7ed4-4755-a499-824deadba708", + "metadata": {}, + "source": [ + "# Azure Database for PostgreSQL - Flexible Server \n", + "\n", + "[Azure Database for PostgreSQL - Flexible Server](https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/service-overview) is a relational database service based on the open-source Postgres database engine. It's a fully managed database-as-a-service that can handle mission-critical workloads with predictable performance, security, high availability, and dynamic scalability.\n", + "\n", + "This notebook shows you how to leverage this integrated [vector database](https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-use-pgvector) to store documents in collections, create indicies and perform vector search queries using approximate nearest neighbor algorithms such as Cosine Distance, L2 (Euclidean distance), and IP (inner product) to locate documents close to the query vectors." + ] + }, + { + "cell_type": "markdown", + "id": "691dfd83", + "metadata": {}, + "source": [ + "## Vector Support on Azure Database for PostgreSQL - Flexible Server\n", + "\n", + "Azure Database for PostgreSQL - Flexible Server enables you to efficiently store and query millions of vector embeddings in PostgreSQL. As well as scale your AI use cases from POC to production:\n", + "\n", + "- Provides a familiar SQL interface for querying vector embeddings and relational data.\n", + "- Boosts `pgvector` with a faster and more precise similarity search across 100M+ vectors using [DiskANN indexing algorithm.](https://aka.ms/pg-diskann-docs)\n", + "- Simplifies operations by integrating relational metadata, vector embeddings, and time-series data into a single database.\n", + "- Leverages the power of the robust PostgreSQL ecosystem and Azure Cloud for enterprise-grade features inculding replication, and high availability." + ] + }, + { + "cell_type": "markdown", + "id": "fad650f8", + "metadata": {}, + "source": [ + "## Authentication\n", + "\n", + "Azure Database for PostgreSQL - Flexible Server supports password-based as well as [Microsoft Entra](https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-azure-ad-authentication) (formerly Azure Active Directory) authentication.\n", + "Entra authentication allows you to use Entra identity to authenticate to your PostgreSQL server. This eliminates the need to manage separate usernames and passwords for your database users, and allows\n", + "you to leverage the same security mechanisms that you use for other Azure services.\n", + "\n", + "This notebook is set up to use either authentication method. You can configure whether or not to use Entra authentication later in the notebook." + ] + }, + { + "cell_type": "markdown", + "id": "3a8395e7", + "metadata": {}, + "source": [ + "## Setup\n", + "\n", + "Since Azure Database for PostgreSQL is open-source Postgres, you can use the [LangChain's Postgres support](https://python.langchain.com/docs/integrations/vectorstores/pgvector/) to connect to Azure Database for PostgreSQL.\n", + "First download the partner package:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "92df32f0", + "metadata": {}, + "outputs": [], + "source": [ + "%pip install -qU langchain-azure-postgresql\n", + "%pip install -qU langchain-openai\n", + "%pip install -qU azure-identity" + ] + }, + { + "cell_type": "markdown", + "id": "2d7be081", + "metadata": {}, + "source": [ + "### Enable pgvector on Azure Database for PostgreSQL - Flexible Server" + ] + }, + { + "cell_type": "markdown", + "id": "2b61d745", + "metadata": {}, + "source": [ + "See [enablement instructions](https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-use-pgvector) for Azure Database for PostgreSQL." + ] + }, + { + "cell_type": "markdown", + "id": "eee31ce1-2c28-484d-82be-d22d9f9a31fd", + "metadata": {}, + "source": [ + "### Set up credentials\n", + "\n", + "You will need you Azure Database for PostgreSQL [connection details](https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/quickstart-create-server-portal#get-the-connection-information) and add them as environment variables to run this notebook.\n", + "\n", + "Set the `USE_ENTRA_AUTH` flag to `True` if you want to use Microsoft Entra authentication. If using Entra authentication, you will only need to supply the host and database name. If using password authentication, you'll also need to set the username and password." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ed8c87bf", + "metadata": {}, + "outputs": [], + "source": [ + "import getpass\n", + "import os\n", + "\n", + "USE_ENTRA_AUTH = True\n", + "\n", + "# Supply the connection details for the database\n", + "os.environ[\"DBHOST\"] = \"REPLACE_WITH_SERVER_NAME\"\n", + "os.environ[\"DBNAME\"] = \"REPLACE_WITH_DATABASE_NAME\"\n", + "os.environ[\"SSLMODE\"] = \"require\"\n", + "\n", + "if not USE_ENTRA_AUTH:\n", + " # If using a username and password, supply them here\n", + " os.environ[\"DBUSER\"] = \"REPLACE_WITH_USERNAME\"\n", + " os.environ[\"DBPASSWORD\"] = getpass.getpass(\"Database Password:\")" + ] + }, + { + "cell_type": "markdown", + "id": "ec44dfcc", + "metadata": {}, + "source": [ + "### Setup Azure OpenAI Embeddings" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "666b40ee", + "metadata": {}, + "outputs": [], + "source": [ + "os.environ[\"AZURE_OPENAI_ENDPOINT\"] = \"REPLACE_WITH_AZURE_OPENAI_ENDPOINT\"\n", + "os.environ[\"AZURE_OPENAI_API_KEY\"] = getpass.getpass(\"Azure OpenAI API Key:\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "94f5c129", + "metadata": {}, + "outputs": [], + "source": [ + "AZURE_OPENAI_ENDPOINT = os.environ[\"AZURE_OPENAI_ENDPOINT\"]\n", + "AZURE_OPENAI_API_KEY = os.environ[\"AZURE_OPENAI_API_KEY\"]\n", + "\n", + "from langchain_openai import AzureOpenAIEmbeddings\n", + "\n", + "embeddings = AzureOpenAIEmbeddings(\n", + " model=\"text-embedding-3-small\",\n", + " api_key=AZURE_OPENAI_API_KEY,\n", + " azure_endpoint=AZURE_OPENAI_ENDPOINT,\n", + " azure_deployment=\"text-embedding-3-small\",\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "dbe21d1c", + "metadata": {}, + "source": [ + "## Initialization" + ] + }, + { + "cell_type": "markdown", + "id": "fa69c6c7", + "metadata": {}, + "source": [ + "### Use Microsoft Entra authentication\n", + "\n", + "The following sections demonstrate how to set up LangChain to use Microsoft Entra authentication. The class `AzurePGConnectionPool` in the LangChain Azure Postgres package retrieves tokens for the Azure Database for PostgreSQL service by using `DefaultAzureCredential` from the `azure.identity` library.\n", + "\n", + "The connection can be passed into the `connection` parameter of the `AzurePGVectorStore` LangChain vector store.\n", + "\n", + "#### Sign in to Azure\n", + "\n", + "To log into Azure, ensure you have the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) installed. You will need to run the following command in your terminal:\n", + "\n", + "```bash\n", + "az login\n", + "```\n", + "\n", + "Once you have logged in, the below code will be able to fetch the token." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "65ff46e2", + "metadata": {}, + "outputs": [], + "source": [ + "from langchain_azure_postgresql.common import (\n", + " BasicAuth,\n", + " AzurePGConnectionPool,\n", + " ConnectionInfo,\n", + ")\n", + "from langchain_azure_postgresql.langchain import AzurePGVectorStore\n", + "\n", + "entra_connection_pool = AzurePGConnectionPool(\n", + " azure_conn_info=ConnectionInfo(\n", + " host=os.environ[\"DBHOST\"], dbname=os.environ[\"DBNAME\"]\n", + " )\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "804e77eb", + "metadata": {}, + "source": [ + "### Password Authentication\n", + "\n", + "If you're not using Microsoft Entra authentication, the `BasicAuth` class allows the use of username and password:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "36dd0ebd", + "metadata": {}, + "outputs": [], + "source": [ + "basic_auth_connection_pool = AzurePGConnectionPool(\n", + " azure_conn_info=ConnectionInfo(\n", + " host=os.environ[\"DBHOST\"],\n", + " dbname=os.environ[\"DBNAME\"],\n", + " credentials=BasicAuth(\n", + " username=os.environ[\"DBUSER\"],\n", + " password=os.environ[\"DBPASSWORD\"],\n", + " ),\n", + " )\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "c1bfc61e", + "metadata": {}, + "source": [ + "### Creating the vector store" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "979a65bd-742f-4b0d-be1e-c0baae245ec6", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Metadata columns are specified as a string, defaulting to 'jsonb' type.\n", + "Embedding type is not specified, defaulting to 'vector'.\n", + "Embedding dimension is not specified, defaulting to 1536.\n", + "Embedding index is not specified, defaulting to 'DiskANN' with 'vector_cosine_ops' opclass.\n" + ] + } + ], + "source": [ + "from langchain_core.documents import Document\n", + "from langchain_azure_postgresql.langchain import AzurePGVectorStore\n", + "\n", + "table_name = \"my_docs\"\n", + "\n", + "# The connection is either using Entra ID or Basic Auth\n", + "connection = entra_connection_pool if USE_ENTRA_AUTH else basic_auth_connection_pool\n", + "\n", + "vector_store = AzurePGVectorStore(\n", + " embedding=embeddings,\n", + " table_name=table_name,\n", + " connection=connection,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "54113d0e", + "metadata": {}, + "source": [ + "## Initialize the DiskANN Vector index for more efficient vector search\n", + "[DiskANN](https://aka.ms/pg-diskann-blog) is a scalable approximate nearest neighbor search algorithm for efficient vector search at any scale. It offers high recall, high queries per second, and low query latency, even for billion-point datasets. Those characteristics make it a powerful tool for handling large volumes of data." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "de9692f3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vector_store.create_index()" + ] + }, + { + "cell_type": "markdown", + "id": "61a224a1-d70b-4daf-86ba-ab6e43c08b50", + "metadata": {}, + "source": [ + "## Manage vector store\n", + "\n", + "### Add items to vector store\n", + "\n", + "Note that adding documents by ID will over-write any existing documents that match that ID." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "88a288cc-ffd4-4800-b011-750c72b9fd10", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['00e2cfe6-6e58-4733-9ebf-a708fd16488a',\n", + " '224a22a8-567f-4e12-ac0f-5cfe4f0a4480',\n", + " '62058e25-8f5e-4388-81c2-a5b7348ffef0',\n", + " '1d37d282-504d-4d28-855a-8d39694b0265',\n", + " '1fffcd2e-6fce-423f-bac3-ee5dc9084673',\n", + " 'b99efbab-2247-418f-b80d-d865f01d3c9e',\n", + " 'd2a86d1b-5d81-4c53-b3d2-a6b1e5189a3f',\n", + " 'a9577242-823e-42bc-9b0f-01670dbec190',\n", + " 'eaa45ae8-a84b-46eb-8a27-bf8652148d17',\n", + " '7d7f04fd-6fb8-4a29-8708-b9f835ef270a']" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "docs = [\n", + " Document(\n", + " page_content=\"there are cats in the pond\",\n", + " metadata={\"doc_id\": 1, \"location\": \"pond\", \"topic\": \"animals\"},\n", + " ),\n", + " Document(\n", + " page_content=\"ducks are also found in the pond\",\n", + " metadata={\"doc_id\": 2, \"location\": \"pond\", \"topic\": \"animals\"},\n", + " ),\n", + " Document(\n", + " page_content=\"fresh apples are available at the market\",\n", + " metadata={\"doc_id\": 3, \"location\": \"market\", \"topic\": \"food\"},\n", + " ),\n", + " Document(\n", + " page_content=\"the market also sells fresh oranges\",\n", + " metadata={\"doc_id\": 4, \"location\": \"market\", \"topic\": \"food\"},\n", + " ),\n", + " Document(\n", + " page_content=\"the new art exhibit is fascinating\",\n", + " metadata={\"doc_id\": 5, \"location\": \"museum\", \"topic\": \"art\"},\n", + " ),\n", + " Document(\n", + " page_content=\"a sculpture exhibit is also at the museum\",\n", + " metadata={\"doc_id\": 6, \"location\": \"museum\", \"topic\": \"art\"},\n", + " ),\n", + " Document(\n", + " page_content=\"a new coffee shop opened on Main Street\",\n", + " metadata={\"doc_id\": 7, \"location\": \"Main Street\", \"topic\": \"food\"},\n", + " ),\n", + " Document(\n", + " page_content=\"the book club meets at the library\",\n", + " metadata={\"doc_id\": 8, \"location\": \"library\", \"topic\": \"reading\"},\n", + " ),\n", + " Document(\n", + " page_content=\"the library hosts a weekly story time for kids\",\n", + " metadata={\"doc_id\": 9, \"location\": \"library\", \"topic\": \"reading\"},\n", + " ),\n", + " Document(\n", + " page_content=\"a cooking class for beginners is offered at the community center\",\n", + " metadata={\"doc_id\": 10, \"location\": \"community center\", \"topic\": \"classes\"},\n", + " ),\n", + "]\n", + "\n", + "uuids = vector_store.add_documents(docs)\n", + "uuids" + ] + }, + { + "cell_type": "markdown", + "id": "60549ce8", + "metadata": {}, + "source": [ + "### Update items in vector store" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "27346d4e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['7d7f04fd-6fb8-4a29-8708-b9f835ef270a']" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "updated_docs = [\n", + " Document(\n", + " page_content=\"Updated - cooking class for beginners is offered at the community center\",\n", + " metadata={\"doc_id\": 10, \"location\": \"community center\", \"topic\": \"classes\"},\n", + " id=uuids[-1],\n", + " )\n", + "]\n", + "vector_store.add_documents(updated_docs, ids=[uuids[-1]], on_conflict_update=True)" + ] + }, + { + "cell_type": "markdown", + "id": "60fd32c5", + "metadata": {}, + "source": [ + "### See items from the vector store" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "fc0d09e6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[Document(id='1d37d282-504d-4d28-855a-8d39694b0265', metadata={'topic': 'food', 'doc_id': 4, 'location': 'market'}, page_content='the market also sells fresh oranges')]" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vector_store.get_by_ids([str(uuids[3])])" + ] + }, + { + "cell_type": "markdown", + "id": "0c712fa3", + "metadata": {}, + "source": [ + "### Delete items from vector store" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "a5b2b71f-49eb-407d-b03a-dea4c0a517d6", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vector_store.delete(ids=[uuids[3]])" + ] + }, + { + "cell_type": "markdown", + "id": "59f82250-7903-4279-8300-062542c83416", + "metadata": {}, + "source": [ + "## Query vector store\n", + "\n", + "After you create your vector store and add the relevant documents, you can query the vector store in your chain or agent.\n", + "\n", + "### Filtering Support\n", + "The vector store supports a set of filters that can be applied against the metadata fields of the documents via the `FilterCondition`, `OrFilter`, and `AndFilter` in the [LangChain Azure PostgreSQL](https://pypi.org/project/langchain-azure-postgresql/) package:\n", + "\n", + "| Operator | Meaning/Category |\n", + "| -------- | ------------------------------- |\n", + "| `=` | Equality |\n", + "| `!=` | Inequality |\n", + "| `<` | Less than |\n", + "| `<=` | Less than or equal |\n", + "| `>` | Greater than |\n", + "| `>=` | Greater than or equal |\n", + "| `in` | Special cased (in) |\n", + "| `not in` | Special cased (not in) |\n", + "| `is null` | Special cased (is null) |\n", + "| `is not null` | Special cased (is not null) |\n", + "| `between` | Special cased (between) |\n", + "| `not between` | Special cased (not between) |\n", + "| `like` | Text (like) |\n", + "| `ilike` | Text (case-insensitive like) |\n", + "| `AND` | Logical (and) |\n", + "| `OR` | Logical (or) |\n", + "\n", + "### Query directly\n", + "\n", + "Performing a simple similarity search can be done as follows:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f15a2359-6dc3-4099-8214-785f167a9ca4", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* there are cats in the pond [{'topic': 'animals', 'doc_id': 1, 'location': 'pond'}]\n", + "* ducks are also found in the pond [{'topic': 'animals', 'doc_id': 2, 'location': 'pond'}]\n", + "* the new art exhibit is fascinating [{'topic': 'art', 'doc_id': 5, 'location': 'museum'}]\n", + "* the library hosts a weekly story time for kids [{'topic': 'reading', 'doc_id': 9, 'location': 'library'}]\n" + ] + } + ], + "source": [ + "from langchain_azure_postgresql import FilterCondition, AndFilter\n", + "\n", + "results = vector_store.similarity_search(\n", + " \"kitty\",\n", + " k=10,\n", + " filter=FilterCondition(\n", + " column=\"(metadata->>'doc_id')::int\",\n", + " operator=\"in\",\n", + " value=[1, 5, 2, 9],\n", + " ),\n", + ")\n", + "\n", + "for doc in results:\n", + " print(\"* \" + doc.page_content + \" [\" + str(doc.metadata) + \"]\")" + ] + }, + { + "cell_type": "markdown", + "id": "d92ea049-1b1f-4ae9-9525-35750fe2e52e", + "metadata": {}, + "source": [ + "If you want to use logical `AND` filters, here is an example:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "88f423a4-6575-4fb8-9be2-a3da01106591", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* ducks are also found in the pond [{'topic': 'animals', 'doc_id': 2, 'location': 'pond'}]\n", + "* there are cats in the pond [{'topic': 'animals', 'doc_id': 1, 'location': 'pond'}]\n" + ] + } + ], + "source": [ + "results = vector_store.similarity_search(\n", + " \"ducks\",\n", + " k=10,\n", + " filter=AndFilter(\n", + " AND=[\n", + " FilterCondition(\n", + " column=\"(metadata->>'doc_id')::int\",\n", + " operator=\"in\",\n", + " value=[1, 5, 2, 9],\n", + " ),\n", + " FilterCondition(\n", + " column=\"metadata->>'location'\",\n", + " operator=\"in\",\n", + " value=[\"pond\", \"market\"],\n", + " ),\n", + " ]\n", + " ),\n", + ")\n", + "\n", + "for doc in results:\n", + " print(\"* \" + doc.page_content + \" [\" + str(doc.metadata) + \"]\")" + ] + }, + { + "cell_type": "markdown", + "id": "2e65adc1", + "metadata": {}, + "source": [ + "If you want to execute a similarity search and receive the corresponding scores you can run:" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "7d92e7b3", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* [SIM=0.528167] there are cats in the pond [{'topic': 'animals', 'doc_id': 1, 'location': 'pond'}]\n" + ] + } + ], + "source": [ + "results = vector_store.similarity_search_with_score(query=\"cats\", k=1)\n", + "for doc, score in results:\n", + " print(f\"* [SIM={score:3f}] {doc.page_content} [{doc.metadata}]\")" + ] + }, + { + "cell_type": "markdown", + "id": "8d40db8c", + "metadata": {}, + "source": [ + "### Query by turning into retriever\n", + "\n", + "You can also transform the vector store into a retriever for easier usage in your chains. " + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "7cd1fb75", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[Document(id='00e2cfe6-6e58-4733-9ebf-a708fd16488a', metadata={'topic': 'animals', 'doc_id': 1, 'location': 'pond'}, page_content='there are cats in the pond')]" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "retriever = vector_store.as_retriever(search_kwargs={\"k\": 1})\n", + "retriever.invoke(\"kitty\")" + ] + }, + { + "cell_type": "markdown", + "id": "b23f5f48", + "metadata": {}, + "source": [ + "If you want to use max marginal relevance search on your vector store:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ccb37670", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* there are cats in the pond [{'topic': 'animals', 'doc_id': 1, 'location': 'pond'}]\n", + "* the new art exhibit is fascinating [{'topic': 'art', 'doc_id': 5, 'location': 'museum'}]\n", + "* the library hosts a weekly story time for kids [{'topic': 'reading', 'doc_id': 9, 'location': 'library'}]\n", + "* ducks are also found in the pond [{'topic': 'animals', 'doc_id': 2, 'location': 'pond'}]\n" + ] + } + ], + "source": [ + "results = vector_store.max_marginal_relevance_search(\n", + " \"query about cats\",\n", + " k=10,\n", + " lambda_mult=0.5,\n", + " filter=FilterCondition(\n", + " column=\"(metadata->>'doc_id')::int\",\n", + " operator=\"in\",\n", + " value=[1, 2, 5, 9],\n", + " ),\n", + ")\n", + "\n", + "for doc in results:\n", + " print(\"* \" + doc.page_content + \" [\" + str(doc.metadata) + \"]\")" + ] + }, + { + "cell_type": "markdown", + "id": "3dfaa048", + "metadata": {}, + "source": [ + "For a full list of the different searches you can execute on a `AzurePGVectorStore` vector store, please refer to the [documentation](https://github.com/langchain-ai/langchain-azure/tree/main/libs/azure-postgresql).\n" + ] + }, + { + "cell_type": "markdown", + "id": "7ecd77a0", + "metadata": {}, + "source": [ + "## Usage for retrieval-augmented generation\n", + "\n", + "For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:\n", + "\n", + "- [Tutorials: working with external knowledge](https://python.langchain.com/docs/tutorials/#working-with-external-knowledge)\n", + "- [How-to: Question and answer with RAG](https://python.langchain.com/docs/how_to/#qa-with-rag)\n", + "- [Retrieval conceptual docs](https://python.langchain.com/docs/concepts/#retrieval)" + ] + }, + { + "cell_type": "markdown", + "id": "f7ec1a5c", + "metadata": {}, + "source": [ + "## API reference\n", + "For detailed documentation of all AzurePGVectorStore features and configurations head to the API reference: https://github.com/langchain-ai/langchain-azure/tree/main/libs/azure-postgresql/src/langchain_azure_postgresql/langchain" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}