fix issues with optional dependencies (#204)

* fix issues with optional dependencies

* format document

* Tree: Format and comment
This commit is contained in:
TerminalMan
2024-09-20 03:24:55 +01:00
committed by GitHub
parent 75af974c88
commit 3aeddc5255
9 changed files with 104 additions and 53 deletions

View File

@@ -5,16 +5,12 @@ from loguru import logger
from typing import List, Optional
from common.utils import unwrap
from common.optional_dependencies import dependencies
# Conditionally import infinity to sidestep its logger
has_infinity_emb: bool = False
try:
if dependencies.extras:
from infinity_emb import EngineArgs, AsyncEmbeddingEngine
has_infinity_emb = True
except ImportError:
pass
class InfinityContainer:
model_dir: pathlib.Path
@@ -23,7 +19,7 @@ class InfinityContainer:
# Conditionally set the type hint based on importablity
# TODO: Clean this up
if has_infinity_emb:
if dependencies.extras:
engine: Optional[AsyncEmbeddingEngine] = None
else:
engine = None