Run the interactive index creation process.
(self)
| 175 | } |
| 176 | |
| 177 | def create_index_interactive(self) -> None: |
| 178 | """Run the interactive index creation process.""" |
| 179 | print("š LocalGPT Index Creation Tool") |
| 180 | print("=" * 50) |
| 181 | |
| 182 | # Get index details |
| 183 | index_name = self.get_user_input("Enter index name") |
| 184 | index_description = self.get_user_input("Enter index description (optional)") |
| 185 | |
| 186 | # Select documents |
| 187 | documents = self.select_documents() |
| 188 | |
| 189 | # Configure processing |
| 190 | processing_config = self.configure_processing() |
| 191 | |
| 192 | # Confirm creation |
| 193 | print("\nš Index Summary") |
| 194 | print("=" * 50) |
| 195 | print(f"Name: {index_name}") |
| 196 | print(f"Description: {index_description or 'None'}") |
| 197 | print(f"Documents: {len(documents)}") |
| 198 | print(f"Chunk size: {processing_config['chunk_size']}") |
| 199 | print(f"Enrichment: {'Enabled' if processing_config['enable_enrich'] else 'Disabled'}") |
| 200 | print(f"Embedding model: {processing_config['embedding_model']}") |
| 201 | |
| 202 | if self.get_user_input("\nProceed with index creation? (y/n)", "y").lower() != 'y': |
| 203 | print("ā Index creation cancelled.") |
| 204 | return |
| 205 | |
| 206 | # Create the index |
| 207 | try: |
| 208 | print("\nš„ Creating index...") |
| 209 | |
| 210 | # Create index record in database |
| 211 | index_id = self.db.create_index( |
| 212 | name=index_name, |
| 213 | description=index_description, |
| 214 | metadata=processing_config |
| 215 | ) |
| 216 | |
| 217 | # Add documents to index |
| 218 | for doc_path in documents: |
| 219 | filename = os.path.basename(doc_path) |
| 220 | self.db.add_document_to_index(index_id, filename, doc_path) |
| 221 | |
| 222 | # Process documents through pipeline |
| 223 | print("š Processing documents...") |
| 224 | self.pipeline.process_documents(documents) |
| 225 | |
| 226 | print(f"\nā Index '{index_name}' created successfully!") |
| 227 | print(f"Index ID: {index_id}") |
| 228 | print(f"Processed {len(documents)} documents") |
| 229 | |
| 230 | # Test the index |
| 231 | if self.get_user_input("\nTest the index with a sample query? (y/n)", "y").lower() == 'y': |
| 232 | self.test_index(index_id) |
| 233 | |
| 234 | except Exception as e: |
no test coverage detected