Configuring an Alternative Vector Database

Supported Vector Databases

By default, the Docker Compose files for the examples deploy Milvus as the vector database. Alternatively, you can deploy pgvector.

Configuring pgvector as the Vector Database

  1. Edit the Docker Compose file for the example, such as deploy/compose/rag-app-text-chatbot.yaml.

    Update the environment variables within the chain server service:

    services:
      chain-server:
        container_name: chain-server
        environment:
          APP_VECTORSTORE_NAME: "pgvector"
          APP_VECTORSTORE_URL: "pgvector:5432"
          POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
          POSTGRES_USER: ${POSTGRES_USER:-postgres}
          POSTGRES_DB: ${POSTGRES_DB:-api}
    

    The preceding example shows the default values for the database user, password, and database. To override the defaults, edit the values in the Docker Compose file, or set the values in the compose.env file.

    Note: If you have existing setup remove deploy/compose/volumes directory to avoid pgvector crash.

  2. Optional: If a container for a vector database is running, stop the container:

    $ docker compose -f deploy/compose/docker-compose-vectordb.yaml down
    
  3. Stop and then start the services:

    $ docker compose --env-file deploy/compose/compose.env -f deploy/compose/<rag-example>.yaml down
    $ docker compose --env-file deploy/compose/compose.env -f deploy/compose/<rag-example>.yaml up -d --remove-orphans
    
  4. Start the pgvector container:

    $ docker compose -f deploy/compose/docker-compose-vectordb.yaml up -d pgvector
    
  5. Optional: View the chain server logs to confirm the vector database.

    1. View the logs:

      $ docker logs -f chain-server
      
    2. Upload a document to the knowledge base. Refer to Use Unstructured Documents as a Knowledge Base for more information.

    3. Confirm the log output includes the vector database:

      INFO:example:Ingesting <file-name>.pdf in vectorDB
      INFO:RetrievalAugmentedGeneration.common.utils:Using pgvector as vector store
      INFO:RetrievalAugmentedGeneration.common.utils:Using PGVector collection: <example-name>
      

Configuring Milvus as the Vector Database

  1. Edit the Docker Compose file for the example, such as deploy/compose/rag-app-text-chatbot.yaml.

    Update the environment variables within the chain server service:

    services:
      chain-server:
        container_name: chain-server
        environment:
          APP_VECTORSTORE_NAME: "milvus"
          APP_VECTORSTORE_URL: "http://milvus:19530"
    
  2. Optional: If a container for a vector database is running, stop the container:

    $ docker compose -f deploy/compose/docker-compose-vectordb.yaml down
    
  3. Stop and then start the services:

    $ docker compose --env-file deploy/compose/compose.env -f deploy/compose/<rag-example>.yaml down
    $ docker compose --env-file deploy/compose/compose.env -f deploy/compose/<rag-example>.yaml up -d --remove-orphans
    
  4. Start the Milvus container:

    $ docker compose -f deploy/compose/docker-compose-vectordb.yaml up -d milvus
    
  5. Optional: View the chain server logs to confirm the vector database.

    1. View the logs:

      $ docker logs -f chain-server
      
    2. Upload a document to the knowledge base. Refer to Use Unstructured Documents as a Knowledge Base for more information.

    3. Confirm the log output includes the vector database:

      INFO:example:Ingesting <file-name>.pdf in vectorDB
      INFO:RetrievalAugmentedGeneration.common.utils:Using milvus as vector store
      INFO:RetrievalAugmentedGeneration.common.utils:Using milvus collection: <example-name>