ommlds 0.0.0.dev506__py3-none-any.whl → 0.0.0.dev508__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.
- ommlds/.omlish-manifests.json +24 -0
- ommlds/backends/anthropic/protocol/types.py +5 -7
- ommlds/backends/cerebras/protocol.py +3 -5
- ommlds/backends/google/protocol/types.py +6 -8
- ommlds/backends/groq/protocol.py +3 -5
- ommlds/backends/huggingface/__init__.py +0 -0
- ommlds/backends/{huggingface.py → huggingface/cache.py} +1 -6
- ommlds/backends/huggingface/cli.py +208 -0
- ommlds/backends/ollama/_dataclasses.py +452 -0
- ommlds/backends/ollama/cli.py +36 -0
- ommlds/backends/ollama/protocol.py +36 -8
- ommlds/backends/openai/protocol/_common.py +3 -5
- ommlds/backends/tavily/protocol.py +3 -5
- ommlds/backends/torch/backends.py +1 -1
- ommlds/minichain/_typedvalues.py +4 -4
- ommlds/minichain/backends/impls/google/search.py +4 -4
- ommlds/minichain/backends/strings/parsing.py +1 -1
- ommlds/minichain/chat/messages.py +3 -3
- ommlds/minichain/models/configs.py +2 -2
- ommlds/minichain/services/_marshal.py +2 -2
- ommlds/minichain/tools/execution/catalog.py +1 -1
- ommlds/minichain/tools/types.py +4 -4
- ommlds/specs/mcp/protocol.py +4 -6
- ommlds/wiki/models.py +4 -4
- ommlds/wiki/text/mfh.py +9 -9
- {ommlds-0.0.0.dev506.dist-info → ommlds-0.0.0.dev508.dist-info}/METADATA +4 -4
- {ommlds-0.0.0.dev506.dist-info → ommlds-0.0.0.dev508.dist-info}/RECORD +31 -28
- {ommlds-0.0.0.dev506.dist-info → ommlds-0.0.0.dev508.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev506.dist-info → ommlds-0.0.0.dev508.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev506.dist-info → ommlds-0.0.0.dev508.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev506.dist-info → ommlds-0.0.0.dev508.dist-info}/top_level.txt +0 -0
ommlds/.omlish-manifests.json
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"module": ".backends.huggingface.cli",
|
|
4
|
+
"attr": "_CLI_MODULE",
|
|
5
|
+
"file": "ommlds/backends/huggingface/cli.py",
|
|
6
|
+
"line": 203,
|
|
7
|
+
"value": {
|
|
8
|
+
"!omdev.cli.types.CliModule": {
|
|
9
|
+
"name": "hf",
|
|
10
|
+
"module": "ommlds.backends.huggingface.cli"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"module": ".backends.ollama.cli",
|
|
16
|
+
"attr": "_CLI_MODULE",
|
|
17
|
+
"file": "ommlds/backends/ollama/cli.py",
|
|
18
|
+
"line": 31,
|
|
19
|
+
"value": {
|
|
20
|
+
"!omdev.cli.types.CliModule": {
|
|
21
|
+
"name": "ollama",
|
|
22
|
+
"module": "ommlds.backends.ollama.cli"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
2
26
|
{
|
|
3
27
|
"module": ".cli.__main__",
|
|
4
28
|
"attr": null,
|
|
@@ -12,12 +12,10 @@ from omlish import marshal as msh
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _set_class_marshal_options(cls):
|
|
15
|
-
msh.
|
|
15
|
+
msh.update_object_options(
|
|
16
16
|
cls,
|
|
17
|
-
field_defaults=msh.
|
|
18
|
-
|
|
19
|
-
omit_if=lang.is_none,
|
|
20
|
-
),
|
|
17
|
+
field_defaults=msh.FieldOptions(
|
|
18
|
+
omit_if=lang.is_none,
|
|
21
19
|
),
|
|
22
20
|
)
|
|
23
21
|
|
|
@@ -43,7 +41,7 @@ class Text(Content):
|
|
|
43
41
|
|
|
44
42
|
_: dc.KW_ONLY
|
|
45
43
|
|
|
46
|
-
cache_control: Content.CacheControl | None = dc.xfield(default=None, repr_fn=
|
|
44
|
+
cache_control: Content.CacheControl | None = dc.xfield(default=None, repr_fn=lang.opt_repr)
|
|
47
45
|
|
|
48
46
|
|
|
49
47
|
@dc.dataclass(frozen=True)
|
|
@@ -55,7 +53,7 @@ class ToolUse(Content):
|
|
|
55
53
|
|
|
56
54
|
_: dc.KW_ONLY
|
|
57
55
|
|
|
58
|
-
cache_control: Content.CacheControl | None = dc.xfield(default=None, repr_fn=
|
|
56
|
+
cache_control: Content.CacheControl | None = dc.xfield(default=None, repr_fn=lang.opt_repr)
|
|
59
57
|
|
|
60
58
|
|
|
61
59
|
@dc.dataclass(frozen=True)
|
|
@@ -12,12 +12,10 @@ from omlish import marshal as msh
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _set_class_marshal_options(cls):
|
|
15
|
-
msh.
|
|
15
|
+
msh.update_object_options(
|
|
16
16
|
cls,
|
|
17
|
-
field_defaults=msh.
|
|
18
|
-
|
|
19
|
-
omit_if=lang.is_none,
|
|
20
|
-
),
|
|
17
|
+
field_defaults=msh.FieldOptions(
|
|
18
|
+
omit_if=lang.is_none,
|
|
21
19
|
),
|
|
22
20
|
)
|
|
23
21
|
|
|
@@ -12,13 +12,11 @@ from omlish import marshal as msh
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _set_class_marshal_options(cls):
|
|
15
|
-
msh.
|
|
15
|
+
msh.update_object_options(
|
|
16
16
|
cls,
|
|
17
17
|
field_naming=msh.Naming.LOW_CAMEL,
|
|
18
|
-
field_defaults=msh.
|
|
19
|
-
|
|
20
|
-
omit_if=lang.is_none,
|
|
21
|
-
),
|
|
18
|
+
field_defaults=msh.FieldOptions(
|
|
19
|
+
omit_if=lang.is_none,
|
|
22
20
|
),
|
|
23
21
|
)
|
|
24
22
|
|
|
@@ -27,7 +25,7 @@ def _set_class_marshal_options(cls):
|
|
|
27
25
|
|
|
28
26
|
@dc.dataclass(frozen=True, kw_only=True)
|
|
29
27
|
@_set_class_marshal_options
|
|
30
|
-
@msh.
|
|
28
|
+
@msh.update_fields_options(
|
|
31
29
|
['data'],
|
|
32
30
|
marshaler=msh.Base64MarshalerUnmarshaler(bytes),
|
|
33
31
|
unmarshaler=msh.Base64MarshalerUnmarshaler(bytes),
|
|
@@ -125,7 +123,7 @@ class VideoMetadata(lang.Final):
|
|
|
125
123
|
|
|
126
124
|
|
|
127
125
|
@dc.dataclass(frozen=True, kw_only=True)
|
|
128
|
-
@msh.
|
|
126
|
+
@msh.update_fields_options(
|
|
129
127
|
['thought_signature'],
|
|
130
128
|
marshaler=msh.OptionalMarshaler(msh.Base64MarshalerUnmarshaler(bytes)),
|
|
131
129
|
unmarshaler=msh.OptionalUnmarshaler(msh.Base64MarshalerUnmarshaler(bytes)),
|
|
@@ -197,7 +195,7 @@ class Value(lang.Abstract, lang.Sealed):
|
|
|
197
195
|
|
|
198
196
|
|
|
199
197
|
@dc.dataclass(frozen=True)
|
|
200
|
-
@msh.
|
|
198
|
+
@msh.update_object_options(field_naming=msh.Naming.LOW_CAMEL)
|
|
201
199
|
class NullValue(Value, lang.Final):
|
|
202
200
|
null_value: None = None
|
|
203
201
|
|
ommlds/backends/groq/protocol.py
CHANGED
|
@@ -12,12 +12,10 @@ from omlish import marshal as msh
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def _set_class_marshal_options(cls):
|
|
15
|
-
msh.
|
|
15
|
+
msh.update_object_options(
|
|
16
16
|
cls,
|
|
17
|
-
field_defaults=msh.
|
|
18
|
-
|
|
19
|
-
omit_if=lang.is_none,
|
|
20
|
-
),
|
|
17
|
+
field_defaults=msh.FieldOptions(
|
|
18
|
+
omit_if=lang.is_none,
|
|
21
19
|
),
|
|
22
20
|
)
|
|
23
21
|
|
|
File without changes
|
|
@@ -11,15 +11,10 @@ from omlish import check
|
|
|
11
11
|
from omlish import lang
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
with lang.auto_proxy_import(globals()):
|
|
15
15
|
import huggingface_hub as hf
|
|
16
16
|
import huggingface_hub.errors # noqa
|
|
17
17
|
import huggingface_hub.utils # noqa
|
|
18
|
-
else:
|
|
19
|
-
hf = lang.proxy_import('huggingface_hub', extras=[
|
|
20
|
-
'errors',
|
|
21
|
-
'utils',
|
|
22
|
-
])
|
|
23
18
|
|
|
24
19
|
|
|
25
20
|
##
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import typing as ta
|
|
5
|
+
|
|
6
|
+
from omdev.cli import CliModule
|
|
7
|
+
from omlish import lang
|
|
8
|
+
from omlish.argparse import all as ap
|
|
9
|
+
from omlish.formats import json
|
|
10
|
+
from omlish.logs import all as logs
|
|
11
|
+
from omlish.term.confirm import confirm_action
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
with lang.auto_proxy_import(globals()):
|
|
15
|
+
import huggingface_hub as hf
|
|
16
|
+
import huggingface_hub.errors # noqa
|
|
17
|
+
import huggingface_hub.utils # noqa
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
log = logs.get_module_logger(globals())
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def fmt_ts(f: float) -> ta.Any:
|
|
27
|
+
dt = datetime.datetime.fromtimestamp(f) # noqa
|
|
28
|
+
return dt.isoformat()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Cli(ap.Cli):
|
|
32
|
+
def _passthrough_args_cmd(
|
|
33
|
+
self,
|
|
34
|
+
exe: str,
|
|
35
|
+
pre_args: ta.Sequence[str] = (),
|
|
36
|
+
post_args: ta.Sequence[str] = (),
|
|
37
|
+
) -> ta.NoReturn:
|
|
38
|
+
os.execvp(
|
|
39
|
+
exe,
|
|
40
|
+
[
|
|
41
|
+
sys.executable,
|
|
42
|
+
*pre_args,
|
|
43
|
+
*self.unknown_args,
|
|
44
|
+
*self.args.args,
|
|
45
|
+
*post_args,
|
|
46
|
+
],
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
@ap.cmd(
|
|
50
|
+
ap.arg('args', nargs=ap.REMAINDER),
|
|
51
|
+
name='cli',
|
|
52
|
+
accepts_unknown=True,
|
|
53
|
+
)
|
|
54
|
+
def cli_cmd(self) -> None:
|
|
55
|
+
self._passthrough_args_cmd(sys.executable, ['-m', 'huggingface_hub.cli.hf'])
|
|
56
|
+
|
|
57
|
+
#
|
|
58
|
+
|
|
59
|
+
@ap.cmd(
|
|
60
|
+
ap.arg('--dir'),
|
|
61
|
+
)
|
|
62
|
+
def scan(self) -> None:
|
|
63
|
+
hf_cache_info = hf.utils.scan_cache_dir(self.args.dir)
|
|
64
|
+
|
|
65
|
+
repo_dcts = [
|
|
66
|
+
{
|
|
67
|
+
'repo_id': repo.repo_id,
|
|
68
|
+
'repo_type': repo.repo_type,
|
|
69
|
+
|
|
70
|
+
'repo_path': str(repo.repo_path),
|
|
71
|
+
|
|
72
|
+
'size_on_disk': repo.size_on_disk,
|
|
73
|
+
'size_on_disk_str': repo.size_on_disk_str,
|
|
74
|
+
|
|
75
|
+
'nb_files': repo.nb_files,
|
|
76
|
+
|
|
77
|
+
'revisions': [
|
|
78
|
+
{
|
|
79
|
+
'commit_hash': rev.commit_hash,
|
|
80
|
+
|
|
81
|
+
'snapshot_path': str(rev.snapshot_path),
|
|
82
|
+
|
|
83
|
+
'size_on_disk': rev.size_on_disk,
|
|
84
|
+
|
|
85
|
+
'files': [
|
|
86
|
+
{
|
|
87
|
+
'file_name': file.file_name,
|
|
88
|
+
'file_path': str(file.file_path),
|
|
89
|
+
'blob_path': str(file.blob_path),
|
|
90
|
+
|
|
91
|
+
'size_on_disk': file.size_on_disk,
|
|
92
|
+
'size_on_disk_str': file.size_on_disk_str,
|
|
93
|
+
|
|
94
|
+
'blob_last_modified': fmt_ts(file.blob_last_modified),
|
|
95
|
+
'blob_last_modified_str': file.blob_last_modified_str,
|
|
96
|
+
'blob_last_accessed': fmt_ts(file.blob_last_accessed),
|
|
97
|
+
'blob_last_accessed_str': file.blob_last_accessed_str,
|
|
98
|
+
}
|
|
99
|
+
for file in sorted(rev.files, key=lambda file: file.blob_last_accessed)
|
|
100
|
+
],
|
|
101
|
+
|
|
102
|
+
'refs': sorted(rev.refs),
|
|
103
|
+
|
|
104
|
+
'last_modified': fmt_ts(rev.last_modified),
|
|
105
|
+
'last_modified_str': rev.last_modified_str,
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
for rev in sorted(repo.revisions, key=lambda rev: rev.last_modified)
|
|
109
|
+
],
|
|
110
|
+
|
|
111
|
+
'last_modified': fmt_ts(repo.last_modified),
|
|
112
|
+
'last_modified_str': repo.last_modified_str,
|
|
113
|
+
'last_accessed': fmt_ts(repo.last_accessed),
|
|
114
|
+
'last_accessed_str': repo.last_accessed_str,
|
|
115
|
+
|
|
116
|
+
'refs': sorted(repo.refs),
|
|
117
|
+
}
|
|
118
|
+
for repo in sorted(hf_cache_info.repos, key=lambda repo: repo.last_accessed)
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
print(json.dumps_pretty(repo_dcts))
|
|
122
|
+
|
|
123
|
+
@ap.cmd(
|
|
124
|
+
ap.arg('--dir'),
|
|
125
|
+
)
|
|
126
|
+
def list(self) -> None:
|
|
127
|
+
hf_cache_info = hf.utils.scan_cache_dir(self.args.dir)
|
|
128
|
+
|
|
129
|
+
repos = [
|
|
130
|
+
repo
|
|
131
|
+
for repo in hf_cache_info.repos
|
|
132
|
+
if repo.repo_type == 'model'
|
|
133
|
+
and repo.nb_files
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
repo_dcts = [
|
|
137
|
+
{
|
|
138
|
+
'repo_id': repo.repo_id,
|
|
139
|
+
'repo_type': repo.repo_type,
|
|
140
|
+
|
|
141
|
+
'repo_path': str(repo.repo_path),
|
|
142
|
+
|
|
143
|
+
'size_on_disk': repo.size_on_disk,
|
|
144
|
+
'size_on_disk_str': repo.size_on_disk_str,
|
|
145
|
+
|
|
146
|
+
'nb_files': repo.nb_files,
|
|
147
|
+
|
|
148
|
+
'last_modified': fmt_ts(repo.last_modified),
|
|
149
|
+
'last_modified_str': repo.last_modified_str,
|
|
150
|
+
'last_accessed': fmt_ts(repo.last_accessed),
|
|
151
|
+
'last_accessed_str': repo.last_accessed_str,
|
|
152
|
+
}
|
|
153
|
+
for repo in sorted(repos, key=lambda repo: repo.last_accessed)
|
|
154
|
+
]
|
|
155
|
+
|
|
156
|
+
print(json.dumps_pretty(repo_dcts))
|
|
157
|
+
|
|
158
|
+
@ap.cmd(
|
|
159
|
+
ap.arg('key', action='append'),
|
|
160
|
+
ap.arg('--dir'),
|
|
161
|
+
ap.arg('--dry-run', action='store_true'),
|
|
162
|
+
ap.arg('--no-confirm', action='store_true'),
|
|
163
|
+
)
|
|
164
|
+
def rm(self) -> None:
|
|
165
|
+
if not self.args.key:
|
|
166
|
+
raise ValueError('key is required')
|
|
167
|
+
|
|
168
|
+
hf_cache_info = hf.utils.scan_cache_dir(self.args.dir)
|
|
169
|
+
|
|
170
|
+
repos_by_id = {repo.repo_id: repo for repo in hf_cache_info.repos}
|
|
171
|
+
repos_by_rev = {rev.commit_hash: repo for repo in hf_cache_info.repos for rev in repo.revisions}
|
|
172
|
+
|
|
173
|
+
rm_revs: dict[str, None] = {}
|
|
174
|
+
|
|
175
|
+
for key in self.args.key:
|
|
176
|
+
if key in repos_by_id:
|
|
177
|
+
rm_revs.update({rev.commit_hash: None for rev in repos_by_id[key].revisions})
|
|
178
|
+
elif key in repos_by_rev:
|
|
179
|
+
rm_revs.update({key: None})
|
|
180
|
+
else:
|
|
181
|
+
raise ValueError(f'key {key} not found')
|
|
182
|
+
|
|
183
|
+
for rm_rev in rm_revs:
|
|
184
|
+
rm_repo = repos_by_rev[rm_rev]
|
|
185
|
+
|
|
186
|
+
if not self.args.no_confirm:
|
|
187
|
+
if not confirm_action(f'Delete {rm_repo.repo_id}@{rm_rev}?'):
|
|
188
|
+
return
|
|
189
|
+
|
|
190
|
+
if not self.args.dry_run:
|
|
191
|
+
strategy = hf_cache_info.delete_revisions(rm_rev)
|
|
192
|
+
strategy.execute()
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
##
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def _main() -> None:
|
|
199
|
+
logs.configure_standard_logging('INFO')
|
|
200
|
+
Cli()()
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
# @omlish-manifest
|
|
204
|
+
_CLI_MODULE = CliModule('hf', __name__)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
if __name__ == '__main__':
|
|
208
|
+
_main()
|