Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -430,7 +430,9 @@ class BasicAgent:
|
|
430 |
token = os.environ.get("HF_API_TOKEN")
|
431 |
self.model = HfApiModel(temperature=0.1, token=token)
|
432 |
except Exception as e:
|
433 |
-
|
|
|
|
|
434 |
|
435 |
try:
|
436 |
# Initialize all tool instances
|
@@ -442,7 +444,9 @@ class BasicAgent:
|
|
442 |
self.visit_webpage_tool = VisitWebpageTool() # Ensure this class is defined/imported
|
443 |
self.final_answer_tool = FinalAnswerTool()
|
444 |
except Exception as e:
|
445 |
-
|
|
|
|
|
446 |
|
447 |
|
448 |
# Custom tools - ensure these classes are defined and imported
|
@@ -477,7 +481,9 @@ If the answer is a comma-separated list, apply the above rules for each element
|
|
477 |
description="Runs web searches and analyzes images",
|
478 |
)
|
479 |
except Exception as e:
|
480 |
-
|
|
|
|
|
481 |
|
482 |
# Create main agent with all capabilities
|
483 |
try:
|
@@ -500,13 +506,22 @@ If the answer is a comma-separated list, apply the above rules for each element
|
|
500 |
add_base_tools=True # Consider what this adds, ensure it doesn't duplicate.
|
501 |
)
|
502 |
except Exception as e:
|
503 |
-
|
|
|
|
|
504 |
|
505 |
# Update system prompt
|
506 |
# It's generally better to pass the system prompt directly if possible
|
507 |
# or manage it through prompt templates defined by smolagents.
|
508 |
# If smolagents adds its own system prompt, this appends to it.
|
509 |
-
self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + system_prompt_template
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
|
511 |
|
512 |
def __call__(self, question: str) -> str:
|
|
|
430 |
token = os.environ.get("HF_API_TOKEN")
|
431 |
self.model = HfApiModel(temperature=0.1, token=token)
|
432 |
except Exception as e:
|
433 |
+
print("Error initializing model:")
|
434 |
+
traceback.print_exc()
|
435 |
+
raise
|
436 |
|
437 |
try:
|
438 |
# Initialize all tool instances
|
|
|
444 |
self.visit_webpage_tool = VisitWebpageTool() # Ensure this class is defined/imported
|
445 |
self.final_answer_tool = FinalAnswerTool()
|
446 |
except Exception as e:
|
447 |
+
print("Error initializing model:")
|
448 |
+
traceback.print_exc()
|
449 |
+
raise
|
450 |
|
451 |
|
452 |
# Custom tools - ensure these classes are defined and imported
|
|
|
481 |
description="Runs web searches and analyzes images",
|
482 |
)
|
483 |
except Exception as e:
|
484 |
+
print("Error initializing model:")
|
485 |
+
traceback.print_exc()
|
486 |
+
raise
|
487 |
|
488 |
# Create main agent with all capabilities
|
489 |
try:
|
|
|
506 |
add_base_tools=True # Consider what this adds, ensure it doesn't duplicate.
|
507 |
)
|
508 |
except Exception as e:
|
509 |
+
print("Error initializing model:")
|
510 |
+
traceback.print_exc()
|
511 |
+
raise
|
512 |
|
513 |
# Update system prompt
|
514 |
# It's generally better to pass the system prompt directly if possible
|
515 |
# or manage it through prompt templates defined by smolagents.
|
516 |
# If smolagents adds its own system prompt, this appends to it.
|
517 |
+
# self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + system_prompt_template
|
518 |
+
try:
|
519 |
+
if hasattr(self.agent, "prompt_templates") and "system_prompt" in self.agent.prompt_templates:
|
520 |
+
self.agent.prompt_templates["system_prompt"] += system_prompt_template
|
521 |
+
except Exception as e:
|
522 |
+
print("Error updating prompt:")
|
523 |
+
traceback.print_exc()
|
524 |
+
raise
|
525 |
|
526 |
|
527 |
def __call__(self, question: str) -> str:
|