Files
miku-discord/readmes/JAPANESE_MODE_QUICK_START.md

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:

  1. Keep English context - Helps the Swallow model understand Miku's personality better
  2. Append language instruction - Add "Respond entirely in Japanese (日本語)" to the prompt
  3. 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

  1. Default behavior - Miku speaks English
  2. Toggle once - Miku switches to Japanese
  3. Send message - Check if response is in Japanese
  4. Toggle again - Miku switches back to English
  5. 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

  1. Save language preference to memory/servers_config.json
  2. Add LANGUAGE_MODE to per-server settings
  3. Create per-channel language support
  4. Add language auto-detection from user messages
  5. Create fully translated Japanese prompt files for better accuracy