fmtr.tools 1.1.2__py3-none-any.whl → 1.1.4__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 +50 -23
- fmtr/tools/api_tools.py +1 -0
- fmtr/tools/version +1 -1
- {fmtr_tools-1.1.2.dist-info → fmtr_tools-1.1.4.dist-info}/METADATA +40 -38
- {fmtr_tools-1.1.2.dist-info → fmtr_tools-1.1.4.dist-info}/RECORD +9 -9
- {fmtr_tools-1.1.2.dist-info → fmtr_tools-1.1.4.dist-info}/WHEEL +1 -1
- {fmtr_tools-1.1.2.dist-info → fmtr_tools-1.1.4.dist-info}/entry_points.txt +0 -0
- {fmtr_tools-1.1.2.dist-info → fmtr_tools-1.1.4.dist-info}/licenses/LICENSE +0 -0
- {fmtr_tools-1.1.2.dist-info → fmtr_tools-1.1.4.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import pydantic_ai
|
|
2
2
|
from pydantic_ai import RunContext
|
|
3
3
|
from pydantic_ai.agent import AgentRunResult, Agent
|
|
4
|
-
from pydantic_ai.messages import ModelRequest, RetryPromptPart
|
|
5
4
|
from pydantic_ai.models.openai import OpenAIModel
|
|
6
5
|
from pydantic_ai.providers.openai import OpenAIProvider
|
|
6
|
+
from typing import List, Optional
|
|
7
7
|
|
|
8
8
|
from fmtr.tools import environment_tools as env
|
|
9
9
|
from fmtr.tools.constants import Constants
|
|
@@ -25,7 +25,7 @@ class Task:
|
|
|
25
25
|
|
|
26
26
|
MODEL_ID = 'gpt-4o'
|
|
27
27
|
MODEL_ID_FMTR = 'qwen2.5-coder:14b'
|
|
28
|
-
|
|
28
|
+
SYSTEM_PROMPT_STATIC = None
|
|
29
29
|
DEPS_TYPE = str
|
|
30
30
|
RESULT_TYPE = str
|
|
31
31
|
RESULT_RETRIES = 5
|
|
@@ -41,7 +41,7 @@ class Task:
|
|
|
41
41
|
self.agent = Agent(
|
|
42
42
|
*args,
|
|
43
43
|
model=self.model,
|
|
44
|
-
system_prompt=self.
|
|
44
|
+
system_prompt=self.SYSTEM_PROMPT_STATIC or [],
|
|
45
45
|
deps_type=self.DEPS_TYPE,
|
|
46
46
|
result_type=self.RESULT_TYPE,
|
|
47
47
|
result_retries=self.RESULT_RETRIES,
|
|
@@ -49,58 +49,85 @@ class Task:
|
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
self.agent.output_validator(self.validate)
|
|
52
|
+
self.agent.system_prompt(self.add_system_prompt)
|
|
52
53
|
self.history = []
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
@property
|
|
56
|
+
def sync_runner(self):
|
|
55
57
|
"""
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
Convenience/debug function to run without async.
|
|
58
60
|
|
|
59
61
|
"""
|
|
62
|
+
import asyncio
|
|
63
|
+
return asyncio.run
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
async def run(self, *args, deps=None, **kwargs) -> AgentRunResult[RESULT_TYPE]:
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
Run Agent with deps-relative user prompt and while storing history
|
|
69
|
+
|
|
70
|
+
"""
|
|
71
|
+
result = await self.agent.run(*args, user_prompt=self.get_prompt(deps), deps=deps, message_history=self.history, **kwargs)
|
|
62
72
|
self.history = result.all_messages()
|
|
63
73
|
return result
|
|
64
74
|
|
|
65
|
-
async def
|
|
75
|
+
async def validate(self, ctx: RunContext[DEPS_TYPE], output: RESULT_TYPE) -> RESULT_TYPE:
|
|
66
76
|
"""
|
|
67
77
|
|
|
68
|
-
|
|
78
|
+
Dummy validator
|
|
69
79
|
|
|
70
80
|
"""
|
|
71
|
-
|
|
72
|
-
tool_return_part = msg_final.parts[0]
|
|
81
|
+
return output
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
def get_prompt(self, deps: Optional[DEPS_TYPE]) -> Optional[str]:
|
|
84
|
+
"""
|
|
76
85
|
|
|
77
|
-
|
|
86
|
+
Dummy prompt generator
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
return
|
|
88
|
+
"""
|
|
89
|
+
return None
|
|
81
90
|
|
|
82
|
-
|
|
91
|
+
def add_system_prompt(self, ctx: RunContext[DEPS_TYPE]) -> str | List[str]:
|
|
83
92
|
"""
|
|
84
93
|
|
|
85
|
-
Dummy
|
|
94
|
+
Dummy system prompt append
|
|
86
95
|
|
|
87
96
|
"""
|
|
88
|
-
|
|
97
|
+
|
|
98
|
+
return []
|
|
89
99
|
|
|
90
100
|
if __name__ == '__main__':
|
|
91
101
|
import asyncio
|
|
92
102
|
from fmtr.tools import dm
|
|
93
103
|
|
|
94
104
|
|
|
95
|
-
class TestOutput(dm.
|
|
105
|
+
class TestOutput(dm.Base):
|
|
96
106
|
text: str
|
|
97
107
|
|
|
98
108
|
|
|
109
|
+
class TestDeps(dm.Base):
|
|
110
|
+
lang: str
|
|
111
|
+
subject: str
|
|
112
|
+
|
|
113
|
+
|
|
99
114
|
class TaskTest(Task):
|
|
100
|
-
PROVIDER = Task.PROVIDER_FMTR
|
|
101
|
-
MODEL_ID = 'qwen2.5-coder:14b'
|
|
115
|
+
# PROVIDER = Task.PROVIDER_FMTR
|
|
116
|
+
# MODEL_ID = 'qwen2.5-coder:14b'
|
|
102
117
|
RESULT_TYPE = TestOutput
|
|
118
|
+
SYSTEM_PROMPT_STATIC = 'Tell the user jokes.'
|
|
119
|
+
|
|
120
|
+
def add_system_prompt(self, ctx: RunContext[TestDeps]) -> str:
|
|
121
|
+
return f'The jokes must be in the {ctx.deps.lang} language.'
|
|
122
|
+
|
|
123
|
+
def get_prompt(self, deps: Optional[TestDeps]) -> str:
|
|
124
|
+
return f'Tell me one about {deps.subject}.'
|
|
103
125
|
|
|
104
126
|
task = TaskTest()
|
|
105
|
-
|
|
106
|
-
|
|
127
|
+
deps = TestDeps(lang='English', subject='eggs')
|
|
128
|
+
result1 = task.sync_runner(task.run(deps=deps))
|
|
129
|
+
result1
|
|
130
|
+
|
|
131
|
+
deps = TestDeps(lang='German', subject='sausages')
|
|
132
|
+
result2 = task.sync_runner(task.run(deps=deps))
|
|
133
|
+
result2
|
fmtr/tools/api_tools.py
CHANGED
fmtr/tools/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fmtr.tools
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.4
|
|
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
|
|
@@ -9,50 +9,51 @@ License: Copyright © 2025 Frontmatter. All rights reserved.
|
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE
|
|
11
11
|
Provides-Extra: test
|
|
12
|
-
Requires-Dist:
|
|
13
|
-
Requires-Dist:
|
|
14
|
-
Requires-Dist: pandas; extra == "test"
|
|
15
|
-
Requires-Dist: pydantic-settings; extra == "test"
|
|
16
|
-
Requires-Dist: pydantic-ai[logfire,openai]; extra == "test"
|
|
17
|
-
Requires-Dist: tinynetrc; extra == "test"
|
|
18
|
-
Requires-Dist: deepmerge; extra == "test"
|
|
19
|
-
Requires-Dist: pytest-cov; extra == "test"
|
|
20
|
-
Requires-Dist: torchaudio; extra == "test"
|
|
21
|
-
Requires-Dist: peft; extra == "test"
|
|
22
|
-
Requires-Dist: google-auth-oauthlib; extra == "test"
|
|
23
|
-
Requires-Dist: huggingface_hub; extra == "test"
|
|
24
|
-
Requires-Dist: uvicorn; extra == "test"
|
|
25
|
-
Requires-Dist: ollama; extra == "test"
|
|
26
|
-
Requires-Dist: sre_yield; extra == "test"
|
|
27
|
-
Requires-Dist: torchvision; extra == "test"
|
|
28
|
-
Requires-Dist: json_repair; extra == "test"
|
|
29
|
-
Requires-Dist: flet-video; extra == "test"
|
|
30
|
-
Requires-Dist: sentence_transformers; extra == "test"
|
|
31
|
-
Requires-Dist: logfire; extra == "test"
|
|
32
|
-
Requires-Dist: google-auth; extra == "test"
|
|
12
|
+
Requires-Dist: tokenizers; extra == "test"
|
|
13
|
+
Requires-Dist: faker; extra == "test"
|
|
33
14
|
Requires-Dist: pydantic; extra == "test"
|
|
15
|
+
Requires-Dist: logfire; extra == "test"
|
|
16
|
+
Requires-Dist: tabulate; extra == "test"
|
|
34
17
|
Requires-Dist: diskcache; extra == "test"
|
|
18
|
+
Requires-Dist: sre_yield; extra == "test"
|
|
19
|
+
Requires-Dist: distributed; extra == "test"
|
|
20
|
+
Requires-Dist: bokeh; extra == "test"
|
|
21
|
+
Requires-Dist: flet[all]; extra == "test"
|
|
35
22
|
Requires-Dist: fastapi; extra == "test"
|
|
36
|
-
Requires-Dist:
|
|
23
|
+
Requires-Dist: uvicorn[standard]; extra == "test"
|
|
24
|
+
Requires-Dist: google-auth; extra == "test"
|
|
25
|
+
Requires-Dist: logfire[fastapi]; extra == "test"
|
|
26
|
+
Requires-Dist: contexttimer; extra == "test"
|
|
37
27
|
Requires-Dist: pyyaml; extra == "test"
|
|
28
|
+
Requires-Dist: flet-webview; extra == "test"
|
|
29
|
+
Requires-Dist: transformers[sentencepiece]; extra == "test"
|
|
30
|
+
Requires-Dist: sentence_transformers; extra == "test"
|
|
31
|
+
Requires-Dist: pandas; extra == "test"
|
|
32
|
+
Requires-Dist: dask[bag]; extra == "test"
|
|
33
|
+
Requires-Dist: pydevd-pycharm; extra == "test"
|
|
38
34
|
Requires-Dist: openai; extra == "test"
|
|
39
|
-
Requires-Dist:
|
|
40
|
-
Requires-Dist:
|
|
35
|
+
Requires-Dist: peft; extra == "test"
|
|
36
|
+
Requires-Dist: tinynetrc; extra == "test"
|
|
37
|
+
Requires-Dist: semver; extra == "test"
|
|
38
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
39
|
+
Requires-Dist: pymupdf4llm; extra == "test"
|
|
40
|
+
Requires-Dist: pydantic-ai[logfire,openai]; extra == "test"
|
|
41
|
+
Requires-Dist: google-api-python-client; extra == "test"
|
|
41
42
|
Requires-Dist: html2text; extra == "test"
|
|
42
|
-
Requires-Dist:
|
|
43
|
-
Requires-Dist:
|
|
44
|
-
Requires-Dist:
|
|
43
|
+
Requires-Dist: huggingface_hub; extra == "test"
|
|
44
|
+
Requires-Dist: torchaudio; extra == "test"
|
|
45
|
+
Requires-Dist: deepmerge; extra == "test"
|
|
46
|
+
Requires-Dist: torchvision; extra == "test"
|
|
47
|
+
Requires-Dist: google-auth-httplib2; extra == "test"
|
|
48
|
+
Requires-Dist: pydantic-settings; extra == "test"
|
|
49
|
+
Requires-Dist: google-auth-oauthlib; extra == "test"
|
|
45
50
|
Requires-Dist: openpyxl; extra == "test"
|
|
46
|
-
Requires-Dist:
|
|
47
|
-
Requires-Dist: contexttimer; extra == "test"
|
|
48
|
-
Requires-Dist: pymupdf4llm; extra == "test"
|
|
49
|
-
Requires-Dist: transformers[sentencepiece]; extra == "test"
|
|
50
|
-
Requires-Dist: tokenizers; extra == "test"
|
|
51
|
-
Requires-Dist: bokeh; extra == "test"
|
|
51
|
+
Requires-Dist: pymupdf; extra == "test"
|
|
52
52
|
Requires-Dist: Unidecode; extra == "test"
|
|
53
|
-
Requires-Dist: flet-
|
|
54
|
-
Requires-Dist:
|
|
55
|
-
Requires-Dist:
|
|
53
|
+
Requires-Dist: flet-video; extra == "test"
|
|
54
|
+
Requires-Dist: ollama; extra == "test"
|
|
55
|
+
Requires-Dist: docker; extra == "test"
|
|
56
|
+
Requires-Dist: json_repair; extra == "test"
|
|
56
57
|
Provides-Extra: yaml
|
|
57
58
|
Requires-Dist: pyyaml; extra == "yaml"
|
|
58
59
|
Provides-Extra: logging
|
|
@@ -88,10 +89,11 @@ Provides-Extra: merging
|
|
|
88
89
|
Requires-Dist: deepmerge; extra == "merging"
|
|
89
90
|
Provides-Extra: api
|
|
90
91
|
Requires-Dist: fastapi; extra == "api"
|
|
91
|
-
Requires-Dist: uvicorn; extra == "api"
|
|
92
|
+
Requires-Dist: uvicorn[standard]; extra == "api"
|
|
92
93
|
Requires-Dist: logfire; extra == "api"
|
|
93
94
|
Requires-Dist: semver; extra == "api"
|
|
94
95
|
Requires-Dist: pydantic; extra == "api"
|
|
96
|
+
Requires-Dist: logfire[fastapi]; extra == "api"
|
|
95
97
|
Provides-Extra: ai
|
|
96
98
|
Requires-Dist: peft; extra == "ai"
|
|
97
99
|
Requires-Dist: transformers[sentencepiece]; extra == "ai"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
fmtr/tools/__init__.py,sha256=_p8-qJSEfrdI5Kc1tTQ7RzIk7dbAcJ9yf0lpLEN4n80,5196
|
|
2
|
-
fmtr/tools/api_tools.py,sha256=
|
|
2
|
+
fmtr/tools/api_tools.py,sha256=w8Zrp_EwN5KlUghwLoTCXo4z1irg5tAsReCqDLjASfE,2133
|
|
3
3
|
fmtr/tools/async_tools.py,sha256=ewz757WcveQJd-G5SVr2JDOQVbdLGecCgl-tsBGVZz4,284
|
|
4
4
|
fmtr/tools/augmentation_tools.py,sha256=-6ESbO4CDlKqVOV1J1V6qBeoBMzbFIinkDHRHnCBej0,55
|
|
5
5
|
fmtr/tools/caching_tools.py,sha256=UOCYUNvLQ-NofR_dhqBmZF96-HRPf4At5MmxVk3gAIk,2943
|
|
@@ -43,11 +43,11 @@ fmtr/tools/tabular_tools.py,sha256=tpIpZzYku1HcJrHZJL6BC39LmN3WUWVhFbK2N7nDVmE,1
|
|
|
43
43
|
fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
|
|
44
44
|
fmtr/tools/tools.py,sha256=CAsApa1YwVdNE6H66Vjivs_mXYvOas3rh7fPELAnTpk,795
|
|
45
45
|
fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
|
|
46
|
-
fmtr/tools/version,sha256=
|
|
46
|
+
fmtr/tools/version,sha256=s4n9aV0PFyXVJPIoNMaqvv68dMsxTpUy9-iiXCnuR9I,5
|
|
47
47
|
fmtr/tools/version_tools.py,sha256=yNs_CGqWpqE4jbK9wsPIi14peJVXYbhIcMqHAFOw3yE,1480
|
|
48
48
|
fmtr/tools/yaml_tools.py,sha256=Ol43ZwbnSXGnn1K98Uxx61KPGSqfC4axE-X2q1LKMwk,349
|
|
49
49
|
fmtr/tools/ai_tools/__init__.py,sha256=JZrLuOFNV1A3wvJgonxOgz_4WS-7MfCuowGWA5uYCjs,372
|
|
50
|
-
fmtr/tools/ai_tools/agentic_tools.py,sha256=
|
|
50
|
+
fmtr/tools/ai_tools/agentic_tools.py,sha256=pHmsWixulpIBEoIQvamfkQT9BDJ39unqS9ndVw0JVUw,3477
|
|
51
51
|
fmtr/tools/ai_tools/inference_tools.py,sha256=yF8Oxph0L8W2CnK_o-MVztBhWVwBpgOEkx9_m3uqQww,11840
|
|
52
52
|
fmtr/tools/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
fmtr/tools/tests/conftest.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -57,9 +57,9 @@ fmtr/tools/tests/test_environment.py,sha256=iHaiMQfECYZPkPKwfuIZV9uHuWe3aE-p_dN_
|
|
|
57
57
|
fmtr/tools/tests/test_json.py,sha256=IeSP4ziPvRcmS8kq7k9tHonC9rN5YYq9GSNT2ul6Msk,287
|
|
58
58
|
fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g,2188
|
|
59
59
|
fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
|
|
60
|
-
fmtr_tools-1.1.
|
|
61
|
-
fmtr_tools-1.1.
|
|
62
|
-
fmtr_tools-1.1.
|
|
63
|
-
fmtr_tools-1.1.
|
|
64
|
-
fmtr_tools-1.1.
|
|
65
|
-
fmtr_tools-1.1.
|
|
60
|
+
fmtr_tools-1.1.4.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
|
|
61
|
+
fmtr_tools-1.1.4.dist-info/METADATA,sha256=q81Hj9eHRAlCzP5eEAW8xhuH5rjkkQ4uXc53VMpb5Ic,14646
|
|
62
|
+
fmtr_tools-1.1.4.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
63
|
+
fmtr_tools-1.1.4.dist-info/entry_points.txt,sha256=Zmeyls-zo5S99SlKUmsy9ULUNmk-4B9WQCEjuPIH0Yw,142
|
|
64
|
+
fmtr_tools-1.1.4.dist-info/top_level.txt,sha256=t5341a8ii3n4RFizwTeXGmcq_pf4GqL1h9ylE5LIWRk,12
|
|
65
|
+
fmtr_tools-1.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|