File size: 2,878 Bytes
a44bd4e
6a725a4
 
 
 
a44bd4e
6a1e37a
6a725a4
 
 
8b52acf
a44bd4e
6a725a4
 
 
 
a44bd4e
6e7b70e
 
a44bd4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5205115
 
 
 
6a725a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a1e37a
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
title: Chatbot Mimic Notes
emoji: 🤖
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 3.50.2
app_file: chatgpt.py
pinned: false
license: mit
python_version: 3.11
---

# Chatbot Mimic Notes

A medical-focused chatbot that supports patient evaluations, structured conversation management, and optional Google Drive backups.

> Need to customize the Hugging Face Space configuration? See the reference guide at https://huggingface.co/docs/hub/spaces-config-reference.

## Prerequisites
- Python 3.x
- pip

## Installation
1. Clone this repository

2. Navigate to the project directory:
   ```
   cd chatbot-mimic-notes
   ```
3. Install the required packages:
   ```
   pip install -r requirements.txt
   ```

## Running the Application
Start the chatbot by running:
```
python chatgpt.py
```

## Run Server
```
python -m src.server
```

## Usage
- Open Chrome and visit `http://localhost:7860` to interact with the chatbot.

## Google Drive Auto-Backup

The chatbot can automatically push evaluation data to Google Drive so the latest files are available when deploying to Hugging Face.

### Storage Layout

1. **Patient evaluations** (`patient_evaluations/`)
   - Synced to the `Patient_Evaluations` folder in Drive
   - Includes per-evaluation JSON files plus the master CSV summary

2. **Conversation logs** (`user_data/`)
   - Synced to the `Chatbot_Conversations` folder in Drive
   - Includes conversation transcripts and memory graphs

### Configuration Options (choose one)

#### ⭐ Option 1: Service Account (recommended)

Use this if you see an `invalid_client` error or want a hands-off setup.

1. Create a Service Account in Google Cloud Console and download the JSON key
2. Share your destination Drive folder with the Service Account email
3. Update `google_drive_sync.py`:
   ```python
   SERVICE_ACCOUNT_FILE = "service-account-key.json"
   ```

**Full walkthrough (≈5 minutes):** see `QUICK_SETUP.md`

#### Option 2: Refresh Token (requires an OAuth client)

1. Generate a refresh token:
   ```bash
   python get_refresh_token.py
   ```
2. If you hit `invalid_client`, create a new OAuth client (see `QUICK_SETUP.md`)
3. Complete the browser authentication flow
4. Copy the printed `refresh_token`
5. Update `google_drive_sync.py`:
   ```python
   REFRESH_TOKEN = "your_refresh_token"
   ```

See `google_drive_setup_guide.md` or `QUICK_SETUP.md` for detailed steps.

#### Option 3: Interactive OAuth (manual in UI)

1. Click **“Login to Google Drive”** inside the Gradio interface
2. Complete the browser authentication
3. Future saves will automatically sync to Drive

### Notes

- Without authentication, all files remain in local storage
- Upload failures are silent but local saves always succeed
- Only your own Drive account receives files; no shared storage is involved
- **Security:** never commit credentials or tokens into the repo