fmtr.tools 1.0.52__tar.gz → 1.0.53__tar.gz

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.

Files changed (73) hide show
  1. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/PKG-INFO +1 -1
  2. fmtr.tools-1.0.53/fmtr/tools/ai_tools/agentic_tools.py +92 -0
  3. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/config.py +2 -0
  4. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/data_modelling_tools.py +9 -1
  5. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/debugging_tools.py +0 -9
  6. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/string_tools.py +17 -1
  7. fmtr.tools-1.0.53/fmtr/tools/tabular_tools.py +7 -0
  8. fmtr.tools-1.0.53/fmtr/tools/version +1 -0
  9. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr.tools.egg-info/PKG-INFO +1 -1
  10. fmtr.tools-1.0.52/fmtr/tools/ai_tools/agentic_tools.py +0 -14
  11. fmtr.tools-1.0.52/fmtr/tools/tabular_tools.py +0 -4
  12. fmtr.tools-1.0.52/fmtr/tools/version +0 -1
  13. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/LICENSE +0 -0
  14. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/README.md +0 -0
  15. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/__init__.py +0 -0
  16. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/ai_tools/__init__.py +0 -0
  17. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/ai_tools/inference_tools.py +0 -0
  18. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/api_tools.py +0 -0
  19. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/async_tools.py +0 -0
  20. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/augmentation_tools.py +0 -0
  21. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/caching_tools.py +0 -0
  22. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/config_tools.py +0 -0
  23. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/console_script_tools.py +0 -0
  24. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/dataclass_tools.py +0 -0
  25. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/datatype_tools.py +0 -0
  26. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/docker_tools.py +0 -0
  27. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/environment_tools.py +0 -0
  28. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/function_tools.py +0 -0
  29. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/google_api_tools.py +0 -0
  30. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/hash_tools.py +0 -0
  31. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/hfh_tools.py +0 -0
  32. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/html_tools.py +0 -0
  33. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/import_tools.py +0 -0
  34. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/inspection_tools.py +0 -0
  35. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/interface_tools.py +0 -0
  36. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/iterator_tools.py +0 -0
  37. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/json_fix_tools.py +0 -0
  38. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/json_tools.py +0 -0
  39. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/logging_tools.py +0 -0
  40. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/merging_tools.py +0 -0
  41. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/metric_tools.py +0 -0
  42. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/name_tools.py +0 -0
  43. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/netrc_tools.py +0 -0
  44. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/openai_tools.py +0 -0
  45. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/parallel_tools.py +0 -0
  46. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/path_tools.py +0 -0
  47. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/pdf_tools.py +0 -0
  48. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/platform_tools.py +0 -0
  49. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/process_tools.py +0 -0
  50. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/profiling_tools.py +0 -0
  51. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/random_tools.py +0 -0
  52. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/semantic_tools.py +0 -0
  53. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/spaces_tools.py +0 -0
  54. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tests/__init__.py +0 -0
  55. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tests/conftest.py +0 -0
  56. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tests/helpers.py +0 -0
  57. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tests/test_datatype.py +0 -0
  58. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tests/test_environment.py +0 -0
  59. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tests/test_json.py +0 -0
  60. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tests/test_path.py +0 -0
  61. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tests/test_yaml.py +0 -0
  62. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tokenization_tools.py +0 -0
  63. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/tools.py +0 -0
  64. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/unicode_tools.py +0 -0
  65. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/version_tools.py +0 -0
  66. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr/tools/yaml_tools.py +0 -0
  67. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr.tools.egg-info/SOURCES.txt +0 -0
  68. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr.tools.egg-info/dependency_links.txt +0 -0
  69. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr.tools.egg-info/entry_points.txt +0 -0
  70. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr.tools.egg-info/requires.txt +0 -0
  71. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/fmtr.tools.egg-info/top_level.txt +0 -0
  72. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/setup.cfg +0 -0
  73. {fmtr.tools-1.0.52 → fmtr.tools-1.0.53}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fmtr.tools
