ChatPPC is a tool to help staff at Gardner Packard Children's Health Center navigate patient care resources, built with Next.js, Vercel AI SDK, and LangChain. This project also uses Supabase as a vector database for retrieval augmented generation (RAG).
- Node.js 22+
- OpenAI API key
- Install the Supabase CLI:
yarn global add supabase
- Clone the repository:
git clone https://github.com/StanfordBDHG/ChatPPC
cd ChatPPC
- Install dependencies:
yarn install
- Initialize Supabase in your project:
supabase init
- Start the Supabase emulator:
supabase start
If this step succeeded, you should see a message that begins with
supabase local development setup is running.
Note the API URL
and service_role key
that are printed out below this message when the emulator starts, which you will use in the next step.
- Create a
.env.local
file in the root directory with these variables:
OPENAI_API_KEY=your_openai_api_key
SUPABASE_URL={API URL}
SUPABASE_PRIVATE_KEY={service_role key}
- Apply database migrations:
supabase migration up
Tip
At this step, you can follow the instructions below in the Document Ingestion section if you wish to add documents to test with.
- Run the development server:
yarn run dev
- Open http://localhost:3000 to view the ChatPPC application. You can also access the Supabase Studio at http://localhost:54323 to view and manage your local database.
The project includes an ingestion script that processes markdown files and stores them in your Supabase vector database for AI retrieval.
Add your markdown files to the docs
directory. Each document should be a properly formatted markdown file (.md
).
To ingest documents from the docs
folder, use the following command:
yarn ingest docs
The script will:
- Scan the specified directory for markdown (
.md
) files - Split the content into chunks with appropriate overlap
- Generate embeddings using OpenAI
- Store the embeddings in your Supabase vector database
To access the admin dashboard for viewing conversation analytics and managing documents:
- Navigate to the Supabase dashboard and add a new user under
Authentication
with an email and password. Currently only admins have individual user accounts, whereas users access without an account, therefore any user created in Supabase Authentication is automatically considered an admin. - Navigate to
/admin
or click theAdmin Login
button in the navbar. - Sign in with admin credentials.