после решения проблемы с падежами и добавления памяти
This commit is contained in:
21
main.py
21
main.py
@@ -13,6 +13,7 @@ Flow:
|
||||
|
||||
import signal
|
||||
import sys
|
||||
from collections import deque
|
||||
|
||||
from wakeword import wait_for_wakeword, cleanup as cleanup_wakeword, check_wakeword_once
|
||||
from stt import listen, cleanup as cleanup_stt, get_recognizer
|
||||
@@ -49,6 +50,9 @@ def main():
|
||||
init_tts() # Then initialize TTS model
|
||||
print()
|
||||
|
||||
# Initialize chat history (last 10 exchanges = 20 messages)
|
||||
chat_history = deque(maxlen=20)
|
||||
|
||||
# Main loop
|
||||
skip_wakeword = False
|
||||
while True:
|
||||
@@ -76,6 +80,14 @@ def main():
|
||||
speak("Извините, я вас не расслышал. Попробуйте ещё раз.")
|
||||
continue
|
||||
|
||||
# Check for stop commands
|
||||
user_text_lower = user_text.lower().strip()
|
||||
if user_text_lower in ["стоп", "александр", "стоп александр"]:
|
||||
print("_" * 50)
|
||||
print("💤 Жду 'Alexandr' для активации...")
|
||||
skip_wakeword = False
|
||||
continue
|
||||
|
||||
# Check for volume command
|
||||
if user_text.lower().startswith("громкость"):
|
||||
try:
|
||||
@@ -102,7 +114,14 @@ def main():
|
||||
continue
|
||||
|
||||
# Step 3: Send to AI
|
||||
ai_response = ask_ai(user_text)
|
||||
# Add user message to history
|
||||
chat_history.append({"role": "user", "content": user_text})
|
||||
|
||||
# Get response using history
|
||||
ai_response = ask_ai(list(chat_history))
|
||||
|
||||
# Add AI response to history
|
||||
chat_history.append({"role": "assistant", "content": ai_response})
|
||||
|
||||
# Step 4: Clean response
|
||||
clean_text = clean_response(ai_response)
|
||||
|
||||
Reference in New Issue
Block a user