Infinity: Use a runtime type hint for engine

Remove the antipattern of the conditional type for the Async engine
and use string-based type inference.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-11-22 18:06:08 -05:00
parent 242ff4f892
commit aa4ccd03d4

View file

@ -17,12 +17,8 @@ class InfinityContainer:
model_is_loading: bool = False
model_loaded: bool = False
# Conditionally set the type hint based on importablity
# TODO: Clean this up
if dependencies.extras:
engine: Optional[AsyncEmbeddingEngine] = None
else:
engine = None
# Use a runtime type hint here
engine: Optional["AsyncEmbeddingEngine"] = None
def __init__(self, model_directory: pathlib.Path):
self.model_dir = model_directory