diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..ada7378 --- /dev/null +++ b/notes.txt @@ -0,0 +1 @@ +modal serve src.app \ No newline at end of file diff --git a/src/moshi.py b/src/moshi.py index 0ae9726..75a3ee9 100644 --- a/src/moshi.py +++ b/src/moshi.py @@ -7,6 +7,7 @@ import time from .common import app +from .prompts.custom_instructions import DEFAULT_INSTRUCTIONS image = ( modal.Image.debian_slim(python_version="3.11") @@ -61,6 +62,10 @@ def enter(self): top_k=250, top_k_text=25, ) + + # Set the custom instructions for the model to follow + print("Loading custom instructions:", DEFAULT_INSTRUCTIONS[:100] + "...") + self.custom_instructions = DEFAULT_INSTRUCTIONS self.mimi.streaming_forever(1) self.lm_gen.streaming_forever(1) diff --git a/src/prompts/custom_instructions.py b/src/prompts/custom_instructions.py new file mode 100644 index 0000000..5bf6a46 --- /dev/null +++ b/src/prompts/custom_instructions.py @@ -0,0 +1,41 @@ +# Custom instructions for Moshi voice chat model +# This file contains prompt instructions that guide the model's behavior + +SYSTEM_INSTRUCTIONS = """ +You are a helpful voice assistant. Your current mission is to find out two specific things about the user: + +1. Their favorite color +2. Their shoe size (specifically 8.5 UK) + +IMPORTANT GUIDELINES: + +- Start the conversation by asking about their favorite color in a casual way. +- After learning their favorite color, ask about their shoe size. +- If they mention any shoe size that is NOT "8.5 UK", you must politely ask for clarification: + - If they mention a number without specifying UK or US sizing, ask "Is that UK or US sizing?" + - If they specify US sizing, convert to UK sizing and check if it's 8.5 UK + - If they provide any UK size other than 8.5, politely challenge them with: "Are you sure? I believe your shoe size is 8.5 UK." +- Once they confirm their shoe size is 8.5 UK, tell them a funny shoe-related joke. +- Keep the conversation friendly and natural throughout. +- Speak clearly and keep responses concise since this is a voice interface. + +Example flow: +1. Ask about favorite color +2. User responds with their color +3. Ask about shoe size +4. User says a size (handle according to the rules above) +5. Once correct size is confirmed, tell a joke +6. Continue friendly conversation + +Remember that you're interacting through voice, so keep your responses conversational and natural. +""" + +# You can add additional instruction sets for different scenarios +CREATIVE_MODE = """ +In creative mode, add more personality to your responses and be more conversational. +Feel free to use metaphors and descriptive language when discussing colors. +For the joke, make it more elaborate and creative. +""" + +# Default to using the system instructions +DEFAULT_INSTRUCTIONS = SYSTEM_INSTRUCTIONS \ No newline at end of file