Spaces:
Configuration error
Configuration error
Scott Cogan commited on
Commit ·
fd1c8a6
1
Parent(s): 5816799
string again
Browse files
app.py
CHANGED
|
@@ -243,10 +243,15 @@ class CustomCodeAgent(CodeAgent):
|
|
| 243 |
print("[DEBUG] Initializing CustomCodeAgent...")
|
| 244 |
# Store the tools dictionary for template rendering
|
| 245 |
self.tools_dict = kwargs.pop('tools_dict', {})
|
| 246 |
-
#
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
# Set default values for template variables
|
| 251 |
self.authorized_imports = [
|
| 252 |
'datetime', 'random', 'pandas', 'itertools', 'math',
|
|
@@ -254,6 +259,9 @@ class CustomCodeAgent(CodeAgent):
|
|
| 254 |
]
|
| 255 |
self.remaining_steps = 15
|
| 256 |
self.answer_facts = ""
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
def initialize_system_prompt(self):
|
| 259 |
print("[DEBUG] Initializing system prompt...")
|
|
@@ -262,7 +270,10 @@ class CustomCodeAgent(CodeAgent):
|
|
| 262 |
# Debug print for tools
|
| 263 |
print("[DEBUG] Tools list:")
|
| 264 |
for t in self.tools:
|
| 265 |
-
|
|
|
|
|
|
|
|
|
|
| 266 |
|
| 267 |
try:
|
| 268 |
# Create template with proper undefined handling
|
|
@@ -284,7 +295,7 @@ class CustomCodeAgent(CodeAgent):
|
|
| 284 |
# Fallback template
|
| 285 |
return f"""System prompt template rendering failed: {str(e)}
|
| 286 |
Task: {getattr(self, 'task', '')}
|
| 287 |
-
Available tools: {[t.name for t in self.tools]}
|
| 288 |
"""
|
| 289 |
|
| 290 |
def run(self, question_text: str, stream: bool = True):
|
|
|
|
| 243 |
print("[DEBUG] Initializing CustomCodeAgent...")
|
| 244 |
# Store the tools dictionary for template rendering
|
| 245 |
self.tools_dict = kwargs.pop('tools_dict', {})
|
| 246 |
+
# Ensure all tools are proper Tool objects
|
| 247 |
+
self.tools = []
|
| 248 |
+
for tool in kwargs.get('tools', []):
|
| 249 |
+
if isinstance(tool, Tool):
|
| 250 |
+
self.tools.append(tool)
|
| 251 |
+
else:
|
| 252 |
+
print(f"[WARNING] Skipping invalid tool: {tool}")
|
| 253 |
+
kwargs['tools'] = self.tools
|
| 254 |
+
|
| 255 |
# Set default values for template variables
|
| 256 |
self.authorized_imports = [
|
| 257 |
'datetime', 'random', 'pandas', 'itertools', 'math',
|
|
|
|
| 259 |
]
|
| 260 |
self.remaining_steps = 15
|
| 261 |
self.answer_facts = ""
|
| 262 |
+
|
| 263 |
+
# Initialize parent class
|
| 264 |
+
super().__init__(*args, **kwargs)
|
| 265 |
|
| 266 |
def initialize_system_prompt(self):
|
| 267 |
print("[DEBUG] Initializing system prompt...")
|
|
|
|
| 270 |
# Debug print for tools
|
| 271 |
print("[DEBUG] Tools list:")
|
| 272 |
for t in self.tools:
|
| 273 |
+
if isinstance(t, Tool):
|
| 274 |
+
print(f" - {t.name}: {type(t)}")
|
| 275 |
+
else:
|
| 276 |
+
print(f" - Invalid tool: {t}")
|
| 277 |
|
| 278 |
try:
|
| 279 |
# Create template with proper undefined handling
|
|
|
|
| 295 |
# Fallback template
|
| 296 |
return f"""System prompt template rendering failed: {str(e)}
|
| 297 |
Task: {getattr(self, 'task', '')}
|
| 298 |
+
Available tools: {[t.name for t in self.tools if isinstance(t, Tool)]}
|
| 299 |
"""
|
| 300 |
|
| 301 |
def run(self, question_text: str, stream: bool = True):
|