Customize AI Template

This guide will help you learn to customize AI Chat with PDF feature in Next.js Supabase AI template. Adjust file types and sizes to fit your product requirement.

Overview

The Next.js Supabase AI Template include advanced AI feature, such as AI Chat with PDF, enabling users to upload PDFs, parse the content, and obtain insights and answers through text-based queries. This feature transforms uploaded PDFs into a dynamic knowledge base, similar to the functionality of ChatGPT.

This feature leverages the OpenAI API and Vercel SDK to process user queries and deliver accurate responses.


Configuration Options

The AI feature can be tailored to meet specific requirements by modifying configuration settings in the client.config.ts file.

1. Customizing Accepted File Types

You can define the types of files the system accepts using the FILE_TYPE_ACCEPT property. By default, the template supports PDF files only.

// Default configuration
FILE_TYPE_ACCEPT: ["application/pdf"]

To allow additional file types (e.g., CSV or TXT files):

// Example for accepting PDF, CSV, and TXT files
FILE_TYPE_ACCEPT: ["application/pdf", "text/csv", "text/plain"]

2. Customizing Maximum File Size

The FILE_MAX_SIZE_IN_BYTES property allows you to set the maximum file size for uploads. The default limit is 2MB.

// Default configuration
FILE_MAX_SIZE_IN_BYTES: 2097152 // in bytes (2MB)

To increase the limit (e.g., to 5MB):

// Updated configuration for 5MB
FILE_MAX_SIZE_IN_BYTES: 5242880 // in bytes (5MB)

On this page