In this tutorial, you will learn how to use Nile’s tenant virtualization, user management and vector embedding features to build a SaaS application that allows users to search the PDF documents in an organization. The SaaS will allow users to upload a PDF document, and then ask questions about the document. Using embeddings generated by OpebAI and stored in Nile, and a similarity search using pg_vector, to provide GPT-3.5 context that will help answer the questions. The embeddings are stored per tenant and data and workload is isolated to a tenant.
Once you created your database, you’ll land in Nile’s web-based SQL editor. Great place to create the tables we need for this app. Lets start with the embeddings table.
This is a tenant-aware table that stores the embeddings of the PDF documents.
You can see that each row belongs to a specific tenant, and that the embedding
column is of type vector(1024)
. Vector type is provided by the pg_vector extension for storing embeddings.
By storing embeddings in a tenant-aware table, we can use Nile’s built-in tenant isolation to ensure that
information about PDFs won’t leak between tenants.
We’ll need few more tables to store information about the PDF documents, the conversations with them and the users. Go ahead and create these.
If all went well, you’ll see the new tables in the panel on the left hand side of the query editor. You can also see Nile’s built-in tenant table next to it.
In the left-hand menu, click on “Settings” and then select “Credentials”. Generate credentials and keep them somewhere safe. These give you access to the database.
This demo uses Google authentication for signup. You will need to configure this in both Google and Nile, following the instructions in the example.
This example requires a few more 3rd party SaaS accounts. You’ll need to set them up and grab API keys to configure this example:
If you haven’t cloned this project yet, now will be an excellent time to do so. Since it uses NextJS, we can use create-next-app
for this:
Rename .env.example
to .env.local
, and update it with your workspace and database name.
(Your workspace and database name are displayed in the header of the Nile dashboard.)
Fill in the username and password with the credentials you picked up in the previous step.
And fill in the access keys for UploadThing and OpenAI.
Install dependencies with yarn install
or npm install
.
In this tutorial, you will learn how to use Nile’s tenant virtualization, user management and vector embedding features to build a SaaS application that allows users to search the PDF documents in an organization. The SaaS will allow users to upload a PDF document, and then ask questions about the document. Using embeddings generated by OpebAI and stored in Nile, and a similarity search using pg_vector, to provide GPT-3.5 context that will help answer the questions. The embeddings are stored per tenant and data and workload is isolated to a tenant.
Once you created your database, you’ll land in Nile’s web-based SQL editor. Great place to create the tables we need for this app. Lets start with the embeddings table.
This is a tenant-aware table that stores the embeddings of the PDF documents.
You can see that each row belongs to a specific tenant, and that the embedding
column is of type vector(1024)
. Vector type is provided by the pg_vector extension for storing embeddings.
By storing embeddings in a tenant-aware table, we can use Nile’s built-in tenant isolation to ensure that
information about PDFs won’t leak between tenants.
We’ll need few more tables to store information about the PDF documents, the conversations with them and the users. Go ahead and create these.
If all went well, you’ll see the new tables in the panel on the left hand side of the query editor. You can also see Nile’s built-in tenant table next to it.
In the left-hand menu, click on “Settings” and then select “Credentials”. Generate credentials and keep them somewhere safe. These give you access to the database.
This demo uses Google authentication for signup. You will need to configure this in both Google and Nile, following the instructions in the example.
This example requires a few more 3rd party SaaS accounts. You’ll need to set them up and grab API keys to configure this example:
If you haven’t cloned this project yet, now will be an excellent time to do so. Since it uses NextJS, we can use create-next-app
for this:
Rename .env.example
to .env.local
, and update it with your workspace and database name.
(Your workspace and database name are displayed in the header of the Nile dashboard.)
Fill in the username and password with the credentials you picked up in the previous step.
And fill in the access keys for UploadThing and OpenAI.
Install dependencies with yarn install
or npm install
.