| import asyncio |
| from app.services.vector_store import vector_store |
| from app.services.document_ingestion import initialize_knowledge_base_async |
|
|
| async def fix_collection(): |
| print("=" * 60) |
| print("π§ FIXING QDRANT COLLECTION DIMENSIONS") |
| print("=" * 60) |
| |
| try: |
| |
| print("\n1οΈβ£ Deleting old collection (1536 dimensions)...") |
| vector_store.delete_collection() |
| print(" β Old collection deleted") |
| except Exception as e: |
| print(f" βΉ Collection delete: {e}") |
| |
| try: |
| |
| print("\n2οΈβ£ Creating new collection (768 dimensions for Gemini)...") |
| vector_store.create_collection(force_recreate=True) |
| print(" β New collection created") |
| except Exception as e: |
| print(f" β Error creating collection: {e}") |
| return |
| |
| try: |
| |
| print("\n3οΈβ£ Re-ingesting documents with Gemini embeddings...") |
| print(" (This may take a few minutes...)") |
| doc_ids = await initialize_knowledge_base_async() |
| print(f" β Successfully ingested {len(doc_ids)} documents") |
| except Exception as e: |
| print(f" β Error ingesting documents: {e}") |
| import traceback |
| traceback.print_exc() |
| return |
| |
| print("\n" + "=" * 60) |
| print("β
MIGRATION COMPLETE!") |
| print("=" * 60) |
| print(f"β Collection: book_documents (768 dimensions)") |
| print(f"β Documents: {len(doc_ids)} chunks") |
| print(f"β Embedding model: Gemini text-embedding-004") |
| print(f"β LLM model: Gemini 2.0 Flash") |
| print("\nYou can now start your application! π") |
| print("=" * 60) |
|
|
| if __name__ == "__main__": |
| asyncio.run(fix_collection()) |