mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-04-20 14:28:54 +00:00
fix issues with optional dependencies (#204)
* fix issues with optional dependencies * format document * Tree: Format and comment
This commit is contained in:
@@ -5,34 +5,6 @@ from importlib.metadata import PackageNotFoundError, version as package_version
|
||||
from loguru import logger
|
||||
|
||||
|
||||
def check_exllama_version():
|
||||
"""Verifies the exllama version"""
|
||||
|
||||
required_version = version.parse("0.2.2")
|
||||
current_version = version.parse(package_version("exllamav2").split("+")[0])
|
||||
|
||||
unsupported_message = (
|
||||
f"ERROR: TabbyAPI requires ExLlamaV2 {required_version} "
|
||||
f"or greater. Your current version is {current_version}.\n"
|
||||
"Please update your environment by running an update script "
|
||||
"(update_scripts/"
|
||||
f"update_deps.{'bat' if platform.system() == 'Windows' else 'sh'})\n\n"
|
||||
"Or you can manually run a requirements update "
|
||||
"using the following command:\n\n"
|
||||
"For CUDA 12.1:\n"
|
||||
"pip install --upgrade .[cu121]\n\n"
|
||||
"For CUDA 11.8:\n"
|
||||
"pip install --upgrade .[cu118]\n\n"
|
||||
"For ROCm:\n"
|
||||
"pip install --upgrade .[amd]\n\n"
|
||||
)
|
||||
|
||||
if current_version < required_version:
|
||||
raise SystemExit(unsupported_message)
|
||||
else:
|
||||
logger.info(f"ExllamaV2 version: {current_version}")
|
||||
|
||||
|
||||
def hardware_supports_flash_attn(gpu_device_list: list[int]):
|
||||
"""
|
||||
Check whether all GPUs in list support FA2
|
||||
|
||||
39
backends/exllamav2/version.py
Normal file
39
backends/exllamav2/version.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import platform
|
||||
from packaging import version
|
||||
from importlib.metadata import version as package_version
|
||||
from loguru import logger
|
||||
from common.optional_dependencies import dependencies
|
||||
|
||||
|
||||
def check_exllama_version():
|
||||
"""Verifies the exllama version"""
|
||||
|
||||
install_message = (
|
||||
"Please update your environment by running an update script "
|
||||
"(update_scripts/"
|
||||
f"update_deps.{'bat' if platform.system() == 'Windows' else 'sh'})\n\n"
|
||||
"Or you can manually run a requirements update "
|
||||
"using the following command:\n\n"
|
||||
"For CUDA 12.1:\n"
|
||||
"pip install --upgrade .[cu121]\n\n"
|
||||
"For CUDA 11.8:\n"
|
||||
"pip install --upgrade .[cu118]\n\n"
|
||||
"For ROCm:\n"
|
||||
"pip install --upgrade .[amd]\n\n"
|
||||
)
|
||||
|
||||
if not dependencies.exl2:
|
||||
raise SystemExit(("Exllamav2 is not installed.\n" + install_message))
|
||||
|
||||
required_version = version.parse("0.2.2")
|
||||
current_version = version.parse(package_version("exllamav2").split("+")[0])
|
||||
|
||||
unsupported_message = (
|
||||
f"ERROR: TabbyAPI requires ExLlamaV2 {required_version} "
|
||||
f"or greater. Your current version is {current_version}.\n" + install_message
|
||||
)
|
||||
|
||||
if current_version < required_version:
|
||||
raise SystemExit(unsupported_message)
|
||||
else:
|
||||
logger.info(f"ExllamaV2 version: {current_version}")
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user