Skip to content

Commit 7270224

Browse files
committed
update stop phrases, exit and quit only, calibrated how sensitive the mood detection is
1 parent 5375ce6 commit 7270224

File tree

8 files changed

+26
-23
lines changed

8 files changed

+26
-23
lines changed

.env.sample

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ DEBUG=false
8787
# List of trigger phrases to have the model view your desktop (desktop, browser, images, etc.).
8888
# It will describe what it sees, and you can ask questions about it:
8989
# "what's on my screen", "take a screenshot", "show me my screen", "analyze my screen",
90-
# "what do you see on my screen", "screen capture", "screenshot"
90+
# "what do you see on my screen", "screen capture", "screenshot"
91+
# To stop the conversation, say "Quit" or "Exit". ( ctl+c always works also)

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ DEBUG=false
413413
# It will describe what it sees, and you can ask questions about it:
414414
# "what's on my screen", "take a screenshot", "show me my screen", "analyze my screen",
415415
# "what do you see on my screen", "screen capture", "screenshot"
416-
# To stop the conversation, say "Quit", "Exit", or "Leave". ( ctl+c always works also)
416+
# To stop the conversation, say "Quit" or "Exit". ( ctl+c always works also)
417417
```
418418

419419
### Audio Commands
@@ -426,7 +426,7 @@ DEBUG=false
426426
"what do you see on my screen",
427427
"screen capture",
428428
"screenshot" to have the AI explain what it is seeing in detail.
429-
- To stop the conversation, say "Quit", "Exit", or "Leave". ( ctl+c always works also in terminal )
429+
- To stop the conversation, say "Quit" or "Exit". ( ctl+c always works also in terminal )
430430

431431
### ElevenLabs
432432

@@ -489,7 +489,7 @@ For the CLI version, the voice ID in the .env file will be used.
489489
490490
### Web View - Visual and Audio input / output
491491
492-
Press start to start talking. Take a break hit stop, when ready again hit start again. Press stop to change characters and voices in dropdown. You can also select the Model Provider and TTS Provider you want in the dropdown menu and it will update and use the selected provider moving forward. Saying Exit, Leave or Quit is like pressing stop.
492+
Press start to start talking. Take a break hit stop, when ready again hit start again. Press stop to change characters and voices in dropdown. You can also select the Model Provider and TTS Provider you want in the dropdown menu and it will update and use the selected provider moving forward. Saying Exit or Quit is like pressing stop.
493493
494494
http://localhost:8000/
495495
@@ -711,7 +711,7 @@ Model provider: openai
711711
Model: gpt-4o
712712
Character: Nerd
713713
Text-to-Speech provider: elevenlabs
714-
To stop chatting say Quit, Leave or Exit. Say, what's on my screen, to have AI view screen. One moment please loading...
714+
To stop chatting say Quit or Exit. Say, what's on my screen, to have AI view screen. One moment please loading...
715715
INFO: Started server process [12752]
716716
INFO: Waiting for application startup.
717717
INFO: Application startup complete.

app/app.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def sync_play_audio(file_path):
239239
print(f"Model: {OPENAI_MODEL if MODEL_PROVIDER == 'openai' else XAI_MODEL if MODEL_PROVIDER == 'xai' else OLLAMA_MODEL}")
240240
print(f"Character: {character_display_name}")
241241
print(f"Text-to-Speech provider: {TTS_PROVIDER}")
242-
print("To stop chatting say Quit, Leave or Exit. Say, what's on my screen, to have AI view screen. One moment please loading...")
242+
print("To stop chatting say Quit or Exit. One moment please loading...")
243243

244244
async def process_and_play(prompt, audio_file_pth):
245245
# Always get the current character name to ensure we have the right audio file
@@ -517,7 +517,7 @@ def analyze_mood(user_input):
517517
"yucky", "ugh", "eww", "blegh", "blech", "ew"
518518
]
519519
happy_keywords = [
520-
"happy", "pleased", "content", "satisfied", "good", "great",
520+
"happy", "pleased", "content", "satisfied", "great",
521521
"positive", "upbeat", "bright", "cheery", "merry", "lighthearted",
522522
"gratified", "blessed", "fortunate", "lucky", "peaceful", "serene",
523523
"comfortable", "at ease", "fulfilled", "optimistic", "hopeful", "sunny",
@@ -547,24 +547,24 @@ def analyze_mood(user_input):
547547
]
548548

549549
mood = "neutral" # Default value
550-
550+
551551
if any(keyword in user_input.lower() for keyword in flirty_keywords):
552552
mood = "flirty"
553-
elif any(keyword in user_input.lower() for keyword in angry_keywords):
553+
elif any(keyword in user_input.lower() for keyword in angry_keywords) or polarity < -0.7:
554554
mood = "angry"
555-
elif any(keyword in user_input.lower() for keyword in sad_keywords):
555+
elif any(keyword in user_input.lower() for keyword in sad_keywords) or polarity < -0.3:
556556
mood = "sad"
557557
elif any(keyword in user_input.lower() for keyword in fearful_keywords):
558558
mood = "fearful"
559559
elif any(keyword in user_input.lower() for keyword in surprised_keywords):
560560
mood = "surprised"
561561
elif any(keyword in user_input.lower() for keyword in disgusted_keywords):
562562
mood = "disgusted"
563-
elif any(keyword in user_input.lower() for keyword in happy_keywords):
563+
elif any(keyword in user_input.lower() for keyword in happy_keywords) or polarity > 0.7:
564564
mood = "happy"
565-
elif any(keyword in user_input.lower() for keyword in joyful_keywords) or polarity > 0.3:
565+
elif any(keyword in user_input.lower() for keyword in joyful_keywords) or polarity > 0.4:
566566
mood = "joyful"
567-
elif any(keyword in user_input.lower() for keyword in neutral_keywords):
567+
elif any(keyword in user_input.lower() for keyword in neutral_keywords) or (-0.3 <= polarity <= 0.4):
568568
mood = "neutral"
569569

570570
# Color mapping for different moods
@@ -585,6 +585,7 @@ def analyze_mood(user_input):
585585

586586
# Print the detected mood with the corresponding color
587587
print(f"{color}Detected mood: {mood}\033[0m")
588+
print() # Add an empty line for spacing in CLI output
588589

589590
return mood
590591

@@ -1075,7 +1076,7 @@ async def user_chatbot_conversation():
10751076

10761077
base_system_message = open_file(character_prompt_file)
10771078

1078-
quit_phrases = ["quit", "Quit", "Quit.", "Exit.", "exit", "Exit", "leave", "Leave."]
1079+
quit_phrases = ["quit", "Quit", "Quit.", "Exit.", "exit", "Exit"]
10791080
screenshot_phrases = [
10801081
"what's on my screen",
10811082
"take a screenshot",
@@ -1096,7 +1097,7 @@ async def user_chatbot_conversation():
10961097

10971098
# Check for quit phrases with word boundary check
10981099
words = user_input.lower().split()
1099-
if any(phrase.lower().rstrip('.') in words for phrase in quit_phrases):
1100+
if any(phrase.lower().rstrip('.') == word for phrase in quit_phrases for word in words):
11001101
print("Quitting the conversation...")
11011102
break
11021103

app/app_logic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ async def process_text(user_input):
116116

117117
return chatbot_response
118118

119-
quit_phrases = ["quit", "Quit", "Quit.", "Exit.", "exit", "Exit", "leave", "Leave."]
119+
quit_phrases = ["quit", "Quit", "Quit.", "Exit.", "exit", "Exit"]
120120
screenshot_phrases = [
121121
"what's on my screen",
122122
"take a screenshot",
@@ -252,7 +252,7 @@ async def conversation_loop():
252252

253253
# Check for quit phrases with word boundary check
254254
words = user_input.lower().split()
255-
if any(phrase.lower() in words for phrase in quit_phrases):
255+
if any(phrase.lower().rstrip('.') == word for phrase in quit_phrases for word in words):
256256
print("Quitting the conversation...")
257257
await stop_conversation()
258258
break

app/enhanced_logic.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
DEBUG = os.getenv("DEBUG", "false").lower() == "true" # Control detailed debug output
3232

3333
# Quit phrases that will stop the conversation when detected
34-
QUIT_PHRASES = ["quit", "exit", "leave", "end", "bye", "goodbye"]
34+
QUIT_PHRASES = ["quit", "exit"]
3535

3636
def load_character_prompt(character_name):
3737
"""
@@ -556,7 +556,8 @@ async def save_history():
556556
await send_message_to_enhanced_clients({"action": "mic", "status": "processing"})
557557

558558
# Check for quit commands
559-
if user_input.lower() in QUIT_PHRASES:
559+
words = user_input.lower().split()
560+
if any(phrase.lower().rstrip('.') == word for phrase in QUIT_PHRASES for word in words):
560561
await send_message_to_enhanced_clients({"message": "Conversation ended.", "type": "system-message"})
561562
break
562563

app/templates/enhanced.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ <h1>
270270
<option value="sage">Sage - female</option>
271271
<option value="coral">Coral - female</option>
272272
<option value="ash">Ash - male</option>
273-
<option value="ballad">Ballad - male</option>
274-
<option value="verse">Verse - male</option>
273+
<option value="ballad">Ballad - male - no tts-1</option>
274+
<option value="verse">Verse - male - no tts-1</option>
275275
</select>
276276
</div>
277277

cli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def play_audio(file_path):
168168
print(f"Character: {character_display_name}")
169169
print(f"Text-to-Speech provider: {TTS_PROVIDER}")
170170
print(f"Text-to-Speech model: {OPENAI_MODEL_TTS if TTS_PROVIDER == 'openai' else ELEVENLABS_TTS_MODEL if TTS_PROVIDER == 'elevenlabs' else 'local' if TTS_PROVIDER == 'xtts' else 'Unknown'}")
171-
print("To stop chatting say Quit, Leave or Exit. Say, what's on my screen, to have AI view screen. One moment please loading...")
171+
print("To stop chatting say Quit or Exit. One moment please loading...")
172172

173173
# Function to synthesize speech using XTTS
174174
def process_and_play(prompt, audio_file_pth):
@@ -1076,7 +1076,7 @@ def user_chatbot_conversation():
10761076
conversation_history = []
10771077

10781078
base_system_message = open_file(character_prompt_file)
1079-
quit_phrases = ["quit", "Quit", "Quit.", "Exit.", "exit", "Exit", "leave", "Leave", "Leave."]
1079+
quit_phrases = ["quit", "Quit", "Quit.", "Exit.", "exit", "Exit"]
10801080
screenshot_phrases = [
10811081
"what's on my screen",
10821082
"take a screenshot",

0 commit comments

Comments
 (0)