ommlds 0.0.0.dev479__py3-none-any.whl → 0.0.0.dev481__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 +40 -23
- ommlds/__about__.py +1 -1
- ommlds/backends/llamacpp/logging.py +4 -1
- ommlds/backends/mlx/caching.py +7 -3
- ommlds/backends/mlx/cli.py +10 -7
- ommlds/backends/mlx/generation.py +18 -16
- ommlds/backends/mlx/limits.py +10 -6
- ommlds/backends/mlx/loading.py +7 -4
- ommlds/backends/tavily/__init__.py +0 -0
- ommlds/backends/tavily/protocol.py +301 -0
- ommlds/backends/transformers/__init__.py +14 -0
- ommlds/minichain/__init__.py +1 -0
- ommlds/minichain/_dataclasses.py +46282 -0
- ommlds/minichain/backends/impls/anthropic/chat.py +23 -4
- ommlds/minichain/backends/impls/duckduckgo/search.py +5 -1
- ommlds/minichain/backends/impls/huggingface/repos.py +1 -5
- ommlds/minichain/backends/impls/llamacpp/chat.py +6 -3
- ommlds/minichain/backends/impls/llamacpp/completion.py +7 -3
- ommlds/minichain/backends/impls/llamacpp/stream.py +6 -3
- ommlds/minichain/backends/impls/mlx/chat.py +6 -3
- ommlds/minichain/backends/impls/openai/format.py +2 -0
- ommlds/minichain/backends/impls/openai/names.py +3 -1
- ommlds/minichain/backends/impls/sentencepiece/tokens.py +9 -6
- ommlds/minichain/backends/impls/tavily.py +66 -0
- ommlds/minichain/backends/impls/tinygrad/chat.py +7 -4
- ommlds/minichain/backends/impls/tokenizers/tokens.py +9 -6
- ommlds/minichain/backends/impls/transformers/sentence.py +5 -2
- ommlds/minichain/backends/impls/transformers/tokens.py +9 -6
- ommlds/minichain/backends/impls/transformers/transformers.py +10 -8
- ommlds/minichain/llms/types.py +4 -0
- ommlds/minichain/search.py +1 -1
- ommlds/minichain/standard.py +1 -0
- ommlds/specs/__init__.py +0 -0
- ommlds/specs/mcp/__init__.py +0 -0
- ommlds/specs/mcp/_marshal.py +23 -0
- ommlds/specs/mcp/clients.py +146 -0
- ommlds/specs/mcp/protocol.py +371 -0
- {ommlds-0.0.0.dev479.dist-info → ommlds-0.0.0.dev481.dist-info}/METADATA +5 -5
- {ommlds-0.0.0.dev479.dist-info → ommlds-0.0.0.dev481.dist-info}/RECORD +43 -34
- {ommlds-0.0.0.dev479.dist-info → ommlds-0.0.0.dev481.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev479.dist-info → ommlds-0.0.0.dev481.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev479.dist-info → ommlds-0.0.0.dev481.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev479.dist-info → ommlds-0.0.0.dev481.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"""
|
|
2
|
+
https://docs.tavily.com/documentation/api-reference/endpoint/search
|
|
3
|
+
"""
|
|
4
|
+
import typing as ta
|
|
5
|
+
|
|
6
|
+
from omlish import dataclasses as dc
|
|
7
|
+
from omlish import lang
|
|
8
|
+
from omlish import marshal as msh
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _set_class_marshal_options(cls):
|
|
15
|
+
msh.update_object_metadata(
|
|
16
|
+
cls,
|
|
17
|
+
field_defaults=msh.FieldMetadata(
|
|
18
|
+
options=msh.FieldOptions(
|
|
19
|
+
omit_if=lang.is_none,
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
return cls
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
KNOWN_COUNTRIES = frozenset([
|
|
31
|
+
'afghanistan',
|
|
32
|
+
'albania',
|
|
33
|
+
'algeria',
|
|
34
|
+
'andorra',
|
|
35
|
+
'angola',
|
|
36
|
+
'argentina',
|
|
37
|
+
'armenia',
|
|
38
|
+
'australia',
|
|
39
|
+
'austria',
|
|
40
|
+
'azerbaijan',
|
|
41
|
+
'bahamas',
|
|
42
|
+
'bahrain',
|
|
43
|
+
'bangladesh',
|
|
44
|
+
'barbados',
|
|
45
|
+
'belarus',
|
|
46
|
+
'belgium',
|
|
47
|
+
'belize',
|
|
48
|
+
'benin',
|
|
49
|
+
'bhutan',
|
|
50
|
+
'bolivia',
|
|
51
|
+
'bosnia and herzegovina',
|
|
52
|
+
'botswana',
|
|
53
|
+
'brazil',
|
|
54
|
+
'brunei',
|
|
55
|
+
'bulgaria',
|
|
56
|
+
'burkina faso',
|
|
57
|
+
'burundi',
|
|
58
|
+
'cambodia',
|
|
59
|
+
'cameroon',
|
|
60
|
+
'canada',
|
|
61
|
+
'cape verde',
|
|
62
|
+
'central african republic',
|
|
63
|
+
'chad',
|
|
64
|
+
'chile',
|
|
65
|
+
'china',
|
|
66
|
+
'colombia',
|
|
67
|
+
'comoros',
|
|
68
|
+
'congo',
|
|
69
|
+
'costa rica',
|
|
70
|
+
'croatia',
|
|
71
|
+
'cuba',
|
|
72
|
+
'cyprus',
|
|
73
|
+
'czech republic',
|
|
74
|
+
'denmark',
|
|
75
|
+
'djibouti',
|
|
76
|
+
'dominican republic',
|
|
77
|
+
'ecuador',
|
|
78
|
+
'egypt',
|
|
79
|
+
'el salvador',
|
|
80
|
+
'equatorial guinea',
|
|
81
|
+
'eritrea',
|
|
82
|
+
'estonia',
|
|
83
|
+
'ethiopia',
|
|
84
|
+
'fiji',
|
|
85
|
+
'finland',
|
|
86
|
+
'france',
|
|
87
|
+
'gabon',
|
|
88
|
+
'gambia',
|
|
89
|
+
'georgia',
|
|
90
|
+
'germany',
|
|
91
|
+
'ghana',
|
|
92
|
+
'greece',
|
|
93
|
+
'guatemala',
|
|
94
|
+
'guinea',
|
|
95
|
+
'haiti',
|
|
96
|
+
'honduras',
|
|
97
|
+
'hungary',
|
|
98
|
+
'iceland',
|
|
99
|
+
'india',
|
|
100
|
+
'indonesia',
|
|
101
|
+
'iran',
|
|
102
|
+
'iraq',
|
|
103
|
+
'ireland',
|
|
104
|
+
'israel',
|
|
105
|
+
'italy',
|
|
106
|
+
'jamaica',
|
|
107
|
+
'japan',
|
|
108
|
+
'jordan',
|
|
109
|
+
'kazakhstan',
|
|
110
|
+
'kenya',
|
|
111
|
+
'kuwait',
|
|
112
|
+
'kyrgyzstan',
|
|
113
|
+
'latvia',
|
|
114
|
+
'lebanon',
|
|
115
|
+
'lesotho',
|
|
116
|
+
'liberia',
|
|
117
|
+
'libya',
|
|
118
|
+
'liechtenstein',
|
|
119
|
+
'lithuania',
|
|
120
|
+
'luxembourg',
|
|
121
|
+
'madagascar',
|
|
122
|
+
'malawi',
|
|
123
|
+
'malaysia',
|
|
124
|
+
'maldives',
|
|
125
|
+
'mali',
|
|
126
|
+
'malta',
|
|
127
|
+
'mauritania',
|
|
128
|
+
'mauritius',
|
|
129
|
+
'mexico',
|
|
130
|
+
'moldova',
|
|
131
|
+
'monaco',
|
|
132
|
+
'mongolia',
|
|
133
|
+
'montenegro',
|
|
134
|
+
'morocco',
|
|
135
|
+
'mozambique',
|
|
136
|
+
'myanmar',
|
|
137
|
+
'namibia',
|
|
138
|
+
'nepal',
|
|
139
|
+
'netherlands',
|
|
140
|
+
'new zealand',
|
|
141
|
+
'nicaragua',
|
|
142
|
+
'niger',
|
|
143
|
+
'nigeria',
|
|
144
|
+
'north korea',
|
|
145
|
+
'north macedonia',
|
|
146
|
+
'norway',
|
|
147
|
+
'oman',
|
|
148
|
+
'pakistan',
|
|
149
|
+
'panama',
|
|
150
|
+
'papua new guinea',
|
|
151
|
+
'paraguay',
|
|
152
|
+
'peru',
|
|
153
|
+
'philippines',
|
|
154
|
+
'poland',
|
|
155
|
+
'portugal',
|
|
156
|
+
'qatar',
|
|
157
|
+
'romania',
|
|
158
|
+
'russia',
|
|
159
|
+
'rwanda',
|
|
160
|
+
'saudi arabia',
|
|
161
|
+
'senegal',
|
|
162
|
+
'serbia',
|
|
163
|
+
'singapore',
|
|
164
|
+
'slovakia',
|
|
165
|
+
'slovenia',
|
|
166
|
+
'somalia',
|
|
167
|
+
'south africa',
|
|
168
|
+
'south korea',
|
|
169
|
+
'south sudan',
|
|
170
|
+
'spain',
|
|
171
|
+
'sri lanka',
|
|
172
|
+
'sudan',
|
|
173
|
+
'sweden',
|
|
174
|
+
'switzerland',
|
|
175
|
+
'syria',
|
|
176
|
+
'taiwan',
|
|
177
|
+
'tajikistan',
|
|
178
|
+
'tanzania',
|
|
179
|
+
'thailand',
|
|
180
|
+
'togo',
|
|
181
|
+
'trinidad and tobago',
|
|
182
|
+
'tunisia',
|
|
183
|
+
'turkey',
|
|
184
|
+
'turkmenistan',
|
|
185
|
+
'uganda',
|
|
186
|
+
'ukraine',
|
|
187
|
+
'united arab emirates',
|
|
188
|
+
'united kingdom',
|
|
189
|
+
'united states',
|
|
190
|
+
'uruguay',
|
|
191
|
+
'uzbekistan',
|
|
192
|
+
'venezuela',
|
|
193
|
+
'vietnam',
|
|
194
|
+
'yemen',
|
|
195
|
+
'zambia',
|
|
196
|
+
'zimbabwe',
|
|
197
|
+
])
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
##
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
204
|
+
@_set_class_marshal_options
|
|
205
|
+
class SearchRequest:
|
|
206
|
+
query: str
|
|
207
|
+
|
|
208
|
+
# optional
|
|
209
|
+
auto_parameters: bool | None = None
|
|
210
|
+
|
|
211
|
+
topic: ta.Literal['general', 'news', 'finance'] | None = None
|
|
212
|
+
search_depth: ta.Literal['basic', 'advanced'] | None = None
|
|
213
|
+
|
|
214
|
+
chunks_per_source: int | None = None
|
|
215
|
+
max_results: int | None = None
|
|
216
|
+
|
|
217
|
+
time_range: ta.Literal['day', 'week', 'month', 'year', 'd', 'w', 'm', 'y'] | None = None
|
|
218
|
+
start_date: str | None = None # YYYY-MM-DD
|
|
219
|
+
end_date: str | None = None # YYYY-MM-DD
|
|
220
|
+
|
|
221
|
+
# Booleans with extra enum-like modes per docs
|
|
222
|
+
include_answer: bool | ta.Literal['basic', 'advanced'] | None = None
|
|
223
|
+
include_raw_content: bool | ta.Literal['markdown', 'text'] | None = None
|
|
224
|
+
|
|
225
|
+
include_images: bool | None = None
|
|
226
|
+
include_image_descriptions: bool | None = None
|
|
227
|
+
include_favicon: bool | None = None
|
|
228
|
+
|
|
229
|
+
include_domains: ta.Sequence[str] | None = None
|
|
230
|
+
exclude_domains: ta.Sequence[str] | None = None
|
|
231
|
+
|
|
232
|
+
country: str | None = None
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
236
|
+
@_set_class_marshal_options
|
|
237
|
+
class SearchResponse:
|
|
238
|
+
query: str
|
|
239
|
+
answer: str
|
|
240
|
+
|
|
241
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
242
|
+
@_set_class_marshal_options
|
|
243
|
+
class Image:
|
|
244
|
+
url: str | None = None
|
|
245
|
+
description: str | None = None
|
|
246
|
+
|
|
247
|
+
images: ta.Sequence[Image] | None = None
|
|
248
|
+
|
|
249
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
250
|
+
@_set_class_marshal_options
|
|
251
|
+
class Result:
|
|
252
|
+
title: str | None = None
|
|
253
|
+
url: str | None = None
|
|
254
|
+
content: str | None = None
|
|
255
|
+
score: float | None = None
|
|
256
|
+
raw_content: str | None = None
|
|
257
|
+
favicon: str | None = None
|
|
258
|
+
|
|
259
|
+
results: ta.Sequence[Result] | None = None
|
|
260
|
+
|
|
261
|
+
follow_up_questions: ta.Sequence[str] | None = None
|
|
262
|
+
|
|
263
|
+
auto_parameters: ta.Mapping[str, ta.Any] | None = None
|
|
264
|
+
|
|
265
|
+
response_time: str | None = None # seconds
|
|
266
|
+
request_id: str | None = None
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
##
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
273
|
+
class ExtractRequest:
|
|
274
|
+
urls: str | ta.Sequence[str]
|
|
275
|
+
include_images: bool | None = None
|
|
276
|
+
include_favicon: bool | None = None
|
|
277
|
+
extract_depth: ta.Literal['basic', 'advanced'] | None = None
|
|
278
|
+
format: ta.Literal['markdown', 'text'] | None = None
|
|
279
|
+
timeout: str | None = None # seconds
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
283
|
+
class ExtractResponse:
|
|
284
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
285
|
+
class Result:
|
|
286
|
+
url: str
|
|
287
|
+
raw_content: str
|
|
288
|
+
images: ta.Sequence[str] | None = None
|
|
289
|
+
favicon: str | None = None
|
|
290
|
+
|
|
291
|
+
results: ta.Sequence[Result]
|
|
292
|
+
|
|
293
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
294
|
+
class FailedResult:
|
|
295
|
+
url: str
|
|
296
|
+
error: str
|
|
297
|
+
|
|
298
|
+
failed_results: ta.Sequence[FailedResult] | None = None
|
|
299
|
+
|
|
300
|
+
response_time: str | None = None
|
|
301
|
+
request_id: str | None = None
|