Skip to content

prompts #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
modal serve src.app
5 changes: 5 additions & 0 deletions src/moshi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions src/prompts/custom_instructions.py
Original file line number Diff line number Diff line change
@@ -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