fix: strip filler phrases from agent response before TTS
This commit is contained in:
@@ -21,6 +21,19 @@ RESET_PATTERNS = re.compile(
|
|||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Фразы-заглушки которые агент генерирует ДО вызова инструмента
|
||||||
|
FILLER_PATTERNS = re.compile(
|
||||||
|
r'(?:(?:сейчас посмотрю|дай мне секунду|дай секунду|проверяю|загружаю|узнаю'
|
||||||
|
r'|смотрю|одну секунду|я сейчас посмотрю|я проверю|попробую другой источник'
|
||||||
|
r'|нужны конкретные числа|дай мне загрузить)[^.!?]*[.!?]?\s*)+',
|
||||||
|
re.IGNORECASE
|
||||||
|
)
|
||||||
|
|
||||||
|
def strip_fillers(text: str) -> str:
|
||||||
|
return FILLER_PATTERNS.sub('', text).strip()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def is_reset_command(text: str) -> bool:
|
def is_reset_command(text: str) -> bool:
|
||||||
return bool(RESET_PATTERNS.search(text))
|
return bool(RESET_PATTERNS.search(text))
|
||||||
@@ -113,7 +126,7 @@ def ask_agent_stream(text: str, conv=None, agent_id: str = "cosmo") -> str:
|
|||||||
_maybe_speak(msg)
|
_maybe_speak(msg)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
result = clean_for_speech(full_text)
|
result = clean_for_speech(strip_fillers(full_text))
|
||||||
|
|
||||||
if TTS_MODE == "full":
|
if TTS_MODE == "full":
|
||||||
_maybe_speak(result)
|
_maybe_speak(result)
|
||||||
|
|||||||
Reference in New Issue
Block a user