File size: 3,226 Bytes
37ebac6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ef73ed
37ebac6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ef73ed
 
 
37ebac6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ef73ed
 
37ebac6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ef73ed
 
 
37ebac6
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
license: mit
---

# AI Health Assistant

This project is a Flask-based web application that provides several machine learning-powered features such as:

- Counseling Response Generation using a GPT-2 model.
- Medication Information Generation using a GPT-2 model.
- Diabetes Classification using a Random Forest classifier.
- Medicine Classification using a K-Nearest Neighbors (KNN) model.
- General Chat powered by LLaMA 3.1 API hosted on Groq Cloud for AI-powered conversations.

The project is divided into two main parts: Backend (Flask) and Frontend (HTML, CSS, JavaScript), with a connection to pre-trained machine learning models.
### Project Setup

-  **System Requirements:**
    - Python 3.8+
    - Flask
    - Transformers library (for GPT-2 models)
    - Joblib (for loading pre-trained models)
    - Langchain Groq (for LLaMA integration)
    - Frontend: HTML, CSS, JavaScript

- **Project Structure:**
    ```
    AI Health Assistant/
    β”‚
    β”œβ”€β”€ backend/
    β”‚   β”œβ”€β”€ models/
    β”‚   β”‚   β”œβ”€β”€ mental_health_model/
    β”‚   β”‚   β”œβ”€β”€ medication_info/
    β”‚   β”‚   β”œβ”€β”€ diabetes_model/
    β”‚   β”‚   β”œβ”€β”€ medication_classification_model/
    β”‚   β”œβ”€β”€ utils.py
    β”œβ”€β”€ frontend/
    β”‚   β”œβ”€β”€ index.html
    β”‚   β”œβ”€β”€ styles.css
    β”‚   β”œβ”€β”€ script.js
    β”œβ”€β”€ app.py
    β”œβ”€β”€ requirements.txt


### Backend

**Counseling Response Generation:**
- Generates counseling-related responses using a GPT-2 mental health model.

**Medication Information Generation:**
- Provides medication-related responses using a GPT-2 medication model.

**Diabetes Classification:**
- Classifies users as diabetic or non-diabetic based on glucose, BMI, and age using a Random Forest classifier.

**Medicine Classification:**
- Predicts suitable medications based on gender, blood type, medical condition, and test results using a K-Nearest Neighbors (KNN) model.

**General Chat:**
- Offers general chat responses using LLaMA 3.1 API hosted on Groq Cloud for AI-powered conversations.


### Frontend

**Diabetes Classification Tab:**
- Form input for glucose, BMI, and age to classify diabetes risk.

**Medicine Classification Tab:**
- Input fields for gender, blood type, medical condition, and test results to classify appropriate medications.

**Counseling and Medication Tabs:**
- Text inputs for receiving AI-generated responses for counseling and medication questions.

**General Chat Tab:**
- General-purpose chatbot powered by LLaMA 3.1 for natural conversations.

**Dark Mode:**
- Toggle dark mode for user interface customization.


### Usage

1. **Access the Application:** Users interact with the web interface, accessible through a browser once the Flask server is running.

2. **Input Data:** Users provide medical-related information or general queries depending on the feature they want to use.

3. **Receive Responses:** Based on the input, AI models provide responses such as classification results (diabetes, medicine) or generated text (counseling, medication, chat).

4. **Interactive Interface:** Users can toggle between different features, making it suitable for general chat, medical insights, or counseling help.