4.0 KiB
4.0 KiB
Japanese Mode - Quick Reference for Web UI
What Was Implemented
A language toggle system for the Miku bot that switches between:
- English Mode (Default) - Uses standard Llama 3.1 model
- Japanese Mode - Uses Llama 3.1 Swallow model, responds entirely in Japanese
API Endpoints
1. Check Language Status
GET /language
Response:
{
"language_mode": "english",
"available_languages": ["english", "japanese"],
"current_model": "llama3.1"
}
2. Toggle Language (English ↔ Japanese)
POST /language/toggle
Response:
{
"status": "ok",
"language_mode": "japanese",
"model_now_using": "swallow",
"message": "Miku is now speaking in JAPANESE!"
}
3. Set Specific Language
POST /language/set?language=japanese
or
POST /language/set?language=english
Response:
{
"status": "ok",
"language_mode": "japanese",
"model_now_using": "swallow",
"message": "Miku is now speaking in JAPANESE!"
}
Web UI Integration
Add a simple toggle button to your web UI:
<button onclick="toggleLanguage()">🌐 Toggle Language</button>
<div id="language-status">English</div>
<script>
async function toggleLanguage() {
const response = await fetch('/language/toggle', { method: 'POST' });
const data = await response.json();
document.getElementById('language-status').textContent =
data.language_mode.toUpperCase();
}
async function getLanguageStatus() {
const response = await fetch('/language');
const data = await response.json();
document.getElementById('language-status').textContent =
data.language_mode.toUpperCase();
}
// Check status on load
getLanguageStatus();
</script>
Design Approach
Why no full translation of prompts?
Instead of translating all Miku's personality prompts to Japanese, we:
- Keep English context - Helps the Swallow model understand Miku's personality better
- Append language instruction - Add "Respond entirely in Japanese (日本語)" to the prompt
- Let Swallow handle it - The model is trained for Japanese and understands English instructions
Benefits:
- ✅ Minimal implementation effort
- ✅ No translation maintenance needed
- ✅ Model still understands Miku's complete personality
- ✅ Can easily expand to other languages
- ✅ Works perfectly for instruction-based language switching
How the Bot Behaves
English Mode
- Responds in English
- Uses standard Llama 3.1 model
- All personality and context in English
- Emoji reactions work as normal
Japanese Mode
- Responds entirely in 日本語 (Japanese)
- Uses Llama 3.1 Swallow model (trained on Japanese text)
- Understands English context but responds in Japanese
- Maintains same personality and mood system
Testing the Implementation
- Default behavior - Miku speaks English
- Toggle once - Miku switches to Japanese
- Send message - Check if response is in Japanese
- Toggle again - Miku switches back to English
- Send message - Confirm response is in English
Technical Details
| Component | English | Japanese |
|---|---|---|
| Text Model | llama3.1 |
swallow |
| Prompts | miku_prompt.txt | miku_prompt_jp.txt |
| Lore | miku_lore.txt | miku_lore_jp.txt |
| Lyrics | miku_lyrics.txt | miku_lyrics_jp.txt |
| Language Instruction | None | "Respond in 日本語 only" |
Notes
- Language mode is global (affects all users/servers)
- If you need per-server language settings, store mode in
servers_config.json - Evil mode takes priority over language mode if both are active
- Conversation history stores both English and Japanese messages seamlessly
- Vision model always uses NVIDIA GPU (language mode doesn't affect vision)
Future Improvements
- Save language preference to
memory/servers_config.json - Add
LANGUAGE_MODEto per-server settings - Create per-channel language support
- Add language auto-detection from user messages
- Create fully translated Japanese prompt files for better accuracy