File size: 1,434 Bytes
99ca1a9
b0394f8
99ca1a9
 
 
 
f1fb3af
e9720a2
 
 
f1fb3af
e5cbdce
a7ba1f0
e5cbdce
d604728
 
99ca1a9
f1fb3af
e9720a2
99ca1a9
 
 
 
 
d604728
99ca1a9
 
 
 
 
 
d604728
 
 
 
 
 
 
 
 
 
 
a7ba1f0
d604728
 
f1fb3af
e9720a2
 
 
f1fb3af
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os

import smolagents
import smolagents.models


def generate_code_writing_agent_with_tools(
    tools=None,
    name: str = "code_writing_agent_without_tools",
    description: str = "A code-writing agent without specialized tools.",
):
    """
    Create a code-writing agent wwith a specific set of tools (defaults to none)
    """
    if tools is None:
        tools = []
    return smolagents.CodeAgent(
        name=name,
        description=description,
        model=smolagents.models.OpenAIServerModel(
            model_id=os.getenv("AGENT_MODEL", ""),
            api_base=os.getenv("UPSTREAM_OPENAI_BASE", "").rstrip("/"),
            api_key=os.getenv("OPENAI_API_KEY"),
        ),
        tools=tools,
        add_base_tools=False,
        max_steps=4,
        verbosity_level=int(
            os.getenv("AGENT_VERBOSITY", "1")
        ),  # quieter by default; override via env
    )


def generate_code_writing_agent_without_tools():
    """
    Create a code-writing agent without any extra tools.
    """
    return generate_code_writing_agent_with_tools()


def generate_code_writing_agent_with_search():
    """
    Create a code-writing agent with search tools.
    """
    tools = [smolagents.WebSearchTool(max_results=5)]
    return generate_code_writing_agent_with_tools(
        tools,
        name="code_writing_agent_with_search",
        description="A code-writing agent with search tools.",
    )