Spaces:
Runtime error
Runtime error
Scott Cogan
commited on
Commit
·
fe0da85
1
Parent(s):
4fbafa6
chore: add debug prints to trace initialization in Spaces
Browse files
app.py
CHANGED
|
@@ -232,15 +232,19 @@ logger.debug("Created tools dictionary:")
|
|
| 232 |
for name, tool in tools_dict.items():
|
| 233 |
logger.debug(f" {name}: {tool}")
|
| 234 |
|
|
|
|
|
|
|
| 235 |
# Create a custom CodeAgent class that handles both list and dictionary requirements
|
| 236 |
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 |
# 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 |
# Convert tools_dict to list for template rendering
|
|
@@ -253,6 +257,7 @@ class CustomCodeAgent(CodeAgent):
|
|
| 253 |
authorized_imports=getattr(self, 'authorized_imports', [])
|
| 254 |
)
|
| 255 |
|
|
|
|
| 256 |
agent = CustomCodeAgent(
|
| 257 |
model=model,
|
| 258 |
tools=tools, # Pass tools as a list for _setup_tools
|
|
@@ -266,5 +271,6 @@ agent = CustomCodeAgent(
|
|
| 266 |
prompt_templates=prompt_templates
|
| 267 |
)
|
| 268 |
|
| 269 |
-
|
| 270 |
demo = GradioUI(agent).build_blocks()
|
|
|
|
|
|
| 232 |
for name, tool in tools_dict.items():
|
| 233 |
logger.debug(f" {name}: {tool}")
|
| 234 |
|
| 235 |
+
print("[DEBUG] Starting app.py initialization...")
|
| 236 |
+
|
| 237 |
# Create a custom CodeAgent class that handles both list and dictionary requirements
|
| 238 |
class CustomCodeAgent(CodeAgent):
|
| 239 |
def __init__(self, *args, **kwargs):
|
| 240 |
+
print("[DEBUG] Initializing CustomCodeAgent...")
|
| 241 |
# Store the tools dictionary for template rendering
|
| 242 |
self.tools_dict = kwargs.pop('tools_dict', {})
|
| 243 |
# Initialize parent class first
|
| 244 |
super().__init__(*args, **kwargs)
|
| 245 |
|
| 246 |
def initialize_system_prompt(self):
|
| 247 |
+
print("[DEBUG] Initializing system prompt...")
|
| 248 |
# Override to use tools_dict for template rendering
|
| 249 |
template = self.prompt_templates["system_prompt"]
|
| 250 |
# Convert tools_dict to list for template rendering
|
|
|
|
| 257 |
authorized_imports=getattr(self, 'authorized_imports', [])
|
| 258 |
)
|
| 259 |
|
| 260 |
+
print("[DEBUG] Creating agent instance...")
|
| 261 |
agent = CustomCodeAgent(
|
| 262 |
model=model,
|
| 263 |
tools=tools, # Pass tools as a list for _setup_tools
|
|
|
|
| 271 |
prompt_templates=prompt_templates
|
| 272 |
)
|
| 273 |
|
| 274 |
+
print("[DEBUG] Building Gradio demo...")
|
| 275 |
demo = GradioUI(agent).build_blocks()
|
| 276 |
+
print("[DEBUG] Gradio demo built and exposed as 'demo'.")
|