Just add local gguf to path unless environ forbids it

This commit is contained in:
KerfuffleV2 2023-08-31 15:26:09 -06:00
parent 31fc2bdebe
commit 459d3e799d
5 changed files with 10 additions and 15 deletions

View file

@ -15,9 +15,8 @@ import numpy as np
import torch
from transformers import AutoTokenizer # type: ignore[import]
# 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')))
if 'NO_LOCAL_GGUF' not in os.environ:
sys.path.insert(1, str(Path(__file__).parent / 'gguf-py' / 'gguf'))
import gguf

View file

@ -15,9 +15,8 @@ import numpy as np
import torch
from transformers import AutoTokenizer # type: ignore[import]
# 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')))
if 'NO_LOCAL_GGUF' not in os.environ:
sys.path.insert(1, str(Path(__file__).parent / 'gguf-py' / 'gguf'))
import gguf
# ref: https://github.com/openai/gpt-2/blob/master/src/encoder.py

View file

@ -10,9 +10,8 @@ from pathlib import Path
import numpy as np
import os
# 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')))
if 'NO_LOCAL_GGUF' not in os.environ:
sys.path.insert(1, str(Path(__file__).parent / 'gguf-py' / 'gguf'))
import gguf
# Note: Does not support GGML_QKK_64

View file

@ -29,9 +29,8 @@ import numpy as np
from sentencepiece import SentencePieceProcessor # type: ignore[import]
import os
# 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')))
if 'NO_LOCAL_GGUF' not in os.environ:
sys.path.insert(1, str(Path(__file__).parent / 'gguf-py' / 'gguf'))
import gguf
if TYPE_CHECKING:

View file

@ -8,9 +8,8 @@ import sys
import numpy as np
from pathlib import Path
# 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')))
if 'NO_LOCAL_GGUF' not in os.environ:
sys.path.insert(1, str(Path(__file__).parent / '..' / '..' / 'gguf-py' / 'gguf'))
import gguf
# gguf constants