From 849dd71a01837716593bc4f92746c00d3d08880b Mon Sep 17 00:00:00 2001 From: mtayfur Date: Sun, 12 Oct 2025 23:03:36 +0300 Subject: [PATCH] Refactor memory selection logic in LLMRerankingService for improved clarity; streamline response handling by directly using response.ids. --- memory_system.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/memory_system.py b/memory_system.py index 5e43cea..e04424d 100644 --- a/memory_system.py +++ b/memory_system.py @@ -730,11 +730,9 @@ CANDIDATE MEMORIES: try: response = await self.memory_system._query_llm(Prompts.MEMORY_RERANKING, user_prompt, response_model=Models.MemoryRerankingResponse) - selected_ids = response.ids - selected_memories = [] for memory in candidate_memories: - if memory["id"] in selected_ids and len(selected_memories) < max_count: + if memory["id"] in response.ids and len(selected_memories) < max_count: selected_memories.append(memory) logger.info(f"🧠 LLM selected {len(selected_memories)} out of {len(candidate_memories)} candidates") @@ -777,7 +775,6 @@ CANDIDATE MEMORIES: duration_text = f" in {duration:.2f}s" if duration >= 0.01 else "" retrieval_method = "LLM" if should_use_llm else "Semantic" await self.memory_system._emit_status(emitter, f"🎯 {retrieval_method} Memory Retrieval Complete{duration_text}", done=True) - logger.info(f"🎯 {retrieval_method} Memory Retrieval Complete{duration_text}") return selected_memories, analysis_info