Cleanup the Python instance from the global registry Call this method when you're done using a HuggingFace or other PythonBridge configuration to free memory and Python resources. Returns True if an instance was removed, False otherwise. Example: config = LlmConfig.huggingface(api_key="...", model="...") # ... use config ... config.cleanup() # Frees resources
(&self)
| 368 | /// # ... use config ... |
| 369 | /// config.cleanup() # Frees resources |
| 370 | fn cleanup(&self) -> bool { |
| 371 | if let CoreLlmConfig::PythonBridge { |
| 372 | instance_id: Some(ref id), |
| 373 | .. |
| 374 | } = self.inner |
| 375 | { |
| 376 | unregister_python_instance(id) |
| 377 | } else { |
| 378 | false |
| 379 | } |
| 380 | } |
| 381 | /// Context manager entry point |
| 382 | /// |
| 383 | /// Enables `with` statement usage for automatic resource cleanup: |