ButterM40 commited on
Commit
7f7c489
Β·
1 Parent(s): bad3b4b

Fix HF Space: update SDK version, add error handling, improve README

Browse files
Files changed (2) hide show
  1. README.md +14 -56
  2. app.py +12 -6
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🎭
4
  colorFrom: purple
5
  colorTo: pink
6
  sdk: gradio
7
- sdk_version: 4.44.1
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. Each character has been trained with specific datasets to maintain unique personalities, speaking patterns, and areas of expertise.
27
 
28
- ## Features
29
 
30
- - **Multi-Character Support**: Switch between different character personalities using LoRA adapters
31
- - **Voice Synthesis**: Text-to-speech with character-specific voices using Microsoft's VibeVoice
32
- - **Modern Interface**: ChatGPT-style web interface with character selection sidebar
33
- - **Real-time Chat**: WebSocket-based real-time communication
34
- - **Audio Toggle**: Optional voice output for responses
35
 
36
- ## Architecture
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
- ## Setup
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
- - Base: Qwen2 (via Polarium/qwen2-yoda-lora)
87
- - Voice: Microsoft VibeVoice-1.5B
88
- - Custom LoRA adapters for each character
 
 
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
- character_manager = CharacterManager()
21
- loop = asyncio.new_event_loop()
22
- asyncio.set_event_loop(loop)
23
- loop.run_until_complete(character_manager.initialize())
24
- loop.close()
25
- print("βœ… Models loaded successfully!")
 
 
 
 
 
 
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"""