Fix vision pipeline: route images through Cat, pass user question to vision model
- Fix silent None return in analyze_image_with_vision exception handler - Add None/empty guards after vision analysis in bot.py (image, video, GIF, Tenor) - Route all image/video/GIF responses through Cheshire Cat pipeline (was calling query_llama directly), enabling episodic memory storage for media interactions and correct Last Prompt display in Web UI - Add media_type parameter to cat_adapter.query() and forward as discord_media_type in WebSocket payload - Update discord_bridge plugin to read media_type from payload and inject MEDIA NOTE into system prefix in before_agent_starts hook - Add _extract_vision_question() helper to strip Discord mentions and bot-name triggers from user message; pass cleaned question to vision model so specific questions (e.g. 'what is the person wearing?') go directly to the vision model instead of the generic 'Describe this image in detail.' fallback - Pass user_prompt to all analyze_image_with_qwen / analyze_video_with_vision call sites in bot.py (image, video, GIF, Tenor, embed paths) - Fix autonomous reaction loops skipping messages that @mention the bot or have media attachments in DMs, preventing duplicate vision model calls for images already being processed by the main message handler - Increase vision max_tokens: images 300->800, video/GIF 400->1000 (no VRAM impact; KV cache is pre-allocated at model load time)
This commit is contained in:
@@ -42,6 +42,7 @@ def before_cat_reads_message(user_message_json: dict, cat) -> dict:
|
||||
mood = user_message_json.get('discord_mood', None)
|
||||
response_type = user_message_json.get('discord_response_type', None)
|
||||
evil_mode = user_message_json.get('discord_evil_mode', False)
|
||||
media_type = user_message_json.get('discord_media_type', None)
|
||||
|
||||
# Also check working memory for backward compatibility
|
||||
if not guild_id:
|
||||
@@ -53,6 +54,7 @@ def before_cat_reads_message(user_message_json: dict, cat) -> dict:
|
||||
cat.working_memory['mood'] = mood
|
||||
cat.working_memory['response_type'] = response_type
|
||||
cat.working_memory['evil_mode'] = evil_mode
|
||||
cat.working_memory['media_type'] = media_type
|
||||
|
||||
return user_message_json
|
||||
|
||||
@@ -263,6 +265,18 @@ CRITICAL RULES:
|
||||
Miku is currently feeling: {mood_description}
|
||||
Please respond in a way that reflects this emotional tone."""
|
||||
|
||||
# Add media type awareness if provided (image/video/gif analysis)
|
||||
media_type = cat.working_memory.get('media_type', None)
|
||||
if media_type:
|
||||
media_descriptions = {
|
||||
"image": "The user has sent you an image.",
|
||||
"video": "The user has sent you a video clip.",
|
||||
"gif": "The user has sent you an animated GIF.",
|
||||
"tenor_gif": "The user has sent you an animated GIF (from Tenor - likely a reaction GIF or meme)."
|
||||
}
|
||||
media_note = media_descriptions.get(media_type, f"The user has sent you {media_type}.")
|
||||
system_prefix += f"\n\n📎 MEDIA NOTE: {media_note}\nYour vision analysis of this {media_type} is included in the user's message with the [Looking at...] prefix."
|
||||
|
||||
except Exception as e:
|
||||
print(f" [Discord Bridge] Error building system prefix: {e}")
|
||||
system_prefix = cat.working_memory.get('full_system_prefix', '[system prefix not available]')
|
||||
|
||||
Reference in New Issue
Block a user