Skip to content

Commit

Permalink
Fix locally compiled llama-cpp-python failing to import
Browse files Browse the repository at this point in the history
  • Loading branch information
oobabooga committed Oct 14, 2024
1 parent c9a9f63 commit bb62e79
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/llama_cpp_python_hijack.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
from modules.cache_utils import process_llamacpp_cache

imported_module = None
not_available_modules = set()


def llama_cpp_lib():
global imported_module
global imported_module, not_available_modules

# Determine the platform
is_macos = platform.system() == 'Darwin'
Expand All @@ -31,6 +32,9 @@ def llama_cpp_lib():
]

for arg, lib_name in lib_names:
if lib_name in not_available_modules:
continue

should_import = (arg is None or getattr(shared.args, arg))

if should_import:
Expand All @@ -44,6 +48,7 @@ def llama_cpp_lib():
monkey_patch_llama_cpp_python(return_lib)
return return_lib
except ImportError:
not_available_modules.add(lib_name)
continue

return None
Expand Down

0 comments on commit bb62e79

Please sign in to comment.