File size: 3,889 Bytes
04d137a
 
 
628ab99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04d137a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628ab99
 
 
 
 
04d137a
 
 
 
 
 
 
 
 
57c9aa7
04d137a
628ab99
 
 
 
 
 
 
 
 
04d137a
 
 
 
57c9aa7
04d137a
628ab99
 
 
 
 
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

</style>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Basic Example with run model using Smolagents</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .container {
            display: flex;
            flex-wrap: wrap;
            min-height: 100vh;
        }
        .split-section {
            flex: 1 1 50%;
            padding: 2rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .left-section {
            background-color: #f0f0f0;
        }
        .right-section {
            background-color: #e0e0e0;
        }
        .content {
            max-width: 600px;
        }
        @media (max-width: 768px) {
            .split-section {
                flex-basis: 100%;
                min-height: 50vh;
            }
        }

.code {
    display: inline;
    background-color: #f3f4f6;
    color: #dc2626;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9em;
    line-height: 1.5;
    vertical-align: baseline;
}

/* Color variations */
.code.blue { color: #2563eb; background-color: #dbeafe; border-color: #bfdbfe; }
.code.green { color: #059669; background-color: #d1fae5; border-color: #a7f3d0; }
.code.purple { color: #7c3aed; background-color: #ede9fe; border-color: #ddd6fe; }
.code.yellow { color: #8a6600; background-color: #fff7d1; border-color: #ece2a8; }
.code.orange { color: #b33c00; background-color: #ffe8d9; border-color: #ffd0b8; }
.code.teal { color: #006d6d; background-color: #d4f3f3; border-color: #a8e0e0; }
.code.pink { color: #9d174d; background-color: #fce7f3; border-color: #fbcfe8; }
    </style>
</head>
<body>
    <div class="container">
        <div class="split-section left-section">
            <div class="content code yellow">
                <h2 class="">Offline "smolagents" usage example:</h2><br>
                <code class="code green">from smolagents import CodeAgent,</code><code class="code yellow">TransformersModel,</code><code class="code green">DuckDuckGoSearchTool</code><br><br>
                <code class="code green">model_path = </code><code class="code yellow">'usr/Qwen3-4B' #or 'C:/model/Qwen3-4B'</code> <code class="code orange">#(Path to model files usually .safetensors)</code><br><br>
                <code class="code purple">model = TransformersModel(
				model_id=model_path,
				max_new_tokens=4096,
				device_map="auto"
				)</code><br><br>
                <code class="code green">agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=</code><code class="code purple">model</code><code class="code green">)</code><br><br>
                <code class="code green">agent.run("Is it good today?")</code>
            </div>
        </div>
        





        <div class="split-section right-section">
            <div class="content code yellow">
                <h2>Online "smolagents" usage example:</h2><br>
                <code class="code green">from smolagents import CodeAgent, </code><code class="code yellow">HfApiModel,</code><code class="code green">DuckDuckGoSearchTool</code><br><br>
                <code class="code green">model_path = </code><code class="code yellow">'Qwen/Qwen3-4B'</code><code class="code orange">#(Path to model space)</code><br><br>
                <code class="code green">agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=</code><code class="code purple">HfApiModel(model_path)</code><code class="code green">)</code><br><br>
                <code class="code green">agent.run("Is it good today?")</code>
            </div>
        </div>
    </div>
</body>
</html>