satif-ai 0.2.4__py3-none-any.whl → 0.2.6__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.
@@ -1,8 +1,9 @@
1
1
  import base64
2
2
  import os
3
3
  import re
4
+ from collections import defaultdict
4
5
  from pathlib import Path
5
- from typing import Dict, List, Optional, Union
6
+ from typing import Any, Dict, List, Optional, Union
6
7
 
7
8
  from agents import Agent, Runner, function_tool
8
9
  from agents.mcp.server import MCPServer
@@ -15,6 +16,7 @@ from satif_sdk.transformers import CodeTransformer
15
16
  # Global variables for transformation
16
17
  INPUT_SDIF_PATH: Optional[Path] = None
17
18
  OUTPUT_TARGET_FILES: Optional[Dict[Union[str, Path], str]] = None
19
+ SCHEMA_ONLY: Optional[bool] = None
18
20
 
19
21
 
20
22
  @function_tool
@@ -32,6 +34,9 @@ async def execute_transformation(code: str) -> str:
32
34
  generated_output_path = code_transformer.export(INPUT_SDIF_PATH)
33
35
 
34
36
  comparisons = []
37
+ comparator_kwargs = {"check_structure_only": True}
38
+ if SCHEMA_ONLY:
39
+ comparator_kwargs["check_structure_only"] = True
35
40
 
36
41
  if os.path.isdir(generated_output_path):
37
42
  # If it's a directory, compare each file with its corresponding target
@@ -46,7 +51,9 @@ async def execute_transformation(code: str) -> str:
46
51
  generated_output_path, output_target_file_name
47
52
  )
48
53
  comparator = get_comparator(output_target_file_name.split(".")[-1])
49
- comparison = comparator.compare(generated_file_path, output_base_file)
54
+ comparison = comparator.compare(
55
+ generated_file_path, output_base_file, **comparator_kwargs
56
+ )
50
57
  comparisons.append(
51
58
  f"Comparison for {generated_file_path} [SOURCE] with {output_target_file_name} [TARGET]: {comparison}"
52
59
  )
@@ -60,7 +67,9 @@ async def execute_transformation(code: str) -> str:
60
67
  output_file = list(OUTPUT_TARGET_FILES.keys())[0]
61
68
  output_target_file_name = list(OUTPUT_TARGET_FILES.values())[0]
62
69
  comparator = get_comparator(output_file.split(".")[-1])
63
- comparison = comparator.compare(generated_output_path, output_file)
70
+ comparison = comparator.compare(
71
+ generated_output_path, output_file, **comparator_kwargs
72
+ )
64
73
  comparisons.append(
65
74
  f"Comparison for {generated_output_path} [SOURCE] with {output_target_file_name} [TARGET]: {comparison}"
66
75
  )
@@ -91,7 +100,7 @@ class TransformationAsyncCodeBuilder(AsyncCodeBuilder):
91
100
  self,
92
101
  mcp_server: MCPServer,
93
102
  mcp_session: ClientSession,
94
- llm_model: str = "o3-mini",
103
+ llm_model: str = "o4-mini",
95
104
  ):
96
105
  self.mcp_server = mcp_server
97
106
  self.mcp_session = mcp_session
@@ -103,17 +112,17 @@ class TransformationAsyncCodeBuilder(AsyncCodeBuilder):
103
112
  output_target_files: Dict[Union[str, Path], str] | List[Path],
104
113
  output_sdif: Optional[Path] = None, # This will now be relative or None
105
114
  instructions: Optional[str] = None,
115
+ schema_only: bool = False,
116
+ representer_options_for_build: Optional[Dict[str, Any]] = None,
106
117
  ) -> str:
107
- global INPUT_SDIF_PATH, OUTPUT_TARGET_FILES
118
+ global INPUT_SDIF_PATH, OUTPUT_TARGET_FILES, SCHEMA_ONLY
108
119
  # INPUT_SDIF_PATH is used by execute_transformation tool, needs to be accessible from where that tool runs.
109
120
  # If execute_transformation runs in the same process as the builder, absolute path is fine.
110
121
  # If it were a separate context, this might need adjustment.
111
122
  # For now, assume execute_transformation can access absolute paths if needed for its *input SDIF*.
112
123
  # However, the sdif for MCP URIs must be relative.
113
- INPUT_SDIF_PATH = Path(
114
- sdif
115
- ).resolve() # Keep this as absolute for the tool's potential direct access.
116
-
124
+ INPUT_SDIF_PATH = Path(sdif).resolve()
125
+ SCHEMA_ONLY = schema_only
117
126
  # Paths for MCP URIs are now expected to be relative to MCP server CWD (project root)
118
127
  # So, use them directly as strings.
119
128
  input_sdif_mcp_uri_path = base64.b64encode(str(sdif).encode()).decode()
@@ -172,16 +181,21 @@ class TransformationAsyncCodeBuilder(AsyncCodeBuilder):
172
181
  else:
173
182
  OUTPUT_TARGET_FILES = {}
