File size: 3,623 Bytes
35810de
 
96f47e7
7f35d34
 
35810de
7f35d34
73b8ca8
 
8ca39cb
cc2f90c
35810de
96f47e7
73b8ca8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49fb144
73b8ca8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: Medical Diagnosis System
emoji: 🏥
colorFrom: yellow
colorTo: green
sdk: docker
pinned: false
license: apache-2.0
short_description: University project creating an AI-powered medical system
python_version: 3.11
app_port: 7860
---

# Medical Diagnosis System

An AI-powered medical chatbot designed for patient-centric interactions, featuring persistent memory and a modern, intuitive user interface. This system is containerised using Docker for simplified deployment and scalability.

## System Architecture

The application is comprised of a FastAPI backend and a static frontend, communicating via a RESTful API. The entire system is designed to be run within Docker containers, ensuring a consistent and reproducible environment.

### Services and Technologies

- **Backend**: Python 3.11 with FastAPI
- **Database**: MongoDB for all persistent data, including user information, chat sessions, and long-term memory.
- **AI Models**:
	- **Primary**: Google's Gemini Pro for response generation.
	- **Fallback**: An NVIDIA-based model for summarisation, accessed via a dedicated API.
- **Containerisation**: Docker and Docker Compose for service orchestration.
- **Frontend**: Static HTML, CSS, and vanilla JavaScript.

### Retrieval-Augmented Generation (RAG) Implementation

The system's contextual memory is built upon a RAG architecture to provide relevant and informed responses. This is achieved through a multi-layered memory system:

- **Short-Term Memory**: An in-memory LRU (Least Recently Used) cache stores the summaries of the last three interactions. This allows for immediate context recall within an ongoing conversation.
- **Long-Term Memory**: The summaries of the last twenty interactions for each patient are persisted in MongoDB. This provides a deeper historical context for recurring patients, allowing the system to reference past conversations and maintain continuity over time.

When a query is received, the system retrieves the relevant short and long-term memory summaries to build a comprehensive context. This context is then provided to the LLM along with the user's query to generate an accurate and context-aware response.

## Key Features

- **Patient-Centric Memory**: Utilises both short-term and long-term memory to maintain context throughout conversations.
- **Persistent Chat History**: All chat sessions are saved in MongoDB, allowing for a complete history of interactions.
- **Contextual Awareness**: The system maintains the context of both the patient and the doctor in all messages and summaries.
- **User Management**: Includes features for patient search (by name or ID) and a doctor dropdown with a streamlined user creation process.
- **Modern User Interface**: The application features a sidebar for session management, modals for doctor and patient profiles, a dark/light mode, and a mobile-friendly design.
- **AI Model Integration**: The system leverages Gemini for generating responses and includes a fallback to an NVIDIA summariser.

## Getting Started

To get the project up and running, please refer to the detailed instructions in the [setup guide](./SETUP_GUIDE.md).

## Licence & Disclaimer

This project is licensed under the Apache 2.0 Licence. See the [LICENCE](./LICENCE) file for details.

The information provided by this system is for educational purposes only and is not a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your physician or other qualified health provider with any questions you may have regarding a medical condition.

Team D1 - COS30018, Swinburne University of Technology