Spaces:
Configuration error
Configuration error
Scott Cogan commited on
Commit ·
d1caed2
1
Parent(s): 2f6cc37
final final final final final final finalfinal final fix
Browse files
app.py
CHANGED
|
@@ -245,6 +245,15 @@ class CustomCodeAgent(CodeAgent):
|
|
| 245 |
# Store tools as a list for template rendering
|
| 246 |
self.tools = tools_list
|
| 247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
self.authorized_imports = [
|
| 249 |
'datetime', 'random', 'pandas', 'itertools', 'math',
|
| 250 |
'statistics', 'queue', 'time', 'collections', 're'
|
|
@@ -258,17 +267,8 @@ class CustomCodeAgent(CodeAgent):
|
|
| 258 |
print("[DEBUG] Initializing system prompt...")
|
| 259 |
template = self.prompt_templates["system_prompt"]
|
| 260 |
|
| 261 |
-
# Convert tools to a format suitable for template rendering
|
| 262 |
-
tools_for_template = []
|
| 263 |
-
for tool in self.tools:
|
| 264 |
-
if hasattr(tool, 'name') and hasattr(tool, 'description'):
|
| 265 |
-
tools_for_template.append({
|
| 266 |
-
'name': str(tool.name),
|
| 267 |
-
'description': str(tool.description)
|
| 268 |
-
})
|
| 269 |
-
|
| 270 |
template_vars = {
|
| 271 |
-
'tools': tools_for_template, #
|
| 272 |
'task': getattr(self, 'task', ''),
|
| 273 |
'authorized_imports': self.authorized_imports,
|
| 274 |
'remaining_steps': self.remaining_steps,
|
|
@@ -281,7 +281,7 @@ class CustomCodeAgent(CodeAgent):
|
|
| 281 |
except Exception as e:
|
| 282 |
print(f"[ERROR] Template rendering failed: {str(e)}")
|
| 283 |
print(f"[DEBUG] Template vars: {template_vars}")
|
| 284 |
-
print(f"[DEBUG] Tools for template: {tools_for_template}")
|
| 285 |
return f"""System prompt template rendering failed: {str(e)}\nTask: {getattr(self, 'task', '')}\nAvailable tools: {[t.name for t in self.tools if hasattr(t, 'name')]}
|
| 286 |
"""
|
| 287 |
|
|
|
|
| 245 |
# Store tools as a list for template rendering
|
| 246 |
self.tools = tools_list
|
| 247 |
|
| 248 |
+
# Convert tools to template-friendly format
|
| 249 |
+
self.tools_for_template = []
|
| 250 |
+
for tool in self.tools:
|
| 251 |
+
if hasattr(tool, 'name') and hasattr(tool, 'description'):
|
| 252 |
+
self.tools_for_template.append({
|
| 253 |
+
'name': str(tool.name),
|
| 254 |
+
'description': str(tool.description)
|
| 255 |
+
})
|
| 256 |
+
|
| 257 |
self.authorized_imports = [
|
| 258 |
'datetime', 'random', 'pandas', 'itertools', 'math',
|
| 259 |
'statistics', 'queue', 'time', 'collections', 're'
|
|
|
|
| 267 |
print("[DEBUG] Initializing system prompt...")
|
| 268 |
template = self.prompt_templates["system_prompt"]
|
| 269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
template_vars = {
|
| 271 |
+
'tools': self.tools_for_template, # Use pre-formatted tools
|
| 272 |
'task': getattr(self, 'task', ''),
|
| 273 |
'authorized_imports': self.authorized_imports,
|
| 274 |
'remaining_steps': self.remaining_steps,
|
|
|
|
| 281 |
except Exception as e:
|
| 282 |
print(f"[ERROR] Template rendering failed: {str(e)}")
|
| 283 |
print(f"[DEBUG] Template vars: {template_vars}")
|
| 284 |
+
print(f"[DEBUG] Tools for template: {self.tools_for_template}")
|
| 285 |
return f"""System prompt template rendering failed: {str(e)}\nTask: {getattr(self, 'task', '')}\nAvailable tools: {[t.name for t in self.tools if hasattr(t, 'name')]}
|
| 286 |
"""
|
| 287 |
|