Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -434,13 +434,13 @@ class BasicAgent:
|
|
434 |
|
435 |
try:
|
436 |
# Initialize all tool instances
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
except Exception as e:
|
445 |
raise RuntimeError(f"Error initializing tools: {e}")
|
446 |
|
@@ -452,7 +452,6 @@ class BasicAgent:
|
|
452 |
self.code_llama_tool = CodeLlamaTool() # Ensure this class is defined/imported
|
453 |
self.parse_excel_to_json_tool = ParseExcelToJsonTool()
|
454 |
|
455 |
-
|
456 |
|
457 |
system_prompt_template = """
|
458 |
You are my general AI assistant. Your task is to answer the question I asked.
|
@@ -466,40 +465,40 @@ If the answer is a comma-separated list, apply the above rules for each element
|
|
466 |
|
467 |
# Create web agent with image analysis capability
|
468 |
try:
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
except Exception as e:
|
481 |
raise RuntimeError(f"Error initializing web agent: {e}")
|
482 |
|
483 |
# Create main agent with all capabilities
|
484 |
try:
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
except Exception as e:
|
504 |
raise RuntimeError(f"Error initializing web agent: {e}")
|
505 |
|
|
|
434 |
|
435 |
try:
|
436 |
# Initialize all tool instances
|
437 |
+
self.search_tool = DuckDuckGoSearchTool()
|
438 |
+
self.wiki_search_tool = WikiSearchTool() # Ensure this class is defined/imported
|
439 |
+
self.str_reverse_tool = StringReverseTool() # Ensure this class is defined/imported
|
440 |
+
self.keywords_extract_tool = KeywordsExtractorTool() # Ensure this class is defined/imported
|
441 |
+
self.speech_to_text_tool = SpeechToTextTool() # Ensure this class is defined/imported
|
442 |
+
self.visit_webpage_tool = VisitWebpageTool() # Ensure this class is defined/imported
|
443 |
+
self.final_answer_tool = FinalAnswerTool()
|
444 |
except Exception as e:
|
445 |
raise RuntimeError(f"Error initializing tools: {e}")
|
446 |
|
|
|
452 |
self.code_llama_tool = CodeLlamaTool() # Ensure this class is defined/imported
|
453 |
self.parse_excel_to_json_tool = ParseExcelToJsonTool()
|
454 |
|
|
|
455 |
|
456 |
system_prompt_template = """
|
457 |
You are my general AI assistant. Your task is to answer the question I asked.
|
|
|
465 |
|
466 |
# Create web agent with image analysis capability
|
467 |
try:
|
468 |
+
self.web_agent = ToolCallingAgent(
|
469 |
+
tools=[
|
470 |
+
self.search_tool, # Use the initialized DuckDuckGoSearchTool instance
|
471 |
+
self.visit_webpage_tool,
|
472 |
+
self.image_analysis_tool
|
473 |
+
],
|
474 |
+
model=self.model, # Use self.model
|
475 |
+
max_steps=10,
|
476 |
+
name="web_search_agent",
|
477 |
+
description="Runs web searches and analyzes images",
|
478 |
+
)
|
479 |
except Exception as e:
|
480 |
raise RuntimeError(f"Error initializing web agent: {e}")
|
481 |
|
482 |
# Create main agent with all capabilities
|
483 |
try:
|
484 |
+
self.agent = CodeAgent(
|
485 |
+
model=self.model, # Use self.model
|
486 |
+
tools=[
|
487 |
+
self.search_tool,
|
488 |
+
self.wiki_search_tool,
|
489 |
+
self.str_reverse_tool,
|
490 |
+
self.keywords_extract_tool,
|
491 |
+
self.speech_to_text_tool,
|
492 |
+
self.visit_webpage_tool,
|
493 |
+
self.final_answer_tool,
|
494 |
+
self.video_transcription_tool,
|
495 |
+
self.code_llama_tool,
|
496 |
+
self.parse_excel_to_json_tool,
|
497 |
+
self.image_analysis_tool, # Use the initialized instance
|
498 |
+
self.analyse_attachment_tool # Add the initialized attachment analysis tool
|
499 |
+
],
|
500 |
+
add_base_tools=True # Consider what this adds, ensure it doesn't duplicate.
|
501 |
+
)
|
502 |
except Exception as e:
|
503 |
raise RuntimeError(f"Error initializing web agent: {e}")
|
504 |
|