
1. Create a database
- Sign up for an invite to Nile if you don’t have one already
- You should see a welcome message. Click on “Lets get started”
- Give your workspace and database names, or you can accept the default auto-generated names.
2. Create a table with pg_vector extension
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.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.
3. Create metadata tables
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.3. Getting credentials
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.4. Setting up Google Authentication
This demo uses Google authentication for signup. You will need to configure this in both Google and Nile, following the instructions in the example.5. Setting up 3rd Party SaaS
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:- UploadThing: Used for storing PDFs
- OpenAI: Used to generate embeddings of the uploaded documents and for the chat itself
- Stripe: This is optional: The application has support for limited free tier and a powerful paid tier. You can learn more about integrating Nile and Stripe in the integration guide.
6. Setting the environment
-
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
ornpm install
.