3
- Version: 1.0.52
3
+ Version: 1.0.53
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
@@ -0,0 +1,92 @@
1
+ import pydantic_ai
2
+ from pydantic_ai import RunContext, ModelRetry
3
+ from pydantic_ai.agent import AgentRunResult
4
+ from pydantic_ai.messages import ModelRequest, SystemPromptPart, ToolCallPart, RetryPromptPart, ModelResponse, ToolReturnPart, UserPromptPart
5
+ from pydantic_ai.models.openai import OpenAIModel
6
+ from pydantic_ai.providers.openai import OpenAIProvider
7
+
8
+ from fmtr.tools import environment_tools as env
9
+ from fmtr.tools.config import ToolsConfig
10
+
11
+ pydantic_ai.Agent.instrument_all()
12
+
13
+ class Agent(pydantic_ai.Agent):
14
+ """
15
+
16
+ Agent stub
17
+
18
+ TODO base class is marked `@final`, so is it safe to subclass?
19
+
20
+ """
21
+
22
+
23
+ class Task:
24
+ """
25
+
26
+ Linear task definition, as Agent configuration and typing, plus state history.
27
+
28
+ """
29
+
30
+ PROVIDER = OpenAIProvider(api_key=env.get(ToolsConfig.FMTR_OPENAI_API_KEY_KEY))
31
+ MODEL_ID = 'gpt-4o'
32
+ SYSTEM_PROMPT = None
33
+ DEPS_TYPE = type(None)
34
+ RESULT_TYPE = type(None)
35
+ RESULT_RETRIES = 5
36
+
37
+ def __init__(self, *args, **kwargs):
38
+ """
39
+
40
+ Configure Agent
41
+
42
+ """
43
+
44
+ self.model = OpenAIModel(self.MODEL_ID, provider=self.PROVIDER)
45
+ self.agent = Agent(
46
+ *args,
47
+ model=self.model,
48
+ system_prompt=self.SYSTEM_PROMPT,
49
+ deps_type=self.DEPS_TYPE,
50
+ result_type=self.RESULT_TYPE,
51
+ result_retries=self.RESULT_RETRIES,
52
+ **kwargs
53
+ )
54
+
55
+ self.agent.output_validator(self.validate)
56
+ self.history = []
57
+
58
+ async def run(self, *args, **kwargs) -> AgentRunResult[RESULT_TYPE]:
59
+ """
60
+
61
+ Run Agent storing history
62
+
63
+ """
64
+
65
+ result = await self.agent.run(*args, message_history=self.history, **kwargs)
66
+ self.history = result.all_messages()
67
+ return result
68
+
69
+ async def revert(self, msg, deps):
70
+ """
71
+
72
+ Post-hoc, user-initiated tool retry.
73
+
74
+ """
75
+ msg_final = self.history.pop(-1)
76
+ tool_return_part = msg_final.parts[0]
77
+
78
+ retry_prompt = RetryPromptPart(content=msg, tool_name=tool_return_part.tool_name, tool_call_id=tool_return_part.tool_call_id, timestamp=tool_return_part.timestamp, part_kind='retry-prompt')
79
+ retry_request = ModelRequest(parts=[retry_prompt], instructions=msg_final.instructions, kind='request')
80
+
81
+ self.history.append(retry_request)
82
+
83
+ result = await Task.run(self, deps=deps)
84
+ return result
85
+
86
+ async def validate(self, ctx: RunContext[DEPS_TYPE], output: RESULT_TYPE) -> RESULT_TYPE:
87
+ """
88
+
89
+ Dummy validator
90
+
91
+ """
92
+ return output
@@ -24,3 +24,5 @@ class ToolsConfig(ConfigClass):
24
24
  FMTR_REMOTE_DEBUG_HOST_DEFAULT = 'ws.lan'
25
25
  FMTR_REMOTE_DEBUG_PORT_DEFAULT = 5679
26
26
  FMTR_REMOTE_DEBUG_ENABLED_KEY = 'FMTR_REMOTE_DEBUG_ENABLED'
27
+
28
+ FMTR_OPENAI_API_KEY_KEY = 'FMTR_OPENAI_API_KEY'
@@ -1,4 +1,4 @@
1
- from pydantic import BaseModel, RootModel
1
+ from pydantic import BaseModel, RootModel, ConfigDict
2
2
 
3
3
 
4
4
  def to_df(*objs, name_value='value'):
@@ -23,6 +23,14 @@ def to_df(*objs, name_value='value'):
23
23
  return df
24
24
 
25
25
 
26
+ class MixinArbitraryTypes:
27
+ """
28
+
29
+ Convenience for when non-serializable types are needed
30
+ """
31
+
32
+ model_config = ConfigDict(arbitrary_types_allowed=True)
33
+
26
34
  class MixinFromJson:
27
35
 
28
36
  @classmethod
@@ -29,12 +29,3 @@ def trace(is_debug=None, host=None, port=None, stdoutToServer=True, stderrToServ
29
29
  logger.info(msg)
30
30
 
31
31
  pydevd_pycharm.settrace(host, port=port, stdoutToServer=stdoutToServer, stderrToServer=stderrToServer, **kwargs)
32
-
33
-
34
- def test(**kwargs):
35
- """
36
-
37
- Test debugger connection
38
-
39
- """
40
- return trace(is_debug=True, **kwargs)
@@ -129,7 +129,8 @@ class Mask:
129
129
  """
130
130
 
131
131
  def __init__(self, mask: str):
132
- self.mask = mask
132
+ self.mask = trim(mask)
133
+ self.mask_data = parse_string(self.mask)
133
134
  self.kwargs = {}
134
135
  self.args = []
135
136
 
@@ -147,6 +148,21 @@ class Mask:
147
148
  except (KeyError, IndexError):
148
149
  return self
149
150
 
151
+ def __str__(self):
152
+ """
153
+
154
+ Force string output, leaving any unfilled slots as-is.
155
+
156
+ """
157
+
158
+ fills = {}
159
+
160
+ for seg in self.mask_data:
161
+ if seg.field_name:
162
+ fill = self.kwargs.get(seg.field_name, f'{{{seg.field_name}}}')
163
+ fills[seg.field_name] = fill
164
+
165
+ return self.mask.format(**fills)
150
166
 
151
167
  def trim(text: str) -> str:
152
168
  """
@@ -0,0 +1,7 @@
1
+ import pandas as pd
2
+
3
+ Table = DataFrame = pd.DataFrame
4
+ Series = pd.Series
5
+
6
+ CONCAT_HORIZONTALLY = 1
7
+ CONCAT_VERTICALLY = 0
@@ -0,0 +1 @@
1
+ 1.0.53
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fmtr.tools
3
- Version: 1.0.52
3
+ Version: 1.0.53
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
@@ -1,14 +0,0 @@
1
- import pydantic_ai
2
-
3
-
4
- class Agent(pydantic_ai.Agent):
5
- """
6
-
7
- Agent stub
8
-
9
- TODO base class is marked `@final`, so is it safe to subclass?
10
-
11
- """
12
-
13
-
14
- Agent.instrument_all()
@@ -1,4 +0,0 @@
1
- import pandas as pd
2
-
3
- DataFrame = pd.DataFrame
4
- Series = pd.Series
@@ -1 +0,0 @@
1
- 1.0.52
File without changes
File without changes
File without changes
File without changes