Commit ·
7bfc491
1
Parent(s): df6c855
Refactor MainAgent ot use just one agent
Browse filesFiles changed (3)
- agent.py+20-15
- requirements.txt+3
- utils.py+1
123456713 unmodified lines212223242526272829303132333435363738394041424344from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, VisitWebpageTool, AmazonBedrockServerModelfrom tools import AudioTranscriber, txt_reader, pdf_reader, excel_reader, math_calculatorfrom utils import BEDROCK_MODEL_IDMAIN_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template:13 unmodified lines"""Main agent that orchestrates file handling and web search tasks."""def __init__(self):model = AmazonBedrockServerModel(model_id=BEDROCK_MODEL_ID)file_handler_agent = ToolCallingAgent(name="FileHandlerAgent",description="Handles file-related tasks such as reading Excel, text, PDF files, etc.",tools=[AudioTranscriber(),txt_reader,pdf_reader,excel_reader,],max_steps=3,model=model,)self.agent = ToolCallingAgent(name="web_search_agent",description="An agent that can search the web, visit webpages, and perform calculations.",managed_agents=[file_handler_agent],tools=[DuckDuckGoSearchTool(), VisitWebpageTool(), math_calculator],max_steps=5,model=model,)123456789101112131415161713 unmodified lines31323334353637383940414243444546474849import osfrom smolagents import OpenAIServerModel, ToolCallingAgentfrom tools import (AudioTranscriber,txt_reader,pdf_reader,excel_reader,math_calculator,search_engine,image_transcriber,)from utils import OPENAI_MODEL_IDMAIN_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template:13 unmodified lines"""Main agent that orchestrates file handling and web search tasks."""def __init__(self):model = OpenAIServerModel(model_id=OPENAI_MODEL_ID, api_key=os.getenv("OPENAI_API_KEY"))self.agent = ToolCallingAgent(name="main_agent",description="An agent that can search the web, visit webpages, perform calculations, and handle files.",tools=[search_engine,math_calculator,AudioTranscriber(),txt_reader,pdf_reader,excel_reader,image_transcriber,],max_steps=5,model=model,)
30 unmodified lines31323334353623 unmodified lines6061626364658 unmodified lines74757677787930 unmodified linesjsonpatch==1.33 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'jsonpointer==3.0.0 ; python_version >= '3.7'langchain-core==0.3.61 ; python_version >= '3.9'langgraph==0.4.7langgraph-checkpoint==2.0.26 ; python_version >= '3.9'langgraph-prebuilt==0.2.1 ; python_version >= '3.9'23 unmodified linespython-multipart==0.0.20 ; python_version >= '3.8'pytz==2025.2pyyaml==6.0.2 ; python_version >= '3.8'requests==2.32.3requests-toolbelt==1.0.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'rich==14.0.0 ; python_full_version >= '3.8.0'8 unmodified linessoupsieve==2.7 ; python_version >= '3.8'starlette==0.46.2 ; sys_platform != 'emscripten'tenacity==9.1.2 ; python_version >= '3.9'tomlkit==0.13.2 ; python_version >= '3.8'tqdm==4.67.1 ; python_version >= '3.7'typer==0.16.0 ; sys_platform != 'emscripten'30 unmodified lines3132333435363723 unmodified lines616263646566678 unmodified lines7677787980818230 unmodified linesjsonpatch==1.33 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'jsonpointer==3.0.0 ; python_version >= '3.7'langchain-core==0.3.61 ; python_version >= '3.9'langchain-openai==0.3.18langgraph==0.4.7langgraph-checkpoint==2.0.26 ; python_version >= '3.9'langgraph-prebuilt==0.2.1 ; python_version >= '3.9'23 unmodified linespython-multipart==0.0.20 ; python_version >= '3.8'pytz==2025.2pyyaml==6.0.2 ; python_version >= '3.8'regex==2024.11.6 ; python_version >= '3.8'requests==2.32.3requests-toolbelt==1.0.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'rich==14.0.0 ; python_full_version >= '3.8.0'8 unmodified linessoupsieve==2.7 ; python_version >= '3.8'starlette==0.46.2 ; sys_platform != 'emscripten'tenacity==9.1.2 ; python_version >= '3.9'tiktoken==0.9.0 ; python_version >= '3.9'tomlkit==0.13.2 ; python_version >= '3.8'tqdm==4.67.1 ; python_version >= '3.7'typer==0.16.0 ; sys_platform != 'emscripten'
5 unmodified lines678910115 unmodified linesDEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"BEDROCK_MODEL_ID = "anthropic.claude-3-5-sonnet-20240620-v1:0"bedrock_runtime = boto3.client("bedrock-runtime", region_name=os.getenv("AWS_REGION"))5 unmodified lines67891011125 unmodified linesDEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"BEDROCK_MODEL_ID = "anthropic.claude-3-5-sonnet-20240620-v1:0"OPENAI_MODEL_ID = "o4-mini"bedrock_runtime = boto3.client("bedrock-runtime", region_name=os.getenv("AWS_REGION"))
agent.py+20-15
requirements.txt+3
utils.py+1