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
|
import torch
|
||||||
from transformers import AutoTokenizer # type: ignore[import]
|
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():
|
# Use local gguf module if available.
|
||||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
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
|
import gguf
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,9 @@ import numpy as np
|
||||||
import torch
|
import torch
|
||||||
from transformers import AutoTokenizer # type: ignore[import]
|
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():
|
# Use local gguf module if available.
|
||||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
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
|
import gguf
|
||||||
|
|
||||||
# ref: https://github.com/openai/gpt-2/blob/master/src/encoder.py
|
# 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 numpy as np
|
||||||
|
|
||||||
import os
|
import os
|
||||||
if os.environ.get('NO_LOCAL_GGUF') is None and Path('gguf-py', 'gguf', '__init__.py').is_file():
|
# Use local gguf module if available.
|
||||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
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
|
import gguf
|
||||||
|
|
||||||
# Note: Does not support GGML_QKK_64
|
# Note: Does not support GGML_QKK_64
|
||||||
|
|
|
@ -29,8 +29,9 @@ import numpy as np
|
||||||
from sentencepiece import SentencePieceProcessor # type: ignore[import]
|
from sentencepiece import SentencePieceProcessor # type: ignore[import]
|
||||||
|
|
||||||
import os
|
import os
|
||||||
if os.environ.get('NO_LOCAL_GGUF') is None and Path('gguf-py', 'gguf', '__init__.py').is_file():
|
# Use local gguf module if available.
|
||||||
sys.path.insert(1, str(Path('gguf-py', 'gguf').absolute()))
|
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
|
import gguf
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
|
@ -8,11 +8,9 @@ import sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
if os.environ.get('NO_LOCAL_GGUF') is None:
|
# Use local gguf module if available.
|
||||||
if Path('gguf-py', 'gguf', '__init__.py').is_file():
|
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('gguf-py', 'gguf').absolute()))
|
sys.path.insert(1, str(Path(__file__).parent.absolute().joinpath('..', '..', 'gguf-py', 'gguf')))
|
||||||
elif Path('..', '..', 'gguf-py', 'gguf', '__init__.py').is_file():
|
|
||||||
sys.path.insert(1, str(Path('..', '..', 'gguf-py', 'gguf').absolute()))
|
|
||||||
import gguf
|
import gguf
|
||||||
|
|
||||||
# gguf constants
|
# gguf constants
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue