Spaces:
Sleeping
Sleeping
| 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 |