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.

$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:

1from superagent.client import Superagent
2
3client = Superagent(
4 token=os.environ["SUPERAGENT_API_KEY"], # replace with your Superagent API Key
5 base_url="https://api.beta.superagent.sh" # or your local environment
6)
7
8datasource = client.datasource.create(request={
9 "name": "Tesla Q3 2023",
10 "description": "Useful for answering questions about Teslas Q3 2023 earnings report",
11 "type": "PDF",
12 "url": "https://digitalassets.tesla.com/tesla-contents/image/upload/IR/TSLA-Q3-2023-Update-3.pdf"
13})

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

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

Additional Resources: