diff --git a/vibe_bot/database.py b/vibe_bot/database.py index d9ad452..10513df 100644 --- a/vibe_bot/database.py +++ b/vibe_bot/database.py @@ -138,13 +138,17 @@ class ChatDatabase: def _calculate_similarity(self, vec1: np.ndarray, vec2: np.ndarray) -> float: """Calculate cosine similarity between two vectors.""" + vec1 = vec1.flatten() + vec2 = vec2.flatten() logger.debug( "Calculating cosine similarity between vectors of dimension %d", len(vec1), ) - result = float( - np.dot(vec1, vec2) / (np.linalg.norm(vec1) * np.linalg.norm(vec2)), - ) + norm1 = np.linalg.norm(vec1) + norm2 = np.linalg.norm(vec2) + if norm1 == 0 or norm2 == 0: + return 0.0 + result = float(np.dot(vec1, vec2) / (norm1 * norm2)) logger.debug("Similarity calculated: %.4f", result) return result diff --git a/vibe_bot/main.py b/vibe_bot/main.py index f4f34c1..ae385d7 100644 --- a/vibe_bot/main.py +++ b/vibe_bot/main.py @@ -328,6 +328,15 @@ async def on_message(message: Message) -> None: await bot.process_commands(message) +@bot.command(name="lobotomize") +async def lobotomize(ctx: CommandsContext[Bot]) -> None: + """Clear all conversation history and memory for all bots.""" + logger.info("Lobotomize command triggered by %s", ctx.author.name) + db = get_database() + db.clear_all_messages() + await ctx.send("All conversation history and memory has been cleared. 🧠✨") + + @bot.command(name="voices") async def voices(ctx: CommandsContext[Bot]) -> None: """List all available TTS voices organized by category."""