Implement vector search for answer suggestions based on message history#193
Open
konard wants to merge 3 commits into
Open
Implement vector search for answer suggestions based on message history#193konard wants to merge 3 commits into
konard wants to merge 3 commits into
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: undefined
This implementation addresses issue #24 by adding vector search functionality to suggest answers based on similar historical conversations. Key features: - Uses @xenova/transformers for local embeddings (all-MiniLM-L6-v2 model) - Implements Vectra for local vector database storage - Creates SuggestAnswerTrigger to analyze message history - Indexes incoming messages and finds similar historical exchanges - Suggests responses based on past answers to similar questions Technical details: - Added vector-search.js module for embeddings and similarity search - Added triggers/suggest-answer.js for bot integration - Integrated trigger into index.js message handling - Added experiment script for testing vector search functionality - Added Jest tests for vector search module - Updated .gitignore to exclude vector index directories The solution works offline using local models and stores vector indexes in .vector-indexes/ directory (gitignored). Suggestions are logged and stored in peer state for potential future use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit 34d98a8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Issue Reference
Fixes #24
🎯 Summary
This PR implements vector search functionality to suggest answers to messages/questions based on the bot's conversation history. The solution uses local machine learning models to find similar past exchanges and suggest appropriate responses.
✨ Key Features
🔧 Technical Implementation
New Files
vector-search.js - Core vector search module
generateEmbedding()- Creates 384-dim embeddings using all-MiniLM-L6-v2indexMessages()- Indexes message history into vector databasesearchSimilarMessages()- Finds similar messages using cosine similaritysuggestAnswers()- Analyzes history to suggest responsestriggers/suggest-answer.js - Bot integration trigger
experiments/test-vector-search.js - Test script
tests/vector-search.test.js - Unit tests
Modified Files
📊 Performance
🧪 Testing
Experiment script output demonstrates successful operation:
💡 How It Works
Bot maintains last 100 messages per peer in memory
When a new message arrives, the SuggestAnswerTrigger:
Suggestions are stored in peer state for future use (e.g., UI display, logging)
🔒 Privacy & Storage
.vector-indexes/(gitignored)clearIndex()function📝 Notes
🚀 Future Enhancements
🤖 Generated with Claude Code