xpander-sdk 2.0.206__py3-none-any.whl → 2.0.207__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.
- xpander_sdk/modules/tools_repository/tools_repository_module.py +65 -3
- xpander_sdk/modules/tools_repository/utils/schemas.py +20 -7
- {xpander_sdk-2.0.206.dist-info → xpander_sdk-2.0.207.dist-info}/METADATA +1 -1
- {xpander_sdk-2.0.206.dist-info → xpander_sdk-2.0.207.dist-info}/RECORD +7 -7
- {xpander_sdk-2.0.206.dist-info → xpander_sdk-2.0.207.dist-info}/WHEEL +1 -1
- {xpander_sdk-2.0.206.dist-info → xpander_sdk-2.0.207.dist-info}/licenses/LICENSE +0 -0
- {xpander_sdk-2.0.206.dist-info → xpander_sdk-2.0.207.dist-info}/top_level.txt +0 -0
|
@@ -159,8 +159,33 @@ class ToolsRepository(XPanderSharedModel):
|
|
|
159
159
|
|
|
160
160
|
for tool in self.list:
|
|
161
161
|
|
|
162
|
-
# add json schema to the model doc
|
|
163
|
-
|
|
162
|
+
# add json schema to the model doc with enhanced guidance
|
|
163
|
+
schema_json = tool.schema.model_json_schema(mode="serialization")
|
|
164
|
+
|
|
165
|
+
# Build example with actual schema structure
|
|
166
|
+
example_payload = {}
|
|
167
|
+
if 'properties' in schema_json:
|
|
168
|
+
for prop_name, prop_def in schema_json['properties'].items():
|
|
169
|
+
if prop_def.get('type') == 'object':
|
|
170
|
+
if prop_def.get('properties'):
|
|
171
|
+
# Show one example nested field
|
|
172
|
+
first_nested = list(prop_def['properties'].keys())[0]
|
|
173
|
+
example_payload[prop_name] = {first_nested: "<value>"}
|
|
174
|
+
else:
|
|
175
|
+
example_payload[prop_name] = {}
|
|
176
|
+
else:
|
|
177
|
+
example_payload[prop_name] = f"<{prop_def.get('type', 'value')}>"
|
|
178
|
+
|
|
179
|
+
tool.schema.__doc__ = f"""CRITICAL: This entire schema must be wrapped in a 'payload' parameter.
|
|
180
|
+
|
|
181
|
+
Call this function as: function_name(payload={{...}})
|
|
182
|
+
DO NOT call as: function_name(body_params={{...}}, headers={{...}}, ...)
|
|
183
|
+
|
|
184
|
+
Example correct call:
|
|
185
|
+
{json.dumps({"payload": example_payload}, indent=2)}
|
|
186
|
+
|
|
187
|
+
Full schema: {json.dumps(schema_json, indent=2)}
|
|
188
|
+
"""
|
|
164
189
|
|
|
165
190
|
schema_cls: Type[BaseModel] = tool.schema
|
|
166
191
|
|
|
@@ -208,7 +233,44 @@ class ToolsRepository(XPanderSharedModel):
|
|
|
208
233
|
|
|
209
234
|
# --- Metadata ---
|
|
210
235
|
tool_function.__name__ = tool_ref.id
|
|
211
|
-
|
|
236
|
+
|
|
237
|
+
# Build comprehensive docstring with parameter structure guidance
|
|
238
|
+
base_doc = tool_ref.description or tool_ref.name
|
|
239
|
+
|
|
240
|
+
# Extract schema properties for examples
|
|
241
|
+
schema_props = schema_ref.model_json_schema().get('properties', {})
|
|
242
|
+
param_names = list(schema_props.keys())
|
|
243
|
+
|
|
244
|
+
# Create example structure
|
|
245
|
+
example_parts = []
|
|
246
|
+
for prop_name in param_names:
|
|
247
|
+
prop_info = schema_props.get(prop_name, {})
|
|
248
|
+
if prop_info.get('type') == 'object' and prop_info.get('properties'):
|
|
249
|
+
# Show nested structure
|
|
250
|
+
nested_props = list(prop_info['properties'].keys())
|
|
251
|
+
if nested_props:
|
|
252
|
+
example_parts.append(f'"{prop_name}": {{"{nested_props[0]}": ...}}')
|
|
253
|
+
else:
|
|
254
|
+
example_parts.append(f'"{prop_name}": {{}}')
|
|
255
|
+
else:
|
|
256
|
+
example_parts.append(f'"{prop_name}": ...')
|
|
257
|
+
|
|
258
|
+
example_json = "{" + ", ".join(example_parts) + "}"
|
|
259
|
+
|
|
260
|
+
tool_function.__doc__ = f"""{base_doc}
|
|
261
|
+
|
|
262
|
+
IMPORTANT - Parameter Structure:
|
|
263
|
+
All parameters must be passed as a single 'payload' object containing the required fields.
|
|
264
|
+
|
|
265
|
+
Correct usage example:
|
|
266
|
+
{{
|
|
267
|
+
"payload": {example_json}
|
|
268
|
+
}}
|
|
269
|
+
|
|
270
|
+
DO NOT pass parameters as separate top-level arguments.
|
|
271
|
+
DO NOT use: {{"{param_names[0] if param_names else 'param'}": ..., "{param_names[1] if len(param_names) > 1 else 'param2'}": ...}}
|
|
272
|
+
USE: {{"payload": {{"{param_names[0] if param_names else 'param'}": ..., "{param_names[1] if len(param_names) > 1 else 'param2'}": ..., ...}}}}
|
|
273
|
+
"""
|
|
212
274
|
|
|
213
275
|
# --- Signature ---
|
|
214
276
|
payload_param = Parameter(
|
|
@@ -98,20 +98,24 @@ def build_model_from_schema(
|
|
|
98
98
|
|
|
99
99
|
field_args = {}
|
|
100
100
|
|
|
101
|
-
# Enhance description to clarify optional vs required status
|
|
101
|
+
# Enhance description to clarify optional vs required status AND nesting
|
|
102
102
|
enhanced_description = description or f"Parameter: {prop_name}"
|
|
103
|
+
|
|
104
|
+
# Add payload wrapper reminder for top-level params
|
|
105
|
+
wrapper_note = " (must be inside payload object)"
|
|
106
|
+
|
|
103
107
|
if is_empty_param_container:
|
|
104
|
-
enhanced_description = f"[OPTIONAL - empty container] {enhanced_description} (default: empty object)"
|
|
108
|
+
enhanced_description = f"[OPTIONAL - empty container] {enhanced_description} (default: empty object){wrapper_note}"
|
|
105
109
|
elif prop_name in required:
|
|
106
110
|
if default is not None:
|
|
107
|
-
enhanced_description = f"[REQUIRED with default] {enhanced_description} (default: {default})"
|
|
111
|
+
enhanced_description = f"[REQUIRED with default] {enhanced_description} (default: {default}){wrapper_note}"
|
|
108
112
|
else:
|
|
109
|
-
enhanced_description = f"[REQUIRED] {enhanced_description}"
|
|
113
|
+
enhanced_description = f"[REQUIRED] {enhanced_description}{wrapper_note}"
|
|
110
114
|
else:
|
|
111
115
|
if default is not None:
|
|
112
|
-
enhanced_description = f"[OPTIONAL with default] {enhanced_description} (default: {default})"
|
|
116
|
+
enhanced_description = f"[OPTIONAL with default] {enhanced_description} (default: {default}){wrapper_note}"
|
|
113
117
|
else:
|
|
114
|
-
enhanced_description = f"[OPTIONAL] {enhanced_description} - can be omitted or set to null"
|
|
118
|
+
enhanced_description = f"[OPTIONAL] {enhanced_description} - can be omitted or set to null{wrapper_note}"
|
|
115
119
|
|
|
116
120
|
field_args["description"] = enhanced_description
|
|
117
121
|
|
|
@@ -169,7 +173,16 @@ def build_model_from_schema(
|
|
|
169
173
|
strict=False, # Allow flexibility with types to handle AI agent inputs better
|
|
170
174
|
extra="allow",
|
|
171
175
|
title=model_name,
|
|
172
|
-
description="
|
|
176
|
+
description="""CRITICAL - This schema must be wrapped in a 'payload' parameter.
|
|
177
|
+
|
|
178
|
+
CORRECT: Call function with {"payload": {<this_schema>}}
|
|
179
|
+
INCORRECT: Call function with {<this_schema>} directly
|
|
180
|
+
|
|
181
|
+
All fields shown below must be nested inside a 'payload' object when calling the function.
|
|
182
|
+
|
|
183
|
+
Required fields must be provided. Optional fields can be omitted entirely or set to null.
|
|
184
|
+
All parameters with defaults will use those defaults if not provided.
|
|
185
|
+
Check the 'required' array in the schema to see which fields are mandatory."""
|
|
173
186
|
)
|
|
174
187
|
return create_model(
|
|
175
188
|
model_name,
|
|
@@ -71,7 +71,7 @@ xpander_sdk/modules/tasks/sub_modules/task.py,sha256=zRDHsE_LnYYa3OC79wVQqeRnpAo
|
|
|
71
71
|
xpander_sdk/modules/tasks/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
72
72
|
xpander_sdk/modules/tasks/utils/files.py,sha256=KqqwSQSrwim2-H3XP5wOadDDfngAyEI034tA7Oon-vc,3631
|
|
73
73
|
xpander_sdk/modules/tools_repository/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
74
|
-
xpander_sdk/modules/tools_repository/tools_repository_module.py,sha256=
|
|
74
|
+
xpander_sdk/modules/tools_repository/tools_repository_module.py,sha256=Hck2dACK2O8BHPXfFdVY8xBMQGYSFrB-trVCJ15LKN4,12393
|
|
75
75
|
xpander_sdk/modules/tools_repository/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
76
76
|
xpander_sdk/modules/tools_repository/decorators/register_tool.py,sha256=ep-BlJHmqvG7zcW6l-hz_V0ZJx3PGfNqdijw6VjUGek,4078
|
|
77
77
|
xpander_sdk/modules/tools_repository/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -82,7 +82,7 @@ xpander_sdk/modules/tools_repository/sub_modules/tool.py,sha256=rivnznxi6CrrOWE1
|
|
|
82
82
|
xpander_sdk/modules/tools_repository/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
83
83
|
xpander_sdk/modules/tools_repository/utils/generic.py,sha256=bQ31-RoAq12lpDoIWsgmqAt7NL5YdzW1j3WKqZtYb2A,1904
|
|
84
84
|
xpander_sdk/modules/tools_repository/utils/local_tools.py,sha256=zp5P8hVnRUJQb-w-2jCEMV5eUB_awmvYfY_rin5qvEw,1875
|
|
85
|
-
xpander_sdk/modules/tools_repository/utils/schemas.py,sha256=
|
|
85
|
+
xpander_sdk/modules/tools_repository/utils/schemas.py,sha256=EAoxhkVmwtqPOm-FkXiQRDNmcrmcnEeXbw73k7PzvUk,14242
|
|
86
86
|
xpander_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
87
87
|
xpander_sdk/utils/env.py,sha256=U_zIhqWgKs5fk2-HXjAaODj4oWMc5dRQ0fvw6fqVcFk,1522
|
|
88
88
|
xpander_sdk/utils/event_loop.py,sha256=kJrN0upgBhyI86tkTdfHeajznrIZl44Rl6WDiDG3GHE,2516
|
|
@@ -90,8 +90,8 @@ xpander_sdk/utils/generic.py,sha256=XrRj2-L8c0YWpfPdDyXE-pVL-6lKF9VpyZzKHQ4wuCc,
|
|
|
90
90
|
xpander_sdk/utils/tools.py,sha256=lyFkq2yP7DxBkyXYVlnFRwDhQCvf0fZZMDm5fBycze4,1244
|
|
91
91
|
xpander_sdk/utils/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
92
92
|
xpander_sdk/utils/agents/compactization_agent.py,sha256=S_U1dSmDC7I0JUsp_THUYjfutEI5QMBaMPJEXGp0_Sw,14389
|
|
93
|
-
xpander_sdk-2.0.
|
|
94
|
-
xpander_sdk-2.0.
|
|
95
|
-
xpander_sdk-2.0.
|
|
96
|
-
xpander_sdk-2.0.
|
|
97
|
-
xpander_sdk-2.0.
|
|
93
|
+
xpander_sdk-2.0.207.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
94
|
+
xpander_sdk-2.0.207.dist-info/METADATA,sha256=DD0MwqtsCcc7b2XXQReMG6y4P-4Rqkbu-sutigeeoIg,17952
|
|
95
|
+
xpander_sdk-2.0.207.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
96
|
+
xpander_sdk-2.0.207.dist-info/top_level.txt,sha256=UCjnxQpsMy5Zoe7lmRuVDO6DI2V_6PgRFfm4oizRbVs,12
|
|
97
|
+
xpander_sdk-2.0.207.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|