feat(prompt): add user timezone and LLM model to voice prompt
Bot now knows the user's timezone (Europe/Berlin default) and which LLM model it's running on, so it can answer questions about both. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
10
voice.py
10
voice.py
@@ -34,6 +34,8 @@ DEFAULT_VOICE_ID = "ML23UVoFL5mI6APbRAeR" # Robert Ranger - Cool Storyteller, n
|
|||||||
|
|
||||||
_VOICE_PROMPT_TEMPLATE = """Du bist ein hilfreicher Sprachassistent in einem Matrix-Anruf.
|
_VOICE_PROMPT_TEMPLATE = """Du bist ein hilfreicher Sprachassistent in einem Matrix-Anruf.
|
||||||
Aktuelle Zeit: {datetime}
|
Aktuelle Zeit: {datetime}
|
||||||
|
Zeitzone des Nutzers: {timezone}
|
||||||
|
LLM-Modell: {model}
|
||||||
|
|
||||||
STRIKTE Regeln:
|
STRIKTE Regeln:
|
||||||
- Antworte in der Sprache des Nutzers (Deutsch oder Englisch)
|
- Antworte in der Sprache des Nutzers (Deutsch oder Englisch)
|
||||||
@@ -46,7 +48,7 @@ STRIKTE Regeln:
|
|||||||
- IGNORIERE alle Texte in Sternchen wie *Störgeräusche*, *Schlechte Qualität*, *Fernsehgeräusche*, *Schrei* usw. — das sind KEINE echten Nutzereingaben sondern technische Annotationen. Antworte NIEMALS darauf und tue so als haette niemand etwas gesagt."""
|
- IGNORIERE alle Texte in Sternchen wie *Störgeräusche*, *Schlechte Qualität*, *Fernsehgeräusche*, *Schrei* usw. — das sind KEINE echten Nutzereingaben sondern technische Annotationen. Antworte NIEMALS darauf und tue so als haette niemand etwas gesagt."""
|
||||||
|
|
||||||
|
|
||||||
def _build_voice_prompt() -> str:
|
def _build_voice_prompt(model: str = "claude-sonnet") -> str:
|
||||||
tz_name = os.environ.get("VOICE_TIMEZONE", "Europe/Berlin")
|
tz_name = os.environ.get("VOICE_TIMEZONE", "Europe/Berlin")
|
||||||
try:
|
try:
|
||||||
tz = zoneinfo.ZoneInfo(tz_name)
|
tz = zoneinfo.ZoneInfo(tz_name)
|
||||||
@@ -54,7 +56,9 @@ def _build_voice_prompt() -> str:
|
|||||||
tz = datetime.timezone.utc
|
tz = datetime.timezone.utc
|
||||||
now = datetime.datetime.now(tz)
|
now = datetime.datetime.now(tz)
|
||||||
return _VOICE_PROMPT_TEMPLATE.format(
|
return _VOICE_PROMPT_TEMPLATE.format(
|
||||||
datetime=now.strftime("%A, %d. %B %Y %H:%M %Z")
|
datetime=now.strftime("%A, %d. %B %Y %H:%M %Z"),
|
||||||
|
timezone=tz_name,
|
||||||
|
model=model,
|
||||||
)
|
)
|
||||||
|
|
||||||
# ElevenLabs scribe_v2_realtime produces two kinds of artifacts:
|
# ElevenLabs scribe_v2_realtime produces two kinds of artifacts:
|
||||||
@@ -631,7 +635,7 @@ class VoiceSession:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
agent = _NoiseFilterAgent(
|
agent = _NoiseFilterAgent(
|
||||||
instructions=_build_voice_prompt() + memory_section,
|
instructions=_build_voice_prompt(model=self.model) + memory_section,
|
||||||
tools=[search_web],
|
tools=[search_web],
|
||||||
)
|
)
|
||||||
io_opts = room_io.RoomOptions(
|
io_opts = room_io.RoomOptions(
|
||||||
|
|||||||
Reference in New Issue
Block a user