fmtr.tools 1.3.37__py3-none-any.whl → 1.3.38__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.
Potentially problematic release.
This version of fmtr.tools might be problematic. Click here for more details.
- fmtr/tools/ai_tools/agentic_tools.py +2 -3
- fmtr/tools/iterator_tools.py +12 -0
- fmtr/tools/string_tools.py +60 -6
- fmtr/tools/version +1 -1
- {fmtr_tools-1.3.37.dist-info → fmtr_tools-1.3.38.dist-info}/METADATA +44 -44
- {fmtr_tools-1.3.37.dist-info → fmtr_tools-1.3.38.dist-info}/RECORD +10 -10
- {fmtr_tools-1.3.37.dist-info → fmtr_tools-1.3.38.dist-info}/WHEEL +0 -0
- {fmtr_tools-1.3.37.dist-info → fmtr_tools-1.3.38.dist-info}/entry_points.txt +0 -0
- {fmtr_tools-1.3.37.dist-info → fmtr_tools-1.3.38.dist-info}/licenses/LICENSE +0 -0
- {fmtr_tools-1.3.37.dist-info → fmtr_tools-1.3.38.dist-info}/top_level.txt +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
from typing import List, Optional, Any, Annotated
|
|
2
|
-
|
|
3
1
|
import pydantic_ai
|
|
4
2
|
from pydantic import PlainValidator
|
|
5
3
|
from pydantic_ai import RunContext, ModelRetry
|
|
6
4
|
from pydantic_ai.agent import AgentRunResult, Agent
|
|
7
5
|
from pydantic_ai.models.openai import OpenAIModel
|
|
8
6
|
from pydantic_ai.providers.openai import OpenAIProvider
|
|
7
|
+
from typing import List, Optional, Any, Annotated
|
|
9
8
|
|
|
10
9
|
from fmtr.tools import environment_tools as env
|
|
11
10
|
from fmtr.tools.constants import Constants
|
|
@@ -153,7 +152,7 @@ def default_prompt_none_specified(text):
|
|
|
153
152
|
return text
|
|
154
153
|
|
|
155
154
|
|
|
156
|
-
StringDefaultNoneSpecified = Annotated[str, PlainValidator(default_prompt_none_specified)]
|
|
155
|
+
StringDefaultNoneSpecified = Annotated[Optional[str], PlainValidator(default_prompt_none_specified)]
|
|
157
156
|
|
|
158
157
|
|
|
159
158
|
if __name__ == '__main__':
|
fmtr/tools/iterator_tools.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
from itertools import chain, batched
|
|
2
|
+
|
|
2
3
|
from typing import List, Dict, Any
|
|
3
4
|
|
|
5
|
+
from fmtr.tools.datatype_tools import is_none
|
|
6
|
+
|
|
4
7
|
|
|
5
8
|
def enlist(value) -> List[Any]:
|
|
6
9
|
"""
|
|
@@ -52,3 +55,12 @@ def rebatch(batches, size: int):
|
|
|
52
55
|
|
|
53
56
|
"""
|
|
54
57
|
return batched(chain.from_iterable(batches), size)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def strip_none(*items):
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
Remove nones from a list of arguments
|
|
64
|
+
|
|
65
|
+
"""
|
|
66
|
+
return [item for item in items if not is_none(item)]
|
fmtr/tools/string_tools.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from collections import namedtuple
|
|
2
|
+
from string import Formatter
|
|
2
3
|
|
|
3
4
|
import re
|
|
4
|
-
from
|
|
5
|
+
from dataclasses import dataclass
|
|
5
6
|
from textwrap import dedent
|
|
6
7
|
from typing import List
|
|
7
8
|
|
|
@@ -84,17 +85,70 @@ def sanitize(*strings, sep: str = '-') -> str:
|
|
|
84
85
|
return string
|
|
85
86
|
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
@dataclass
|
|
89
|
+
class Truncation:
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
Result type for truncation functions
|
|
93
|
+
|
|
94
|
+
"""
|
|
95
|
+
text: str
|
|
96
|
+
text_without_sep: str | None
|
|
97
|
+
original: str
|
|
98
|
+
remainder: str | None
|
|
99
|
+
sep: str
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def truncate(text, length=None, sep=ELLIPSIS, return_type=str):
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
Truncate a string to length characters
|
|
106
|
+
|
|
88
107
|
"""
|
|
108
|
+
text = flatten(text)
|
|
109
|
+
if len(text) <= length or not length:
|
|
110
|
+
return text if return_type is str else Truncation(text, text, text, None, sep)
|
|
111
|
+
|
|
112
|
+
cutoff = length - len(sep)
|
|
113
|
+
truncated = text[:cutoff] + sep
|
|
114
|
+
|
|
115
|
+
if return_type is str:
|
|
116
|
+
return truncated
|
|
117
|
+
else:
|
|
118
|
+
return Truncation(
|
|
119
|
+
text=truncated,
|
|
120
|
+
text_without_sep=text[:cutoff],
|
|
121
|
+
original=text,
|
|
122
|
+
remainder=text[cutoff:] or None,
|
|
123
|
+
sep=sep
|
|
124
|
+
)
|
|
89
125
|
|
|
90
|
-
|
|
126
|
+
|
|
127
|
+
def truncate_mid(text, length=None, sep=ELLIPSIS, return_type=str):
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
Truncate a string to `length` characters in the middle.
|
|
91
131
|
|
|
92
132
|
"""
|
|
93
133
|
text = flatten(text)
|
|
94
134
|
if len(text) <= length or not length:
|
|
95
|
-
return text
|
|
96
|
-
|
|
97
|
-
|
|
135
|
+
return text if return_type is str else Truncation(text, text, text, '', sep)
|
|
136
|
+
|
|
137
|
+
half = (length - len(sep)) // 2
|
|
138
|
+
left = text[:half]
|
|
139
|
+
right = text[-half:]
|
|
140
|
+
truncated = left + sep + right
|
|
141
|
+
|
|
142
|
+
if return_type is str:
|
|
143
|
+
return truncated
|
|
144
|
+
else:
|
|
145
|
+
return Truncation(
|
|
146
|
+
text=truncated,
|
|
147
|
+
text_without_sep=None,
|
|
148
|
+
original=text,
|
|
149
|
+
remainder=None,
|
|
150
|
+
sep=sep
|
|
151
|
+
)
|
|
98
152
|
|
|
99
153
|
|
|
100
154
|
def flatten(raw):
|
fmtr/tools/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.3.
|
|
1
|
+
1.3.38
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fmtr.tools
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.38
|
|
4
4
|
Summary: Collection of high-level tools to simplify everyday development tasks, with a focus on AI/ML
|
|
5
5
|
Home-page: https://github.com/fmtr/fmtr.tools
|
|
6
6
|
Author: Frontmatter
|
|
@@ -133,62 +133,62 @@ Requires-Dist: logfire[httpx]; extra == "webhook"
|
|
|
133
133
|
Provides-Extra: browsers
|
|
134
134
|
Requires-Dist: playwright; extra == "browsers"
|
|
135
135
|
Provides-Extra: all
|
|
136
|
-
Requires-Dist: ollama; extra == "all"
|
|
137
|
-
Requires-Dist: appdirs; extra == "all"
|
|
138
136
|
Requires-Dist: flet-video; extra == "all"
|
|
137
|
+
Requires-Dist: google-auth; extra == "all"
|
|
139
138
|
Requires-Dist: logfire[httpx]; extra == "all"
|
|
140
|
-
Requires-Dist:
|
|
141
|
-
Requires-Dist:
|
|
142
|
-
Requires-Dist:
|
|
143
|
-
Requires-Dist: tinynetrc; extra == "all"
|
|
144
|
-
Requires-Dist: diskcache; extra == "all"
|
|
145
|
-
Requires-Dist: docker; extra == "all"
|
|
146
|
-
Requires-Dist: pymupdf; extra == "all"
|
|
147
|
-
Requires-Dist: httpx_retries; extra == "all"
|
|
139
|
+
Requires-Dist: pymupdf4llm; extra == "all"
|
|
140
|
+
Requires-Dist: deepmerge; extra == "all"
|
|
141
|
+
Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
|
|
148
142
|
Requires-Dist: Unidecode; extra == "all"
|
|
149
|
-
Requires-Dist: fastapi; extra == "all"
|
|
150
143
|
Requires-Dist: semver; extra == "all"
|
|
144
|
+
Requires-Dist: diskcache; extra == "all"
|
|
151
145
|
Requires-Dist: pandas; extra == "all"
|
|
152
|
-
Requires-Dist: distributed; extra == "all"
|
|
153
|
-
Requires-Dist: uvicorn[standard]; extra == "all"
|
|
154
|
-
Requires-Dist: openai; extra == "all"
|
|
155
|
-
Requires-Dist: contexttimer; extra == "all"
|
|
156
|
-
Requires-Dist: logfire; extra == "all"
|
|
157
|
-
Requires-Dist: pydantic-settings; extra == "all"
|
|
158
|
-
Requires-Dist: torchvision; extra == "all"
|
|
159
|
-
Requires-Dist: torchaudio; extra == "all"
|
|
160
|
-
Requires-Dist: json_repair; extra == "all"
|
|
161
|
-
Requires-Dist: pymupdf4llm; extra == "all"
|
|
162
|
-
Requires-Dist: httpx; extra == "all"
|
|
163
|
-
Requires-Dist: tokenizers; extra == "all"
|
|
164
146
|
Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
|
|
147
|
+
Requires-Dist: ollama; extra == "all"
|
|
148
|
+
Requires-Dist: peft; extra == "all"
|
|
149
|
+
Requires-Dist: playwright; extra == "all"
|
|
150
|
+
Requires-Dist: html2text; extra == "all"
|
|
151
|
+
Requires-Dist: sentence_transformers; extra == "all"
|
|
152
|
+
Requires-Dist: pydantic; extra == "all"
|
|
153
|
+
Requires-Dist: sre_yield; extra == "all"
|
|
154
|
+
Requires-Dist: tabulate; extra == "all"
|
|
155
|
+
Requires-Dist: appdirs; extra == "all"
|
|
156
|
+
Requires-Dist: bokeh; extra == "all"
|
|
157
|
+
Requires-Dist: dnspython[doh]; extra == "all"
|
|
158
|
+
Requires-Dist: yamlscript; extra == "all"
|
|
165
159
|
Requires-Dist: logfire[fastapi]; extra == "all"
|
|
166
|
-
Requires-Dist:
|
|
160
|
+
Requires-Dist: regex; extra == "all"
|
|
161
|
+
Requires-Dist: fastapi; extra == "all"
|
|
162
|
+
Requires-Dist: torchaudio; extra == "all"
|
|
167
163
|
Requires-Dist: pytest-cov; extra == "all"
|
|
168
|
-
Requires-Dist: faker; extra == "all"
|
|
169
|
-
Requires-Dist: google-auth; extra == "all"
|
|
170
|
-
Requires-Dist: google-api-python-client; extra == "all"
|
|
171
|
-
Requires-Dist: sre_yield; extra == "all"
|
|
172
164
|
Requires-Dist: flet[all]; extra == "all"
|
|
173
|
-
Requires-Dist:
|
|
165
|
+
Requires-Dist: google-auth-oauthlib; extra == "all"
|
|
166
|
+
Requires-Dist: pymupdf; extra == "all"
|
|
167
|
+
Requires-Dist: torchvision; extra == "all"
|
|
168
|
+
Requires-Dist: google-api-python-client; extra == "all"
|
|
169
|
+
Requires-Dist: uvicorn[standard]; extra == "all"
|
|
170
|
+
Requires-Dist: tokenizers; extra == "all"
|
|
171
|
+
Requires-Dist: logfire; extra == "all"
|
|
172
|
+
Requires-Dist: cachetools; extra == "all"
|
|
173
|
+
Requires-Dist: distributed; extra == "all"
|
|
174
|
+
Requires-Dist: openpyxl; extra == "all"
|
|
175
|
+
Requires-Dist: setuptools; extra == "all"
|
|
174
176
|
Requires-Dist: huggingface_hub; extra == "all"
|
|
175
|
-
Requires-Dist: pydantic; extra == "all"
|
|
176
|
-
Requires-Dist:
|
|
177
|
-
Requires-Dist:
|
|
178
|
-
Requires-Dist:
|
|
179
|
-
Requires-Dist: transformers[sentencepiece]; extra == "all"
|
|
180
|
-
Requires-Dist: regex; extra == "all"
|
|
181
|
-
Requires-Dist: playwright; extra == "all"
|
|
177
|
+
Requires-Dist: pydantic-settings; extra == "all"
|
|
178
|
+
Requires-Dist: httpx; extra == "all"
|
|
179
|
+
Requires-Dist: json_repair; extra == "all"
|
|
180
|
+
Requires-Dist: httpx_retries; extra == "all"
|
|
182
181
|
Requires-Dist: filetype; extra == "all"
|
|
183
|
-
Requires-Dist:
|
|
184
|
-
Requires-Dist:
|
|
185
|
-
Requires-Dist:
|
|
182
|
+
Requires-Dist: faker; extra == "all"
|
|
183
|
+
Requires-Dist: docker; extra == "all"
|
|
184
|
+
Requires-Dist: contexttimer; extra == "all"
|
|
185
|
+
Requires-Dist: google-auth-httplib2; extra == "all"
|
|
186
|
+
Requires-Dist: openai; extra == "all"
|
|
187
|
+
Requires-Dist: transformers[sentencepiece]; extra == "all"
|
|
186
188
|
Requires-Dist: dask[bag]; extra == "all"
|
|
189
|
+
Requires-Dist: flet-webview; extra == "all"
|
|
190
|
+
Requires-Dist: tinynetrc; extra == "all"
|
|
187
191
|
Requires-Dist: pyyaml; extra == "all"
|
|
188
|
-
Requires-Dist: sentence_transformers; extra == "all"
|
|
189
|
-
Requires-Dist: peft; extra == "all"
|
|
190
|
-
Requires-Dist: google-auth-httplib2; extra == "all"
|
|
191
|
-
Requires-Dist: setuptools; extra == "all"
|
|
192
192
|
Dynamic: author
|
|
193
193
|
Dynamic: author-email
|
|
194
194
|
Dynamic: description
|
|
@@ -20,7 +20,7 @@ fmtr/tools/http_tools.py,sha256=RVwGrBNMyjfbpgAPCSnxEkXfSzXXWARb3ayq981ONQE,464
|
|
|
20
20
|
fmtr/tools/import_tools.py,sha256=XJmiWLukRncJAcaGReDn4jIz1_IpVBjfYCQHH1hIg7c,588
|
|
21
21
|
fmtr/tools/inherit_tools.py,sha256=gTGL4mRm5RsbFW76s25AbuAJ2vlymbh1c8Q4Hl2uJGU,646
|
|
22
22
|
fmtr/tools/inspection_tools.py,sha256=tLTRvzy9XVomQPi0dfnF_cgwc7KiDVZAr7gPTk4S_bQ,278
|
|
23
|
-
fmtr/tools/iterator_tools.py,sha256=
|
|
23
|
+
fmtr/tools/iterator_tools.py,sha256=ysNT2h39_ukEGrj8k7Z_CLKjWoguKBqVdjj4PLe7faE,1502
|
|
24
24
|
fmtr/tools/json_fix_tools.py,sha256=vNSlswVQnujPmKEqDjFJcO901mjMyv59q3awsT7mlhs,477
|
|
25
25
|
fmtr/tools/json_tools.py,sha256=WkFc5q7oqMtcFejhN1K5zQFULa9TdLOup83Fr0saDRY,348
|
|
26
26
|
fmtr/tools/logging_tools.py,sha256=M7I5igs_tX5SIRv4f-jfb75LOODclSdmEg5ziAAMSPE,2503
|
|
@@ -40,16 +40,16 @@ fmtr/tools/random_tools.py,sha256=4VlQdk5THbR8ka4pZaLbk_ZO_4yy6PF_lHZes_rgenY,22
|
|
|
40
40
|
fmtr/tools/semantic_tools.py,sha256=cxY9NSAHWj4nEc6Oj4qA1omR3dWbl2OuH7_PkINc6_E,1386
|
|
41
41
|
fmtr/tools/settings_tools.py,sha256=o11W3T60UZSvCTkh_eEQq1Mx74GycQ6JxUr0plBDbsk,2356
|
|
42
42
|
fmtr/tools/spaces_tools.py,sha256=D_he3mve6DruB3OPS6QyzqD05ChHnRTb4buViKPe7To,1099
|
|
43
|
-
fmtr/tools/string_tools.py,sha256=
|
|
43
|
+
fmtr/tools/string_tools.py,sha256=On6YRLTAK1i6mmMpOUWVM618CykJiuaoyKIsU1cB_mA,4952
|
|
44
44
|
fmtr/tools/tabular_tools.py,sha256=tpIpZzYku1HcJrHZJL6BC39LmN3WUWVhFbK2N7nDVmE,120
|
|
45
45
|
fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
|
|
46
46
|
fmtr/tools/tools.py,sha256=CAsApa1YwVdNE6H66Vjivs_mXYvOas3rh7fPELAnTpk,795
|
|
47
47
|
fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
|
|
48
|
-
fmtr/tools/version,sha256=
|
|
48
|
+
fmtr/tools/version,sha256=CUhoLtYuOkZkXro_emKCgxROYC4p3ceZxrtbyGlGwQw,6
|
|
49
49
|
fmtr/tools/webhook_tools.py,sha256=q3pVJ1NCem2SrMuFcLxiWd7DibFs7Q-uGtojfXd3Qcg,380
|
|
50
50
|
fmtr/tools/yaml_tools.py,sha256=Bhhyd6GQVKO72Lp8ky7bAUjIB_65Hdh0Q45SKIEe6S8,1901
|
|
51
51
|
fmtr/tools/ai_tools/__init__.py,sha256=JZrLuOFNV1A3wvJgonxOgz_4WS-7MfCuowGWA5uYCjs,372
|
|
52
|
-
fmtr/tools/ai_tools/agentic_tools.py,sha256
|
|
52
|
+
fmtr/tools/ai_tools/agentic_tools.py,sha256=-6q9Cp8WUbLu9AmS5SI5R8qtWMp1Ky4rFXMtfLvcQ7A,4791
|
|
53
53
|
fmtr/tools/ai_tools/inference_tools.py,sha256=2UP2gXEyOJUjyyV6zmFIYmIxUsh1rXkRH0IbFvr2bRs,11908
|
|
54
54
|
fmtr/tools/dns_tools/__init__.py,sha256=Mzaepy8lEdT0SJtUOCnF3IkpOt0vrZn-IOgOf4xfd8Q,258
|
|
55
55
|
fmtr/tools/dns_tools/client.py,sha256=IBbd7Xgx9ExTn_EPoL7ts9JfXokHHuOiD9m4K6tl1Q0,2817
|
|
@@ -81,9 +81,9 @@ fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g
|
|
|
81
81
|
fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
|
|
82
82
|
fmtr/tools/version_tools/__init__.py,sha256=pg4iLtmIr5HtyEW_j0fMFoIdzqi_w9xH8-grQaXLB28,318
|
|
83
83
|
fmtr/tools/version_tools/version_tools.py,sha256=Hcc6yferZS1hHbugRTdiHhSNmXEEG0hjCiTTXKna-YY,1127
|
|
84
|
-
fmtr_tools-1.3.
|
|
85
|
-
fmtr_tools-1.3.
|
|
86
|
-
fmtr_tools-1.3.
|
|
87
|
-
fmtr_tools-1.3.
|
|
88
|
-
fmtr_tools-1.3.
|
|
89
|
-
fmtr_tools-1.3.
|
|
84
|
+
fmtr_tools-1.3.38.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
|
|
85
|
+
fmtr_tools-1.3.38.dist-info/METADATA,sha256=fNG_O_TGAtpbSYUjS7nn5eGE150AOSNECmadWbN73Gs,16259
|
|
86
|
+
fmtr_tools-1.3.38.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
87
|
+
fmtr_tools-1.3.38.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
|
|
88
|
+
fmtr_tools-1.3.38.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
|
|
89
|
+
fmtr_tools-1.3.38.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|