Spaces:
Running
Running
use "with" statement for more safety (it's my opinion)
#2
by
funlifew
- opened
Used with open(...) to ensure proper file handling and automatic closing of file descriptors.
Simplified and cleaned up conditionals for better readability.
Added exception handling to gracefully catch unexpected errors.
Used .get() with default fallbacks when accessing response JSON to prevent KeyError.
Returned API's reported inference time if available, otherwise used locally measured time as a fallback.
Improved naming and formatting for consistency with Python conventions.