|
<!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; |
|
} |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="container"> |
|
<div class="split-section left-section"> |
|
<div class="content"> |
|
<h2>Offline "smolagents" usage example:</h2> |
|
<p>from smolagents import CodeAgent, TransformersModel,DuckDuckGoSearchTool</p> |
|
<p>model_path = 'usr/Qwen3-4B-Instruct' #or 'C:/model/Qwen3-4B-Instruct' #(Path to model files usually .safetensors)</p> |
|
<p>model = TransformersModel(model_id=model_path,max_new_tokens=4096,device_map="auto")</p> |
|
<p>agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model) #offline #uses TransformersModel</p> |
|
<p>agent.run("Is it good today?")</p> |
|
</div> |
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="split-section right-section"> |
|
<div class="content"> |
|
<h2>Online "smolagents" usage example:</h2> |
|
<p>from smolagents import CodeAgent, HfApiModel,DuckDuckGoSearchTool</p> |
|
<p>model_path = 'huihui-ai/Qwen3-4B-abliterated' #HFspace online</p> |
|
<p>agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel(model_path)) #online</p> |
|
<p>agent.run("Is it good today?")</p> |
|
</div> |
|
</div> |
|
</div> |
|
</body> |
|
</html> |