Spaces:
Running
Running
Fix HF Space: update SDK version, add error handling, improve README
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: π
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
@@ -17,72 +17,30 @@ tags:
|
|
| 17 |
- chatbot
|
| 18 |
- transformers
|
| 19 |
- qwen
|
| 20 |
-
models:
|
| 21 |
-
- Qwen/Qwen2.5-1.5B
|
| 22 |
---
|
| 23 |
|
| 24 |
# Roleplay Chat Box π
|
| 25 |
|
| 26 |
-
An intelligent conversational AI system featuring multiple character personalities powered by LoRA (Low-Rank Adaptation) fine-tuned language models.
|
| 27 |
|
| 28 |
-
##
|
| 29 |
|
| 30 |
-
|
| 31 |
-
- **
|
| 32 |
-
- **
|
| 33 |
-
- **
|
| 34 |
-
- **Audio Toggle**: Optional voice output for responses
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
```
|
| 39 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
| 40 |
-
β Frontend β β Backend API β β ML Models β
|
| 41 |
-
β (React/HTML) βββββΊβ (FastAPI) βββββΊβ Base + LoRA β
|
| 42 |
-
β β β β β + VibeVoice β
|
| 43 |
-
β - Chat UI β β - Model Loading β β β
|
| 44 |
-
β - Character β β - LoRA Switchingβ β - Qwen2 Base β
|
| 45 |
-
β Selection β β - TTS Service β β - Character β
|
| 46 |
-
β - Audio Toggle β β - WebSocket β β Adapters β
|
| 47 |
-
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
|
| 48 |
-
```
|
| 49 |
|
| 50 |
## Characters
|
| 51 |
|
| 52 |
1. **Moses** - Biblical prophet with wisdom and authority
|
| 53 |
-
2. **Samsung Employee** - Tech-savvy corporate representative
|
| 54 |
3. **Jinx** - Complex, chaotic character from Arcane
|
| 55 |
|
| 56 |
-
##
|
| 57 |
-
|
| 58 |
-
1. Install dependencies:
|
| 59 |
-
```bash
|
| 60 |
-
pip install -r requirements.txt
|
| 61 |
-
```
|
| 62 |
-
|
| 63 |
-
2. Download models (see Resources section)
|
| 64 |
-
|
| 65 |
-
3. Start backend:
|
| 66 |
-
```bash
|
| 67 |
-
cd backend
|
| 68 |
-
python main.py
|
| 69 |
-
```
|
| 70 |
-
|
| 71 |
-
4. Start frontend:
|
| 72 |
-
```bash
|
| 73 |
-
cd frontend
|
| 74 |
-
# Instructions for your chosen frontend framework
|
| 75 |
-
```
|
| 76 |
-
|
| 77 |
-
## Requirements
|
| 78 |
-
|
| 79 |
-
- Python 3.8+
|
| 80 |
-
- CUDA-compatible GPU (recommended)
|
| 81 |
-
- ~8GB RAM minimum
|
| 82 |
-
- ~20GB storage for models
|
| 83 |
-
|
| 84 |
-
## Models Used
|
| 85 |
|
| 86 |
-
-
|
| 87 |
-
-
|
| 88 |
-
-
|
|
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.35.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 17 |
- chatbot
|
| 18 |
- transformers
|
| 19 |
- qwen
|
|
|
|
|
|
|
| 20 |
---
|
| 21 |
|
| 22 |
# Roleplay Chat Box π
|
| 23 |
|
| 24 |
+
An intelligent conversational AI system featuring multiple character personalities powered by LoRA (Low-Rank Adaptation) fine-tuned language models.
|
| 25 |
|
| 26 |
+
## β οΈ Important Notes for HuggingFace Spaces
|
| 27 |
|
| 28 |
+
This app requires significant resources:
|
| 29 |
+
- **Model**: Qwen/Qwen3-0.6B (will be downloaded from HuggingFace Hub)
|
| 30 |
+
- **Memory**: ~4GB RAM minimum for model loading
|
| 31 |
+
- **Storage**: LoRA adapters are included in the repo
|
|
|
|
| 32 |
|
| 33 |
+
The app will automatically download the base model from HuggingFace on first run. This may take a few minutes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
## Characters
|
| 36 |
|
| 37 |
1. **Moses** - Biblical prophet with wisdom and authority
|
| 38 |
+
2. **Samsung Employee** - Tech-savvy corporate representative
|
| 39 |
3. **Jinx** - Complex, chaotic character from Arcane
|
| 40 |
|
| 41 |
+
## How It Works
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
- Uses a shared base model (Qwen3-0.6B) from HuggingFace
|
| 44 |
+
- Switches between character-specific LoRA adapters
|
| 45 |
+
- LoRA adapters are tiny (few MB each) vs full models (GB each)
|
| 46 |
+
- Efficient memory usage by sharing one base model
|
app.py
CHANGED
|
@@ -17,12 +17,18 @@ def initialize_models():
|
|
| 17 |
global character_manager
|
| 18 |
if character_manager is None:
|
| 19 |
print("π Initializing character manager...")
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
def chat_function(message, character_id, history):
|
| 28 |
"""Handle chat with character - returns updated history and empty message"""
|
|
|
|
| 17 |
global character_manager
|
| 18 |
if character_manager is None:
|
| 19 |
print("π Initializing character manager...")
|
| 20 |
+
try:
|
| 21 |
+
character_manager = CharacterManager()
|
| 22 |
+
loop = asyncio.new_event_loop()
|
| 23 |
+
asyncio.set_event_loop(loop)
|
| 24 |
+
loop.run_until_complete(character_manager.initialize())
|
| 25 |
+
loop.close()
|
| 26 |
+
print("β
Models loaded successfully!")
|
| 27 |
+
except Exception as e:
|
| 28 |
+
print(f"β Error initializing models: {e}")
|
| 29 |
+
import traceback
|
| 30 |
+
traceback.print_exc()
|
| 31 |
+
raise
|
| 32 |
|
| 33 |
def chat_function(message, character_id, history):
|
| 34 |
"""Handle chat with character - returns updated history and empty message"""
|