Spaces:
Sleeping
Sleeping
push config
Browse files
README.md
CHANGED
|
@@ -1,124 +1,10 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
```
|
| 12 |
-
|
| 13 |
-
### 2. Run the Server
|
| 14 |
-
|
| 15 |
-
```bash
|
| 16 |
-
uvicorn app:app --host 0.0.0.0 --port 8000 --reload
|
| 17 |
-
```
|
| 18 |
-
|
| 19 |
-
The server will start on `http://127.0.0.1:8000`
|
| 20 |
-
|
| 21 |
-
**Note:** On first run, the BioMistral-7B model (~14GB) will be downloaded from Hugging Face. This may take several minutes.
|
| 22 |
-
|
| 23 |
-
### 3. Test the API
|
| 24 |
-
|
| 25 |
-
#### Start a new conversation:
|
| 26 |
-
```bash
|
| 27 |
-
curl -X POST "http://127.0.0.1:8000/chat" \
|
| 28 |
-
-H "Content-Type: application/json" \
|
| 29 |
-
-d '{"prompt": "I have a rash on my arm that itches for 3 days"}'
|
| 30 |
-
```
|
| 31 |
-
|
| 32 |
-
**Response:**
|
| 33 |
-
```json
|
| 34 |
-
{
|
| 35 |
-
"response": "It sounds like you may have a mild skin irritation...",
|
| 36 |
-
"session_id": "550e8400-e29b-41d4-a716-446655440000"
|
| 37 |
-
}
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
#### Continue the conversation (use the session_id from previous response):
|
| 41 |
-
```bash
|
| 42 |
-
curl -X POST "http://127.0.0.1:8000/chat" \
|
| 43 |
-
-H "Content-Type: application/json" \
|
| 44 |
-
-d '{
|
| 45 |
-
"prompt": "What should I do about it?",
|
| 46 |
-
"session_id": "550e8400-e29b-41d4-a716-446655440000"
|
| 47 |
-
}'
|
| 48 |
-
```
|
| 49 |
-
|
| 50 |
-
#### Clear a session:
|
| 51 |
-
```bash
|
| 52 |
-
curl -X DELETE "http://127.0.0.1:8000/chat/550e8400-e29b-41d4-a716-446655440000"
|
| 53 |
-
```
|
| 54 |
-
|
| 55 |
-
## π Project Structure
|
| 56 |
-
|
| 57 |
-
```
|
| 58 |
-
.
|
| 59 |
-
βββ app.py # FastAPI application with session management
|
| 60 |
-
βββ model/
|
| 61 |
-
β βββ __init__.py
|
| 62 |
-
β βββ biomistral_service.py # BioMistral model with conversation history
|
| 63 |
-
βββ requirements.txt # Python dependencies
|
| 64 |
-
βββ README.md # This file
|
| 65 |
-
```
|
| 66 |
-
|
| 67 |
-
## π§ API Endpoints
|
| 68 |
-
|
| 69 |
-
### `GET /`
|
| 70 |
-
Health check and API information.
|
| 71 |
-
|
| 72 |
-
### `GET /health`
|
| 73 |
-
Health check endpoint.
|
| 74 |
-
|
| 75 |
-
### `POST /chat`
|
| 76 |
-
Chat endpoint with conversation support.
|
| 77 |
-
|
| 78 |
-
**Request Body:**
|
| 79 |
-
```json
|
| 80 |
-
{
|
| 81 |
-
"prompt": "Your medical question or symptom description",
|
| 82 |
-
"session_id": "optional-session-id" // If omitted, a new session is created
|
| 83 |
-
}
|
| 84 |
-
```
|
| 85 |
-
|
| 86 |
-
**Response:**
|
| 87 |
-
```json
|
| 88 |
-
{
|
| 89 |
-
"response": "AI-generated medical advice/explanation",
|
| 90 |
-
"session_id": "session-id-for-continuing-conversation"
|
| 91 |
-
}
|
| 92 |
-
```
|
| 93 |
-
|
| 94 |
-
### `DELETE /chat/{session_id}`
|
| 95 |
-
Clear conversation history for a specific session.
|
| 96 |
-
|
| 97 |
-
## π¬ Conversation Features
|
| 98 |
-
|
| 99 |
-
- **Session Management**: Each conversation has a unique `session_id`
|
| 100 |
-
- **Multi-turn Conversations**: Maintain context across multiple messages
|
| 101 |
-
- **Automatic Session Creation**: New sessions are created automatically if `session_id` is not provided
|
| 102 |
-
- **Conversation History**: Full conversation history is maintained per session
|
| 103 |
-
|
| 104 |
-
## π§ Model Information
|
| 105 |
-
|
| 106 |
-
- **Model:** BioMistral/BioMistral-7B
|
| 107 |
-
- **Source:** Hugging Face
|
| 108 |
-
- **Purpose:** Medical chat, reasoning, and education
|
| 109 |
-
- **Capabilities:** Multi-turn medical conversations, symptom analysis, medical education
|
| 110 |
-
|
| 111 |
-
## β οΈ Important Notes
|
| 112 |
-
|
| 113 |
-
- This is an **educational tool** and should not replace professional medical consultation
|
| 114 |
-
- Always encourage users to consult healthcare professionals for serious conditions
|
| 115 |
-
- The model is loaded into memory on startup, which may take time and require significant RAM/VRAM
|
| 116 |
-
- Sessions are stored in memory (not persisted). Restarting the server will clear all sessions
|
| 117 |
-
- For production use, consider implementing persistent storage, caching, rate limiting, and proper error handling
|
| 118 |
-
|
| 119 |
-
## π Next Steps
|
| 120 |
-
|
| 121 |
-
- Add `/analyze-image` endpoint (BiomedCLIP)
|
| 122 |
-
- Add `/analyze-text` endpoint (ClinicalBERT)
|
| 123 |
-
- Fuse all endpoints into `/triage` endpoint
|
| 124 |
-
- Add persistent session storage (Redis/Database)
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: QuickCare Text
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|