174
183
 
175
- output_representation = {}
184
+ output_representation = defaultdict(dict)
176
185
  if OUTPUT_TARGET_FILES:
177
186
  for file_key_abs_path in list(OUTPUT_TARGET_FILES.keys()):
178
187
  agent_facing_name = OUTPUT_TARGET_FILES[file_key_abs_path]
179
- print(f"Representing {agent_facing_name} from {file_key_abs_path}!!")
188
+ print(f"Representing {agent_facing_name} from {file_key_abs_path}")
180
189
  try:
181
190
  # Representer uses the absolute path (file_key_abs_path) to read the example file.
182
- output_representation[agent_facing_name] = get_representer(
183
- file_key_abs_path
184
- ).represent(file_key_abs_path)
191
+ representer = get_representer(file_key_abs_path)
192
+ representation, used_params = representer.represent(
193
+ file_key_abs_path, **(representer_options_for_build or {})
194
+ )
195
+ output_representation[agent_facing_name] = {
196
+ "representation": representation,
197
+ "used_params": used_params,
198
+ }
185
199
  except Exception as e:
186
200
  print(
187
201
  f"Warning: Could not get representation for {agent_facing_name} (path {file_key_abs_path}): {e}"
@@ -204,10 +218,13 @@ class TransformationAsyncCodeBuilder(AsyncCodeBuilder):
204
218
  else "Error reading input sample",
205
219
  "output_files": str(list(OUTPUT_TARGET_FILES.values())),
206
220
  "output_schema": output_schema_text,
207
- "output_sample": output_sample_text,
221
+ "output_sample": output_sample_text
222
+ if not SCHEMA_ONLY
223
+ else "Sample not available.",
208
224
  "output_representation": str(
209
225
  output_representation
210
226
  ), # Representation keyed by agent-facing name
227
+ "instructions": instructions,
211
228
  },
212
229
  )
213
230
  agent = Agent(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: satif-ai
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: AI Agents for Satif
5
5
  License: MIT
6
6
  Author: Bryan Djafer
@@ -3,15 +3,15 @@ satif_ai/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
3
3
  satif_ai/adapters/tidy.py,sha256=2oYj7Gz3vOQtzcpoJI4JbftWlMKvOWL8rdwthjg-zUE,19884
4
4
  satif_ai/code_builders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  satif_ai/code_builders/adaptation.py,sha256=E29YM0S6pMtAfB0uzSUexoeWKwXfF8iJVyYUCKWQz5k,188
6
- satif_ai/code_builders/transformation.py,sha256=c0-7JTs5pgiDOYxjWtB-w8Z-nwwqDWSUPCY1kJo3xEs,9638
6
+ satif_ai/code_builders/transformation.py,sha256=mO_kGYl6QYvErW1rVaToDYJ2rpE36hUmKC7HjGl4ytI,10432
7
7
  satif_ai/plot_builders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  satif_ai/plot_builders/agent.py,sha256=Ncw7SL9qkpRN0hw76ezSo1K8vVQK6gcXFp8x8VFwqUI,8291
9
9
  satif_ai/plot_builders/prompt.py,sha256=m0W1SsxnB9_FhIYRumkthImJbK-7KUm4dygN3kjAXGk,6877
10
10
  satif_ai/plot_builders/tool.py,sha256=MeLnG_wFoITSVWZcNFsQLCi157O4L3wItQgolBa4fAw,5994
11
11
  satif_ai/standardizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  satif_ai/standardizers/ai_csv.py,sha256=AAeTt7eqFAtayxF2b95Z_K_lnMdwBBnv2Cn-qTEpMp8,29499
13
- satif_ai-0.2.4.dist-info/LICENSE,sha256=kS8EN6yAaGZd7V5z6GKSn_x3ozcZltrfRky4vMPRCw8,1072
14
- satif_ai-0.2.4.dist-info/METADATA,sha256=3wCHxt5KwmSGllAwhqSQus7rgtcbteW7DYPmKRxIO-A,670
15
- satif_ai-0.2.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
16
- satif_ai-0.2.4.dist-info/entry_points.txt,sha256=Mz2SwYALjktap1bF-Q3EWBgiZVNT6QJCVsCs_fCV33Y,43
17
- satif_ai-0.2.4.dist-info/RECORD,,
13
+ satif_ai-0.2.6.dist-info/LICENSE,sha256=kS8EN6yAaGZd7V5z6GKSn_x3ozcZltrfRky4vMPRCw8,1072
14
+ satif_ai-0.2.6.dist-info/METADATA,sha256=qM5JQ9OJfC2zTlYlp6XyyrLdzuL1N45hYWsjgUSQxAM,670
15
+ satif_ai-0.2.6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
16
+ satif_ai-0.2.6.dist-info/entry_points.txt,sha256=Mz2SwYALjktap1bF-Q3EWBgiZVNT6QJCVsCs_fCV33Y,43
17
+ satif_ai-0.2.6.dist-info/RECORD,,