|
61 | 61 | "import numpy as np\n", |
62 | 62 | "import yaml\n", |
63 | 63 | "\n", |
| 64 | + "from graphrag.config.models.vector_store_schema_config import VectorStoreSchemaConfig\n", |
64 | 65 | "from graphrag.data_model.types import TextEmbedder\n", |
65 | 66 | "\n", |
66 | 67 | "# GraphRAG vector store components\n", |
|
147 | 148 | " self.vectors: dict[str, np.ndarray] = {}\n", |
148 | 149 | " self.connected = False\n", |
149 | 150 | "\n", |
150 | | - " print(\n", |
151 | | - " f\"🚀 SimpleInMemoryVectorStore initialized for collection: {self.collection_name}\"\n", |
152 | | - " )\n", |
| 151 | + " print(f\"🚀 SimpleInMemoryVectorStore initialized for index: {self.index_name}\")\n", |
153 | 152 | "\n", |
154 | 153 | " def connect(self, **kwargs: Any) -> None:\n", |
155 | 154 | " \"\"\"Connect to the vector storage (no-op for in-memory store).\"\"\"\n", |
156 | 155 | " self.connected = True\n", |
157 | | - " print(f\"✅ Connected to in-memory vector store: {self.collection_name}\")\n", |
| 156 | + " print(f\"✅ Connected to in-memory vector store: {self.index_name}\")\n", |
158 | 157 | "\n", |
159 | 158 | " def load_documents(\n", |
160 | 159 | " self, documents: list[VectorStoreDocument], overwrite: bool = True\n", |
|
250 | 249 | " def get_stats(self) -> dict[str, Any]:\n", |
251 | 250 | " \"\"\"Get statistics about the vector store (custom method).\"\"\"\n", |
252 | 251 | " return {\n", |
253 | | - " \"collection_name\": self.collection_name,\n", |
| 252 | + " \"index_name\": self.index_name,\n", |
254 | 253 | " \"document_count\": len(self.documents),\n", |
255 | 254 | " \"vector_count\": len(self.vectors),\n", |
256 | 255 | " \"connected\": self.connected,\n", |
|
353 | 352 | "outputs": [], |
354 | 353 | "source": [ |
355 | 354 | "# Test creating vector store using the factory\n", |
356 | | - "vector_store_config = {\"collection_name\": \"test_collection\"}\n", |
| 355 | + "schema = VectorStoreSchemaConfig(index_name=\"test_collection\")\n", |
357 | 356 | "\n", |
358 | 357 | "# Create vector store instance using factory\n", |
359 | 358 | "vector_store = VectorStoreFactory.create_vector_store(\n", |
360 | | - " CUSTOM_VECTOR_STORE_TYPE, vector_store_config\n", |
| 359 | + " CUSTOM_VECTOR_STORE_TYPE, vector_store_schema_config=schema\n", |
361 | 360 | ")\n", |
362 | 361 | "\n", |
363 | 362 | "print(f\"✅ Created vector store instance: {type(vector_store).__name__}\")\n", |
|
486 | 485 | " print(\"🚀 Simulating GraphRAG pipeline with custom vector store...\\n\")\n", |
487 | 486 | "\n", |
488 | 487 | " # 1. GraphRAG creates vector store using factory\n", |
489 | | - " config = {\"collection_name\": \"graphrag_entities\", \"similarity_threshold\": 0.3}\n", |
| 488 | + " schema = VectorStoreSchemaConfig(index_name=\"graphrag_entities\")\n", |
490 | 489 | "\n", |
491 | | - " store = VectorStoreFactory.create_vector_store(CUSTOM_VECTOR_STORE_TYPE, config)\n", |
| 490 | + " store = VectorStoreFactory.create_vector_store(\n", |
| 491 | + " CUSTOM_VECTOR_STORE_TYPE,\n", |
| 492 | + " vector_store_schema_config=schema,\n", |
| 493 | + " similarity_threshold=0.3,\n", |
| 494 | + " )\n", |
492 | 495 | " store.connect()\n", |
493 | 496 | "\n", |
494 | 497 | " print(\"✅ Step 1: Vector store created and connected\")\n", |
|
549 | 552 | " # Test 1: Basic functionality\n", |
550 | 553 | " print(\"Test 1: Basic functionality\")\n", |
551 | 554 | " store = VectorStoreFactory.create_vector_store(\n", |
552 | | - " CUSTOM_VECTOR_STORE_TYPE, {\"collection_name\": \"test\"}\n", |
| 555 | + " CUSTOM_VECTOR_STORE_TYPE,\n", |
| 556 | + " vector_store_schema_config=VectorStoreSchemaConfig(index_name=\"test\"),\n", |
553 | 557 | " )\n", |
554 | 558 | " store.connect()\n", |
555 | 559 | "\n", |
|
597 | 601 | " # Test 5: Error handling\n", |
598 | 602 | " print(\"\\nTest 5: Error handling\")\n", |
599 | 603 | " disconnected_store = VectorStoreFactory.create_vector_store(\n", |
600 | | - " CUSTOM_VECTOR_STORE_TYPE, {\"collection_name\": \"test2\"}\n", |
| 604 | + " CUSTOM_VECTOR_STORE_TYPE,\n", |
| 605 | + " vector_store_schema_config=VectorStoreSchemaConfig(index_name=\"test2\"),\n", |
601 | 606 | " )\n", |
602 | 607 | "\n", |
603 | 608 | " try:\n", |
|
653 | 658 | ], |
654 | 659 | "metadata": { |
655 | 660 | "kernelspec": { |
656 | | - "display_name": "graphrag-venv (3.10.18)", |
| 661 | + "display_name": "graphrag", |
657 | 662 | "language": "python", |
658 | 663 | "name": "python3" |
659 | 664 | }, |
|
667 | 672 | "name": "python", |
668 | 673 | "nbconvert_exporter": "python", |
669 | 674 | "pygments_lexer": "ipython3", |
670 | | - "version": "3.10.18" |
| 675 | + "version": "3.12.10" |
671 | 676 | } |
672 | 677 | }, |
673 | 678 | "nbformat": 4, |
|
0 commit comments