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