Spaces:
Runtime error
Runtime error
Scott Cogan
commited on
Commit
·
16cd708
1
Parent(s):
4ed31d3
fix: Update CustomCodeAgent to safely handle initialization and template attributes
Browse files
app.py
CHANGED
|
@@ -237,16 +237,18 @@ class CustomCodeAgent(CodeAgent):
|
|
| 237 |
def __init__(self, *args, **kwargs):
|
| 238 |
# Store the tools dictionary for template rendering
|
| 239 |
self.tools_dict = kwargs.pop('tools_dict', {})
|
|
|
|
| 240 |
super().__init__(*args, **kwargs)
|
| 241 |
|
| 242 |
def initialize_system_prompt(self):
|
| 243 |
# Override to use tools_dict for template rendering
|
| 244 |
template = self.prompt_templates["system_prompt"]
|
|
|
|
| 245 |
return template.format(
|
| 246 |
tools=self.tools_dict,
|
| 247 |
-
task=self
|
| 248 |
-
managed_agents=self
|
| 249 |
-
authorized_imports=self
|
| 250 |
)
|
| 251 |
|
| 252 |
agent = CustomCodeAgent(
|
|
|
|
| 237 |
def __init__(self, *args, **kwargs):
|
| 238 |
# Store the tools dictionary for template rendering
|
| 239 |
self.tools_dict = kwargs.pop('tools_dict', {})
|
| 240 |
+
# Initialize parent class first
|
| 241 |
super().__init__(*args, **kwargs)
|
| 242 |
|
| 243 |
def initialize_system_prompt(self):
|
| 244 |
# Override to use tools_dict for template rendering
|
| 245 |
template = self.prompt_templates["system_prompt"]
|
| 246 |
+
# Use getattr to safely access attributes that might not be set yet
|
| 247 |
return template.format(
|
| 248 |
tools=self.tools_dict,
|
| 249 |
+
task=getattr(self, 'task', ''),
|
| 250 |
+
managed_agents=getattr(self, 'managed_agents', []),
|
| 251 |
+
authorized_imports=getattr(self, 'authorized_imports', [])
|
| 252 |
)
|
| 253 |
|
| 254 |
agent = CustomCodeAgent(
|