From 71310b8e8430047e694982b5a451bfb84dc1ae0c Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Wed, 29 Apr 2026 01:08:29 +0200 Subject: [PATCH] fix(perception): resolve UNKNOWN screen classification on explore grid and fix LLM fallback API 1. Added a robust structural heuristic for EXPLORE_GRID that looks for 'action_bar_search_edit_text' alongside 'search_tab', eliminating the reliance on the flaky 'selected' attribute. 2. Fixed a critical bug in the LLM semantic fallback where it was incorrectly querying the '/api/chat' endpoint using an '/api/generate' payload format, causing silent 400 Bad Request failures. 3. Corrected the fallback model assignment to use 'ai_model' (e.g. qwen3.5) instead of 'ai_embedding_model' (which incorrectly attempted to use nomic-embed-text or llama3 for chat completion). --- GramAddict/core/perception/screen_identity.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/GramAddict/core/perception/screen_identity.py b/GramAddict/core/perception/screen_identity.py index ff9ba1f..535e3ea 100644 --- a/GramAddict/core/perception/screen_identity.py +++ b/GramAddict/core/perception/screen_identity.py @@ -219,6 +219,8 @@ class ScreenIdentity: return ScreenType.REELS_FEED if selected_tab == "search_tab": return ScreenType.EXPLORE_GRID + if "action_bar_search_edit_text" in ids and "search_tab" in ids: + return ScreenType.EXPLORE_GRID if selected_tab == "profile_tab": return ScreenType.OWN_PROFILE if selected_tab == "direct_tab": @@ -232,11 +234,11 @@ class ScreenIdentity: cfg = Config() url = ( - getattr(cfg.args, "ai_embedding_url", "http://localhost:11434/api/chat") + getattr(cfg.args, "ai_model_url", "http://localhost:11434/api/generate") if hasattr(cfg, "args") - else "http://localhost:11434/api/chat" + else "http://localhost:11434/api/generate" ) - model = getattr(cfg.args, "ai_embedding_model", "llama3") if hasattr(cfg, "args") else "llama3" + model = getattr(cfg.args, "ai_model", "qwen3.5:latest") if hasattr(cfg, "args") else "qwen3.5:latest" layout_context = ( f"Selected Tab: {selected_tab}\nResource IDs: {list(ids)}\nVisible Texts context: {texts[:10]}\n"