model-library 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- model_library/__init__.py +7 -3
- model_library/logging.py +30 -0
- {model_library-0.1.0.dist-info → model_library-0.1.1.dist-info}/METADATA +36 -7
- {model_library-0.1.0.dist-info → model_library-0.1.1.dist-info}/RECORD +7 -6
- {model_library-0.1.0.dist-info → model_library-0.1.1.dist-info}/WHEEL +0 -0
- {model_library-0.1.0.dist-info → model_library-0.1.1.dist-info}/licenses/LICENSE +0 -0
- {model_library-0.1.0.dist-info → model_library-0.1.1.dist-info}/top_level.txt +0 -0
model_library/__init__.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
from model_library.settings import ModelLibrarySettings
|
|
2
1
|
from model_library.base import LLM, LLMConfig
|
|
2
|
+
from model_library.logging import set_logging
|
|
3
|
+
from model_library.settings import ModelLibrarySettings
|
|
3
4
|
|
|
4
5
|
model_library_settings: ModelLibrarySettings = ModelLibrarySettings()
|
|
5
6
|
|
|
7
|
+
set_logging()
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
def model(model_str: str, override_config: LLMConfig | None = None) -> LLM:
|
|
8
11
|
from model_library.registry_utils import get_registry_model
|
|
@@ -10,14 +13,15 @@ def model(model_str: str, override_config: LLMConfig | None = None) -> LLM:
|
|
|
10
13
|
return get_registry_model(model_str, override_config)
|
|
11
14
|
|
|
12
15
|
|
|
13
|
-
def raw_model(model_str: str,
|
|
16
|
+
def raw_model(model_str: str, config: LLMConfig | None = None) -> LLM:
|
|
14
17
|
from model_library.registry_utils import get_raw_model
|
|
15
18
|
|
|
16
|
-
return get_raw_model(model_str, config=
|
|
19
|
+
return get_raw_model(model_str, config=config)
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
__all__ = [
|
|
20
23
|
"model_library_settings",
|
|
21
24
|
"model",
|
|
22
25
|
"raw_model",
|
|
26
|
+
"set_logging",
|
|
23
27
|
]
|
model_library/logging.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
from rich.logging import RichHandler
|
|
5
|
+
|
|
6
|
+
_llm_logger = logging.getLogger("llm")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def set_logging(enable: bool = True, handler: logging.Handler | None = None):
|
|
10
|
+
"""
|
|
11
|
+
Sets up logging for the model library
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
enable (bool): Enable or disable logging.
|
|
15
|
+
handler (logging.Handler, optional): A custom logging handler. Defaults to RichHandler.
|
|
16
|
+
"""
|
|
17
|
+
if enable:
|
|
18
|
+
_llm_logger.setLevel(logging.INFO)
|
|
19
|
+
else:
|
|
20
|
+
_llm_logger.setLevel(logging.CRITICAL)
|
|
21
|
+
|
|
22
|
+
if not enable or _llm_logger.hasHandlers():
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
if handler is None:
|
|
26
|
+
console = Console()
|
|
27
|
+
handler = RichHandler(console=console, markup=True, show_time=False)
|
|
28
|
+
|
|
29
|
+
handler.setFormatter(logging.Formatter("%(name)s - %(levelname)s - %(message)s"))
|
|
30
|
+
_llm_logger.addHandler(handler)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: model-library
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Model Library for vals.ai
|
|
5
5
|
Author-email: "Vals AI, Inc." <contact@vals.ai>
|
|
6
6
|
License: MIT
|
|
@@ -10,6 +10,7 @@ License-File: LICENSE
|
|
|
10
10
|
Requires-Dist: typing-extensions<5.0,>=4.14.1
|
|
11
11
|
Requires-Dist: pydantic<3.0,>=2.11.7
|
|
12
12
|
Requires-Dist: pyyaml>=6.0.2
|
|
13
|
+
Requires-Dist: rich
|
|
13
14
|
Requires-Dist: backoff<3.0,>=2.2.1
|
|
14
15
|
Requires-Dist: redis<7.0,>=6.2.0
|
|
15
16
|
Requires-Dist: tiktoken==0.11.0
|
|
@@ -53,7 +54,14 @@ Open-source model library for interacting with a variety of LLM providers. Origi
|
|
|
53
54
|
- X AI
|
|
54
55
|
- ZhipuAI (zai)
|
|
55
56
|
|
|
56
|
-
Run `python -m scripts.browse_models` to browse the model registry
|
|
57
|
+
Run `python -m scripts.browse_models` to browse the model registry or
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from model_library.registry_utils import get_model_names_by_provider, get_provider_names
|
|
61
|
+
|
|
62
|
+
print(get_provider_names())
|
|
63
|
+
print(get_model_names_by_provider("chosen-provider"))
|
|
64
|
+
```
|
|
57
65
|
|
|
58
66
|
### Supported Input
|
|
59
67
|
|
|
@@ -70,16 +78,26 @@ Here is a basic example of how to query a model:
|
|
|
70
78
|
|
|
71
79
|
```python
|
|
72
80
|
import asyncio
|
|
73
|
-
from model_library
|
|
81
|
+
from model_library import model
|
|
74
82
|
|
|
75
83
|
async def main():
|
|
76
84
|
# Load a model from the registry
|
|
77
|
-
|
|
85
|
+
llm = model("anthropic/claude-opus-4-1-20250805-thinking")
|
|
86
|
+
|
|
87
|
+
# Display the LLM instance
|
|
88
|
+
llm.logger.info(llm)
|
|
89
|
+
# or print(llm)
|
|
78
90
|
|
|
79
91
|
# Query the model with a simple text input
|
|
80
|
-
|
|
92
|
+
result = await llm.query(
|
|
93
|
+
"What is QSBS? Explain your thinking in detail and make it concise."
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Logger automatically logs the result
|
|
97
|
+
|
|
98
|
+
# Display only the output text
|
|
99
|
+
llm.logger.info(result.output_text)
|
|
81
100
|
|
|
82
|
-
# Logger automatically logs the response
|
|
83
101
|
|
|
84
102
|
if __name__ == "__main__":
|
|
85
103
|
asyncio.run(main())
|
|
@@ -88,7 +106,18 @@ if __name__ == "__main__":
|
|
|
88
106
|
The model registry holds model attributes, ex. reasoning, file support, tool support, max tokens. You may also use models not included in the registry.
|
|
89
107
|
|
|
90
108
|
```python
|
|
91
|
-
|
|
109
|
+
from model_library import raw_model
|
|
110
|
+
from model_library.base import LLMConfig
|
|
111
|
+
|
|
112
|
+
model = raw_model("grok/grok-code-fast", LLMConfig(max_tokens=10000))
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Root logger is named "llm". To disable logging:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from model_library import set_logging
|
|
119
|
+
|
|
120
|
+
set_logging(enable=False)
|
|
92
121
|
```
|
|
93
122
|
|
|
94
123
|
### Environment Setup
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
model_library/__init__.py,sha256=
|
|
1
|
+
model_library/__init__.py,sha256=AKc_15aklOf-LbcS9z1Xer_moRWNpG6Dh3kqvSQ0nOI,714
|
|
2
2
|
model_library/base.py,sha256=JRzDZkYhzlEarknC0gX0sRplfxoFaqSb47gYhQy57sA,23834
|
|
3
3
|
model_library/exceptions.py,sha256=FnEQXTeC1GpcMEpwukGK7Uwu1_Bnvl87MUs1zOqVm0o,8750
|
|
4
4
|
model_library/file_utils.py,sha256=vLxYWI0-kwp67UONcFdZw2qDTV38P7IZLBaXFJDNtO4,3666
|
|
5
|
+
model_library/logging.py,sha256=McyaPHUk7RkB38-LrfnudrrU1B62ta8wAbbIBwLRmj0,853
|
|
5
6
|
model_library/model_utils.py,sha256=l8oCltGeimMGtnne_3Q1EguVtzCj61UMsLsma-1czwg,753
|
|
6
7
|
model_library/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
8
|
model_library/register_models.py,sha256=JOSt_VdtsllIshRGKVzKWG9DT7cFHd9JsjZLysi7cUw,13267
|
|
@@ -46,8 +47,8 @@ model_library/providers/zai.py,sha256=4Ui-2bPQ7m0NwQLJAaMezbLUNZOqBfWzq1JCR8f65N
|
|
|
46
47
|
model_library/providers/google/__init__.py,sha256=ypuLVL_QJEQ7C3S47FhC9y4wyawYOdGikAViJmACI0U,115
|
|
47
48
|
model_library/providers/google/batch.py,sha256=4TE90Uo1adi54dVtGcGyUAxw11YExJq-Y4KmkQ-cyHA,9978
|
|
48
49
|
model_library/providers/google/google.py,sha256=nsfiA6x0Mo6e6Q307ogA99fAOUqiEqWoMjmbLvFUikQ,16347
|
|
49
|
-
model_library-0.1.
|
|
50
|
-
model_library-0.1.
|
|
51
|
-
model_library-0.1.
|
|
52
|
-
model_library-0.1.
|
|
53
|
-
model_library-0.1.
|
|
50
|
+
model_library-0.1.1.dist-info/licenses/LICENSE,sha256=x6mf4o7U_wHaaqcfxoU-0R6uYJLbqL_TNuoULP3asaA,1070
|
|
51
|
+
model_library-0.1.1.dist-info/METADATA,sha256=IjFE4RqayFyEoejuGc680tYVZurKlFSuHq7X949p_Qc,7034
|
|
52
|
+
model_library-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
53
|
+
model_library-0.1.1.dist-info/top_level.txt,sha256=HtQYxA_7RP8UT35I6VcUw20L6edI0Zf2t5Ys1uDGVjs,14
|
|
54
|
+
model_library-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|