Spaces:
Running on Zero
Running on Zero
Download scratch/debug_thala_query.py from arka7/discord-rag-memory-bot: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/arka7/discord-rag-memory-bot/resolve/main/scratch/debug_thala_query.py
- Command line
-
hf download hf://spaces/arka7/discord-rag-memory-bot/scratch/debug_thala_query.py
-
curl -L -o debug_thala_query.py https://huggingface.co/spaces/arka7/discord-rag-memory-bot/resolve/main/scratch/debug_thala_query.py
1.04 kB
| import sys | |
| import os | |
| sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | |
| import asyncio | |
| from services import MistralEmbeddingService, SQLiteVectorStoreService | |
| from database.database import init_db, get_db_session | |
| from database.repository import DiscordRAGRepository | |
| from utils.logger import logger | |
| async def debug_thala(): | |
| init_db() | |
| embedder = MistralEmbeddingService() | |
| vector_db = SQLiteVectorStoreService() | |
| query = "what kind of person is @thalacool" | |
| q_vecs = await embedder.get_embeddings([query]) | |
| q_vec = q_vecs[0] | |
| # Run general search | |
| results = await vector_db.search_similar(q_vec, top_k=250, channel_id=817421565183918089) | |
| logger.info(f"Retrieved {len(results)} matches.") | |
| # Let's inspect the top 15 matches content and author | |
| for i, (_, score, meta) in enumerate(results[:15], 1): | |
| logger.info(f"[{i}] Score: {score:.4f} | @{meta['author']} in #{meta['channel']}: {meta['content']}") | |
| if __name__ == "__main__": | |
| asyncio.run(debug_thala()) | |