from smolagents import CodeAgent,ToolCallingAgent, PythonInterpreterTool , VisitWebpageTool, DuckDuckGoSearchTool from src.final_assignment_template.models import openrouter_qwenCoder_model, modelLiteLLm from src.final_assignment_template.tools import travily_tool, bm25_query, BM25Tool,extract_filter_textual_info_from_textual_context, summarize_before_final_answer, Video_link_understanding_tool, image_understanding_tool, get_task_file # (Keep Constants as is) # --- Constants --- # retrived_context_qa_agent = ToolCallingAgent( # name="retrived_context_qa_agent", # description=""" # You are a simple QA agent for the retrived web contect. # 1. Pass query and context and avaialbe tools. # 2. If you can answer directly, respond in plain text. # 3. Otherwise, return an explicit action JSON, e.g. # {"action": "use_tool", "tool_name": "...", "input": "..."}. # """, # model=modelLiteLLm, # tools=[], # no extra tools by default # add_base_tools=False, # don’t add PythonInterpreterTool, etc. # verbosity_level=1, # planning_interval=1, # ) # web_agent = CodeAgent( # model=openrouter_qwenCoder_model, # tools=[ # # GoogleSearchTool(provider="serper"), # # DuckDuckGoSearchTool(max_results=10), # travily_tool, # VisitWebpageTool(), # ], # name="web_agent", # description="""Browses the web to find information""", # verbosity_level=1, # planning_interval=1, # max_steps=8, # ) # code_agent = CodeAgent( # model=openrouter_qwenCoder_model, # tools=[ # # GoogleSearchTool(provider="serper"), # # DuckDuckGoSearchTool(max_results=10), # PythonInterpreterTool(additional_authorized_imports=[ # "json", # "markdown", # 'numpy', # 'pandas' # 'math', 'statistics', 're', 'unicodedata', 'random', # 'datetime', 'queue', 'time', 'collections', 'stat', 'itertools', # ]) # ], # name="code_agent", # description="""You can execute python code using this agent""", # verbosity_level=1, # max_steps=3, # ) # - When using the Video_Link_Understanding_Tool and Image_Understanding_Tool, consider their responses and generate an answer based on the textual understanding they provide. # - Video_Link_Understanding_Tool: This tool can only return textual understanding. # - Image_Understanding_Tool: This tool can only return textual understanding. Task_agent = CodeAgent( name="task_Agent", description=""" - You are the Task Agent. - Provide the correct answer - Must call 'summarize_before_final_answer' at the end """, model=modelLiteLLm, add_base_tools=True, tools=[ PythonInterpreterTool(), Video_link_understanding_tool, image_understanding_tool, get_task_file, travily_tool, # DuckDuckGoSearchTool(), # bm25_query, VisitWebpageTool(), extract_filter_textual_info_from_textual_context, # summarize_before_final_answer, ], additional_authorized_imports=[ 'numpy', 'pandas' 'math', 'datetime', ], # managed_agents=[web_agent], planning_interval=1, verbosity_level=1, max_steps=7, # final_answer_checks=[check_reasoning_and_plot], )