quantalogic 0.30.6__py3-none-any.whl → 0.30.8__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.
- quantalogic/agent.py +12 -8
- quantalogic/tool_manager.py +47 -36
- {quantalogic-0.30.6.dist-info → quantalogic-0.30.8.dist-info}/METADATA +1 -1
- {quantalogic-0.30.6.dist-info → quantalogic-0.30.8.dist-info}/RECORD +7 -7
- {quantalogic-0.30.6.dist-info → quantalogic-0.30.8.dist-info}/LICENSE +0 -0
- {quantalogic-0.30.6.dist-info → quantalogic-0.30.8.dist-info}/WHEEL +0 -0
- {quantalogic-0.30.6.dist-info → quantalogic-0.30.8.dist-info}/entry_points.txt +0 -0
quantalogic/agent.py
CHANGED
@@ -559,20 +559,24 @@ class Agent(BaseModel):
|
|
559
559
|
key: self._interpolate_variables(value) for key, value in arguments_with_values.items()
|
560
560
|
}
|
561
561
|
|
562
|
-
|
563
|
-
try:
|
564
|
-
converted_args = self.tools._convert_kwargs_types(tool_name, **arguments_with_values_interpolated)
|
565
|
-
except ValueError as e:
|
566
|
-
logger.error(f"Type conversion failed: {str(e)}")
|
567
|
-
return "", f"Error: Type conversion failed for tool '{tool_name}': {str(e)}"
|
562
|
+
arguments_with_values_interpolated = arguments_with_values_interpolated
|
568
563
|
|
569
564
|
# test if tool need variables in context
|
570
565
|
if tool.need_variables:
|
571
566
|
# Inject variables into the tool if needed
|
572
|
-
|
567
|
+
arguments_with_values_interpolated["variables"] = self.variable_store
|
573
568
|
if tool.need_caller_context_memory:
|
574
569
|
# Inject caller context into the tool if needed
|
575
|
-
|
570
|
+
arguments_with_values_interpolated["caller_context_memory"] = self.memory.memory
|
571
|
+
|
572
|
+
try:
|
573
|
+
# Convert arguments to proper types
|
574
|
+
converted_args = self.tools.validate_and_convert_arguments(
|
575
|
+
tool_name,
|
576
|
+
arguments_with_values_interpolated
|
577
|
+
)
|
578
|
+
except ValueError as e:
|
579
|
+
return "", f"Argument Error: {str(e)}"
|
576
580
|
|
577
581
|
# Add injectable variables
|
578
582
|
injectable_properties = tool.get_injectable_properties_in_execution()
|
quantalogic/tool_manager.py
CHANGED
@@ -67,49 +67,60 @@ class ToolManager(BaseModel):
|
|
67
67
|
index += 1
|
68
68
|
return markdown
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
|
72
|
+
def validate_and_convert_arguments(self, tool_name: str, provided_args: dict) -> dict:
|
73
|
+
"""Validates and converts arguments based on tool definition.
|
72
74
|
|
73
75
|
Args:
|
74
|
-
tool_name: Name of the tool to
|
75
|
-
|
76
|
+
tool_name: Name of the tool to validate against
|
77
|
+
provided_args: Dictionary of arguments to validate
|
76
78
|
|
77
79
|
Returns:
|
78
|
-
Dictionary of converted arguments
|
80
|
+
Dictionary of converted arguments with proper types
|
79
81
|
|
80
82
|
Raises:
|
81
|
-
ValueError:
|
83
|
+
ValueError: For missing/invalid arguments or conversion errors
|
82
84
|
"""
|
83
|
-
tool = self.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
85
|
+
tool = self.get(tool_name)
|
86
|
+
converted_args = {}
|
87
|
+
type_conversion = {
|
88
|
+
"string": lambda x: str(x),
|
89
|
+
"int": lambda x: int(x),
|
90
|
+
"float": lambda x: float(x),
|
91
|
+
"bool": lambda x: str(x).lower() in ['true', '1', 'yes']
|
92
|
+
}
|
93
|
+
|
94
|
+
for arg_def in tool.arguments:
|
95
|
+
arg_name = arg_def.name
|
96
|
+
arg_type = arg_def.arg_type
|
97
|
+
required = arg_def.required
|
98
|
+
default = getattr(arg_def, 'default', None)
|
99
|
+
|
100
|
+
# Handle missing arguments
|
101
|
+
if arg_name not in provided_args:
|
102
|
+
if required:
|
103
|
+
raise ValueError(f"Missing required argument: {arg_name}")
|
104
|
+
if default is None:
|
105
|
+
continue # Skip optional args with no default
|
106
|
+
provided_args[arg_name] = default
|
107
|
+
|
108
|
+
# Type conversion
|
109
|
+
value = provided_args[arg_name]
|
110
|
+
if arg_type in type_conversion:
|
111
|
+
try:
|
112
|
+
converted = type_conversion[arg_type](value)
|
113
|
+
except (ValueError, TypeError) as e:
|
107
114
|
raise ValueError(
|
108
|
-
f"
|
115
|
+
f"Invalid value '{value}' for {arg_name} ({arg_type}): {str(e)}"
|
109
116
|
)
|
110
|
-
|
111
|
-
|
112
|
-
|
117
|
+
converted_args[arg_name] = converted
|
118
|
+
else:
|
119
|
+
converted_args[arg_name] = value # Unknown type, pass through
|
113
120
|
|
114
|
-
|
115
|
-
|
121
|
+
# Validate extra arguments
|
122
|
+
extra_args = set(provided_args.keys()) - {a.name for a in tool.arguments}
|
123
|
+
if extra_args:
|
124
|
+
raise ValueError(f"Unexpected arguments: {', '.join(extra_args)}")
|
125
|
+
|
126
|
+
return converted_args
|
@@ -1,5 +1,5 @@
|
|
1
1
|
quantalogic/__init__.py,sha256=kX0c_xmD9OslWnAE92YHMGuD7xZcTo8ZOF_5R64HKps,784
|
2
|
-
quantalogic/agent.py,sha256=
|
2
|
+
quantalogic/agent.py,sha256=Ue8qV0jkD5i7ownIuYQJ1ljIqYYc-rQ2-3cv6Cuo9Y4,31309
|
3
3
|
quantalogic/agent_config.py,sha256=9sjDnCPlAqVM45oguB_D509WSCaXZmuaVUtLcOvDlPg,7572
|
4
4
|
quantalogic/agent_factory.py,sha256=ODVGuGtugSzmSdP6jiWlT8WyC5onANc6BIs83FC90Bg,3782
|
5
5
|
quantalogic/coding_agent.py,sha256=Z7ik6LUvLKDnaW9Ax1iZGC7p1WMnlYEUIlE5lkBP414,4975
|
@@ -25,7 +25,7 @@ quantalogic/server/static/js/quantalogic.js,sha256=x7TrlZGR1Y0WLK2DWl1xY847BhEWM
|
|
25
25
|
quantalogic/server/templates/index.html,sha256=nDnXJoQEm1vXbhXtgaYk0G5VXj0wwzE6KrqEDhHFpj4,7773
|
26
26
|
quantalogic/task_file_reader.py,sha256=AMIJoeVY9Hhu0dBJ-C5EyaOFsXLkhn2oBhVs-WTnnLk,1460
|
27
27
|
quantalogic/task_runner.py,sha256=FtxfZs2dxdsSZoiW92K3dpfegFe0dyKx9ZP5CCyEAzo,9965
|
28
|
-
quantalogic/tool_manager.py,sha256=
|
28
|
+
quantalogic/tool_manager.py,sha256=LUdzKIQn2W8ieCDG5EX0LdjzcwCOvSuiHnsXgddukc4,4599
|
29
29
|
quantalogic/tools/__init__.py,sha256=pTirT5UBynuTkAzFYebu7ttGAMP3_A0idFvDp6lGZJQ,2146
|
30
30
|
quantalogic/tools/agent_tool.py,sha256=MXCXxWHRch7VK4UWhtRP1jeI8Np9Ne2CUGo8vm1oZiM,3064
|
31
31
|
quantalogic/tools/dalle_e.py,sha256=nur2kl6DKjaWWaHcmF_y9vS5bvty2fW8hQfdgf5KWfs,10948
|
@@ -85,8 +85,8 @@ quantalogic/version_check.py,sha256=cttR1lR3OienGLl7NrK1Te1fhDkqSjCci7HC1vFUTSY,
|
|
85
85
|
quantalogic/welcome_message.py,sha256=IXMhem8h7srzNUwvw8G_lmEkHU8PFfote021E_BXmVk,3039
|
86
86
|
quantalogic/xml_parser.py,sha256=uMLQNHTRCg116FwcjRoquZmSwVtE4LEH-6V2E3RD-dA,11466
|
87
87
|
quantalogic/xml_tool_parser.py,sha256=Vz4LEgDbelJynD1siLOVkJ3gLlfHsUk65_gCwbYJyGc,3784
|
88
|
-
quantalogic-0.30.
|
89
|
-
quantalogic-0.30.
|
90
|
-
quantalogic-0.30.
|
91
|
-
quantalogic-0.30.
|
92
|
-
quantalogic-0.30.
|
88
|
+
quantalogic-0.30.8.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
89
|
+
quantalogic-0.30.8.dist-info/METADATA,sha256=IAlgxZjaFHCms34IQMC-mYWFbB4yh7pfJ0OMuxTQngE,21722
|
90
|
+
quantalogic-0.30.8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
91
|
+
quantalogic-0.30.8.dist-info/entry_points.txt,sha256=h74O_Q3qBRCrDR99qvwB4BpBGzASPUIjCfxHq6Qnups,183
|
92
|
+
quantalogic-0.30.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|