Skip to content

StanfordBDHG/ChatPPC

Repository files navigation

ChatPPC

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).

Local Development

Prerequisites

  • Node.js 22+
  • OpenAI API key
  • Supabase project

Setup for Development

  1. Clone the repository:
git clone <your-repo-url>
cd <project-directory>
  1. Install dependencies:
yarn install
  1. Set up your Supabase database by following these instructions to:

    • Enable the pgvector extension
    • Create the necessary tables and functions
  2. 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.

  1. Run the development server:
yarn run dev
  1. Open http://localhost:3000 to view the application.

Document Ingestion

The project includes an ingestion script (ingest.mjs) that processes markdown files and stores them in your Supabase vector database for AI retrieval.

Setup for Ingestion

Ensure that you have followed the instructions in Local Development section above to set up your project first.

Preparing Documents for Ingestion

Documents should be stored in a directory (e.g. docs) within the project root. Each document should be a properly formatted markdown file.

Running the Ingestion Script

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

About

Chat agent for Stanford Pediatric Primary Care

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •