Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,25 @@ def __init__(
if not os.path.exists(model_path):
raise ValueError(f"Model path does not exist: {model_path}")

self._model = self._stack.enter_context(
contextlib.closing(
internals.LlamaModel(
path_model=self.model_path,
params=self.model_params,
verbose=self.verbose,
try:
self._model = self._stack.enter_context(
contextlib.closing(
internals.LlamaModel(
path_model=self.model_path,
params=self.model_params,
verbose=self.verbose,
)
)
)
)
)
except RuntimeError as e:
if "No such file or directory" in str(e):
raise FileNotFoundError(
f"Model file not found at '{self.model_path}'. "
"Make sure the .gguf model file exists at the given path."
) from e
else:
raise


# Override tokenizer
self.tokenizer_ = tokenizer or LlamaTokenizer(self)
Expand Down