MCPcopy
hub / github.com/PromtEngineer/localGPT / create_index_interactive

Method create_index_interactive

create_index_script.py:177–237  Ā·  view source on GitHub ↗

Run the interactive index creation process.

(self)

Source from the content-addressed store, hash-verified

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:

Callers 1

mainFunction Ā· 0.95

Calls 6

get_user_inputMethod Ā· 0.95
select_documentsMethod Ā· 0.95
configure_processingMethod Ā· 0.95
test_indexMethod Ā· 0.95
create_indexMethod Ā· 0.80
add_document_to_indexMethod Ā· 0.80

Tested by

no test coverage detected