mirror of
https://github.com/bentoml/OpenLLM.git
synced 2026-02-18 22:55:08 -05:00
fix(annotations): check library through find_spec (#691)
Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
import functools
|
||||
import importlib.util
|
||||
import logging
|
||||
import os
|
||||
import types
|
||||
@@ -349,12 +350,8 @@ class LLM(t.Generic[M, T], ReprMixin):
|
||||
|
||||
@property
|
||||
def adapter_map(self):
|
||||
try:
|
||||
import peft as _ # noqa: F401
|
||||
except ImportError as err:
|
||||
raise MissingDependencyError(
|
||||
"Failed to import 'peft'. Make sure to do 'pip install \"openllm[fine-tune]\"'"
|
||||
) from err
|
||||
if importlib.util.find_spec('peft') is None:
|
||||
raise MissingDependencyError("Failed to import 'peft'. Make sure to do 'pip install \"openllm[fine-tune]\"'")
|
||||
if not self.has_adapters:
|
||||
raise AttributeError('Adapter map is not available.')
|
||||
assert self._adapter_map is not None
|
||||
|
||||
@@ -24,7 +24,7 @@ from openllm_core.utils.representation import ReprArgs
|
||||
from ._quantisation import QuantizationConfig
|
||||
from ._runners import Runner
|
||||
|
||||
InjectedModel = Union[PeftModel | PeftModelForCausalLM | PeftModelForSeq2SeqLM]
|
||||
InjectedModel = Union[PeftModel, PeftModelForCausalLM, PeftModelForSeq2SeqLM]
|
||||
|
||||
class IdentifyingParams(TypedDict):
|
||||
configuration: str
|
||||
|
||||
Reference in New Issue
Block a user