Look for local gguf module relative to running script file
This commit is contained in:
parent
489ffb2525
commit
4b54a7e7bc
5 changed files with 15 additions and 13 deletions
|
@ -15,8 +15,9 @@ import numpy as np
|
|||
import torch
|
||||
from transformers import AutoTokenizer # type: ignore[import]
|
||||
|
||||
if os.environ.get('NO_LOCAL_GGUF') is None and Path('gguf-py', 'gguf', '__init__.py').is_file():
|
||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
||||
# Use local gguf module if available.
|
||||
if 'NO_LOCAL_GGUF' not in os.environ and (Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf', '__init__.py')).is_file():
|
||||
sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf')))
|
||||
import gguf
|
||||
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ import numpy as np
|
|||
import torch
|
||||
from transformers import AutoTokenizer # type: ignore[import]
|
||||
|
||||
if os.environ.get('NO_LOCAL_GGUF') is None and Path('gguf-py', 'gguf', '__init__.py').is_file():
|
||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
||||
# Use local gguf module if available.
|
||||
if 'NO_LOCAL_GGUF' not in os.environ and (Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf', '__init__.py')).is_file():
|
||||
sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf')))
|
||||
import gguf
|
||||
|
||||
# ref: https://github.com/openai/gpt-2/blob/master/src/encoder.py
|
||||
|
|
|
@ -10,8 +10,9 @@ from pathlib import Path
|
|||
import numpy as np
|
||||
|
||||
import os
|
||||
if os.environ.get('NO_LOCAL_GGUF') is None and Path('gguf-py', 'gguf', '__init__.py').is_file():
|
||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
||||
# Use local gguf module if available.
|
||||
if 'NO_LOCAL_GGUF' not in os.environ and (Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf', '__init__.py')).is_file():
|
||||
sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf')))
|
||||
import gguf
|
||||
|
||||
# Note: Does not support GGML_QKK_64
|
||||
|
|
|
@ -29,8 +29,9 @@ import numpy as np
|
|||
from sentencepiece import SentencePieceProcessor # type: ignore[import]
|
||||
|
||||
import os
|
||||
if os.environ.get('NO_LOCAL_GGUF') is None and Path('gguf-py', 'gguf', '__init__.py').is_file():
|
||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
||||
# Use local gguf module if available.
|
||||
if 'NO_LOCAL_GGUF' not in os.environ and (Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf', '__init__.py')).is_file():
|
||||
sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('gguf-py', 'gguf')))
|
||||
import gguf
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
|
@ -8,11 +8,9 @@ import sys
|
|||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
if os.environ.get('NO_LOCAL_GGUF') is None:
|
||||
if Path('gguf-py', 'gguf', '__init__.py').is_file():
|
||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
||||
elif Path('..', '..', 'gguf-py', 'gguf', '__init__.py').is_file():
|
||||
sys.path.insert(1, str(Path('..', '..', 'gguf-py', 'gguf').absolute()))
|
||||
# Use local gguf module if available.
|
||||
if 'NO_LOCAL_GGUF' not in os.environ and (Path(__file__).parent.absolute().joinpath('..', '..', 'gguf-py', 'gguf', '__init__.py')).is_file():
|
||||
sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('..', '..', 'gguf-py', 'gguf')))
|
||||
import gguf
|
||||
|
||||
# gguf constants
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue