Qscar KIM
update codes
19eab17
Raw
History Blame Contribute Delete
989 Bytes
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