import os from smolagents import CodeAgent, HfApiClientModel, Tool from langchain_community.tools import DuckDuckGoSearchRun class WebSearchTool(Tool): name = "web_search" description = "인터넷에서 최신 정보나 지식을 검색할 때 사용합니다." inputs = {"query": {"type": "string", "description": "검색할 단어나 문장"}} output_type = "string" def __init__(self): super().__init__() self.search = DuckDuckGoSearchRun() def forward(self, query: str) -> str: try: return self.search.run(query) except Exception as e: return f"검색 실패: {str(e)}" def create_gaia_agent(): model = HfApiClientModel( model_id="Qwen/Qwen2.5-Coder-32B-Instruct" ) search_tool = WebSearchTool() agent = CodeAgent( tools=[search_tool], model=model, additional_authorized_imports=["pandas", "numpy", "json", "math", "re"] ) return agent