Getting started

Configuring Vector Database

Superagent supports two primary methods for integrating vector databases: using environment variables and leveraging the Superagent SDK. This guide will walk you through both methods.

Environment variables

This is the easiest way to get started.

You can see supported vector databases in Superagent, and their corresponding environment variables.

1
2
3
export VECTORSTORE=supabase
export SUPABASE_DB_URL=postgresql://user:password@host:port/dbname
export SUPABASE_TABLE_NAME=your-table-name

Step-by-step guide

After setting the environment variables for one of the supported vector databases, you can create a datasource with the vector database:

1
2
3
4
5
6
7
8
9
10
11
12
13
from superagent.client import Superagent

client = Superagent(
    token=os.environ["SUPERAGENT_API_KEY"], # replace with your Superagent API Key
    base_url="https://api.beta.superagent.sh" # or your local environment
)

datasource = client.datasource.create(request={
    "name": "Tesla Q3 2023",
    "description": "Useful for answering questions about Teslas Q3 2023 earnings report",
    "type": "PDF",
    "url": "https://digitalassets.tesla.com/tesla-contents/image/upload/IR/TSLA-Q3-2023-Update-3.pdf"
})

Using the SDK

This is more flexible and allows you to use multiple databases in the same project.

Step-by-step guide

Note that we will be using Pinecone as an example, but the same steps apply to all supported vector databases.


  1. Initialize the Superagent client with your API key:
1
2
3
4
5
6
from superagent.client import Superagent

client = Superagent(
    token=os.environ["SUPERAGENT_API_KEY"], # replace with your Superagent API Key
    base_url="https://api.beta.superagent.sh" # or your local environment
)
  1. Create a vector database:
1
2
3
4
5
6
7
8
9
10
vector_database = client.vector_database.create(
    request={
        "provider": "PINECONE",
        "options": {
            "PINECONE_ENVIRONMENT": "your-environment",
            "PINECONE_API_KEY": "your-api-key",
            "PINECONE_INDEX": "your-index-name"
        }
    }   
)
  1. Create a datasource with the vector database:
1
2
3
4
5
6
7
 datasource = client.datasource.create(request={
     "name": "Tesla Q3 2023",
     "description": "Useful for answering questions about Teslas Q3 2023 earnings report",
     "type": "PDF",
     "url": "https://digitalassets.tesla.com/tesla-contents/image/upload/IR/TSLA-Q3-2023-Update-3.pdf",
     "vectorDbId": vector_database.data.id
 })

For more information on interacting with datasources, refer to the example.

Additional Resources: