Skip to content

Commit

Permalink
feat: improve error handling for module imports in PretrainedModelForQA
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravarthik27 committed Jan 27, 2025
1 parent d82daca commit e4f8d7e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions langtest/modelhandler/llm_modelhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ def load_model(cls, hub: str, path: str, *args, **kwargs) -> "PretrainedModelFor
cls.model = model(**path)
return cls(hub, cls.model, *args, **filtered_kwargs)

except ModuleNotFoundError:
module = CHAT_MODEL_CLASSES[hub].get("module", None)
if module:
package_name = module.split(".")[0]
raise ValueError(Errors.E078(hub=hub, lib=package_name))
raise ValueError(Errors.E078(hub=hub, lib=package_name))
except ImportError:
raise ValueError(Errors.E044(path=path))
except ValidationError as e:
Expand Down

0 comments on commit e4f8d7e

Please sign in to comment.