⚕️MedDocChat is a chatbot that allows you to converse with medical documents.
What ⚕️MedDocChat can do:
✅ Answer questions about medical documents (in .txt files) in an intuitive chatbot interface
✅ Provides source attribution 💡 from medical document, ensuring trust in chatbot
✅ Stores medical documents in NoSQL distributed database (using MongoDB at the moment)
✅ Maintains conversational history when chatting with document, allowing for context to be maintained
🛠️ Project's Tech Stack:
- Langchain
- FastAPI
- Next.Js
- MongoDB
- OpenAI
-
Ensure that you have Node.js installed, which can be found on the official website
-
Clone this project onto your local machine
git clone https://github.com/will-pang/medical-document-chat
- (Recommended) Using your terminal,
cdinto the project root folder, create a virtual environment:
python3 -m venv venv
source venv/bin/activate
Note that the latest Python version is required (as of writing, it is Python 3.13.2)
- Install all the required Python packages
pip install -r requirements.txt
- Install all the required Node.js packages
npm install
- Create a
.env.localfile in the project root, with the following variables. You can also find an example underdocs\.env.example:
MONGO_URI="YOUR_MONGODB_URI"
DB="YOUR_MONGO_DATABASE_NAME"
COLLECTION="YOUR_MONGO_COLLECTION_NAME"
OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
CONVERSATIONAL_HISTORY_COLLECTION="YOUR_MONGODB_CONVERSATIONAL_HISTORY_COLLECTION_NAME"
- In your IDE of choice, run the development server via the terminal:
npm run dev -- -p 3000
Open http://localhost:3000 with your browser to see the result.
- In a separate terminal, run fastapi using Uvicorn:
uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload
You can generate examples of medical documents on ChatGPT, or download some examples under docs and upload it (must be .txt format) by pressing the "Upload .txt File" button.
Note: Currently, the "I'm Feeling Lucky" button is not supported. The idea was to pick a random example stored in the database of choice, but I did not have enough time to implement this.

