File size: 1,122 Bytes
1aa16a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
35
import agent_tools
from smolagents import CodeAgent, FinalAnswerTool, DuckDuckGoSearchTool, AzureOpenAIServerModel
import app_tokens

model = AzureOpenAIServerModel(
    model_id = app_tokens.AZURE_OPENAI_MODEL,
    azure_endpoint = app_tokens.AZURE_OPENAI_ENDPOINT,
    api_key = app_tokens.AZURE_OPENAI_API_KEY,
    api_version = app_tokens.OPENAI_API_VERSION    
)

class BasicAgent:
    def __init__(self):
        self.web_agent = CodeAgent(
            model=model,
            tools=[agent_tools.VisitWebpageTool(), FinalAnswerTool(), DuckDuckGoSearchTool()],
            max_steps=8,
            name="web_agent",
            description="Runs web searches for you."
        )
        
        self.manager_agent = CodeAgent(
            model=model,
            tools=[],
            managed_agents=[self.web_agent],
            additional_authorized_imports=["json","pandas","numpy", "regex"],
            planning_interval=5,
            verbosity_level=2,
            max_steps=12,
        )

    def forward(self, question: str) -> str:
        result = self.manager_agent.run(question)
        return result