Spaces:
Sleeping
Sleeping
File size: 989 Bytes
19eab17 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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 |