forked from tilesprivacy/tiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
52 lines (40 loc) · 1.1 KB
/
__init__.py
File metadata and controls
52 lines (40 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
`mlx_engine` is LM Studio's LLM inferencing engine for Apple MLX
"""
__all__ = [
"load_model",
"load_draft_model",
"is_draft_model_compatible",
"unload_draft_model",
"create_generator",
"tokenize",
]
from pathlib import Path
import os
from .utils.disable_hf_download import patch_huggingface_hub
from .utils.register_models import register_models
from .utils.logger import setup_logging
from .generate import (
load_model,
load_draft_model,
is_draft_model_compatible,
unload_draft_model,
create_generator,
tokenize,
)
patch_huggingface_hub()
register_models()
setup_logging()
def _set_outlines_cache_dir(cache_dir: Path | str):
"""
Set the cache dir for Outlines.
Outlines reads the OUTLINES_CACHE_DIR environment variable to
determine where to read/write its cache files
"""
if "OUTLINES_CACHE_DIR" in os.environ:
return
cache_dir = Path(cache_dir).expanduser().resolve()
os.environ["OUTLINES_CACHE_DIR"] = str(cache_dir)
_set_outlines_cache_dir(
os.getenv("TILES_OUTLINES_CACHE", "~/.cache/tiles/.internal/outlines")
)