Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -426,12 +426,13 @@ class VideoTranscriptionTool(Tool):
|
|
426 |
|
427 |
class BasicAgent:
|
428 |
def __init__(self):
|
429 |
-
|
430 |
-
|
431 |
-
temperature=0.1,
|
432 |
-
|
433 |
-
|
434 |
|
|
|
435 |
# Initialize all tool instances
|
436 |
self.search_tool = DuckDuckGoSearchTool()
|
437 |
self.wiki_search_tool = WikiSearchTool() # Ensure this class is defined/imported
|
@@ -440,13 +441,17 @@ class BasicAgent:
|
|
440 |
self.speech_to_text_tool = SpeechToTextTool() # Ensure this class is defined/imported
|
441 |
self.visit_webpage_tool = VisitWebpageTool() # Ensure this class is defined/imported
|
442 |
self.final_answer_tool = FinalAnswerTool()
|
|
|
|
|
443 |
|
|
|
444 |
# Custom tools - ensure these classes are defined and imported
|
445 |
self.video_transcription_tool = VideoTranscriptionTool()
|
446 |
self.image_analysis_tool = ImageAnalysisTool() # Renamed for clarity
|
447 |
self.analyse_attachment_tool = AnalyseAttachmentTool() # Renamed for clarity
|
448 |
self.code_llama_tool = CodeLlamaTool() # Ensure this class is defined/imported
|
449 |
self.parse_excel_to_json_tool = ParseExcelToJsonTool()
|
|
|
450 |
|
451 |
|
452 |
system_prompt_template = """
|
@@ -460,6 +465,7 @@ If the answer is a comma-separated list, apply the above rules for each element
|
|
460 |
"""
|
461 |
|
462 |
# Create web agent with image analysis capability
|
|
|
463 |
self.web_agent = ToolCallingAgent(
|
464 |
tools=[
|
465 |
self.search_tool, # Use the initialized DuckDuckGoSearchTool instance
|
@@ -471,8 +477,11 @@ If the answer is a comma-separated list, apply the above rules for each element
|
|
471 |
name="web_search_agent",
|
472 |
description="Runs web searches and analyzes images",
|
473 |
)
|
|
|
|
|
474 |
|
475 |
# Create main agent with all capabilities
|
|
|
476 |
self.agent = CodeAgent(
|
477 |
model=self.model, # Use self.model
|
478 |
tools=[
|
@@ -491,6 +500,8 @@ If the answer is a comma-separated list, apply the above rules for each element
|
|
491 |
],
|
492 |
add_base_tools=True # Consider what this adds, ensure it doesn't duplicate.
|
493 |
)
|
|
|
|
|
494 |
|
495 |
# Update system prompt
|
496 |
# It's generally better to pass the system prompt directly if possible
|
|
|
426 |
|
427 |
class BasicAgent:
|
428 |
def __init__(self):
|
429 |
+
try:
|
430 |
+
token = os.environ.get("HF_API_TOKEN")
|
431 |
+
self.model = HfApiModel(temperature=0.1, token=token)
|
432 |
+
except Exception as e:
|
433 |
+
raise RuntimeError(f"Error initializing model: {e}")
|
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
|
|
|
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 |
|
447 |
+
|
448 |
# Custom tools - ensure these classes are defined and imported
|
449 |
self.video_transcription_tool = VideoTranscriptionTool()
|
450 |
self.image_analysis_tool = ImageAnalysisTool() # Renamed for clarity
|
451 |
self.analyse_attachment_tool = AnalyseAttachmentTool() # Renamed for clarity
|
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 = """
|
|
|
465 |
"""
|
466 |
|
467 |
# Create web agent with image analysis capability
|
468 |
+
try:
|
469 |
self.web_agent = ToolCallingAgent(
|
470 |
tools=[
|
471 |
self.search_tool, # Use the initialized DuckDuckGoSearchTool instance
|
|
|
477 |
name="web_search_agent",
|
478 |
description="Runs web searches and analyzes images",
|
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 |
self.agent = CodeAgent(
|
486 |
model=self.model, # Use self.model
|
487 |
tools=[
|
|
|
500 |
],
|
501 |
add_base_tools=True # Consider what this adds, ensure it doesn't duplicate.
|
502 |
)
|
503 |
+
except Exception as e:
|
504 |
+
raise RuntimeError(f"Error initializing web agent: {e}")
|
505 |
|
506 |
# Update system prompt
|
507 |
# It's generally better to pass the system prompt directly if possible
|