|
|
|
</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; |
|
} |
|
|
|
|
|
.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> |