This 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
- Supabase project
- Clone the repository:
git clone <your-repo-url>
cd <project-directory>
- Install dependencies:
yarn install
-
Set up your Supabase database by following these instructions to:
- Enable the
pgvector
extension - Create the necessary tables and functions
- Enable the
-
Create a
.env.local
file in the root directory based on the.env.example
file in the project root. Ensure your.env.local
file includes these variables:
OPENAI_API_KEY=your_openai_api_key
SUPABASE_URL=your_supabase_project_url
SUPABASE_PRIVATE_KEY=your_supabase_private_key
Tip
If you are running the application for the first time, follow the instructions in the Document Ingestion section below to ingest documents into your Supabase vector database.
- Run the development server:
yarn run dev
- Open http://localhost:3000 to view the application.
The project includes an ingestion script (ingest.mjs
) that processes markdown files and stores them in your Supabase vector database for AI retrieval.
Ensure that you have followed the instructions in Local Development section above to set up your project first.
Documents should be stored in a directory (e.g. docs
) within the project root. Each document should be a properly formatted markdown file.
To ingest documents, use the following command:
yarn ingest <path_to_markdown_directory>
For example:
yarn ingest docs # documents to ingest are in the 'docs' directory
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