feat: add src code
Browse files- smartagent_websearch (py).py +44 -0
smartagent_websearch (py).py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""SmartAgent-WebSearch
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colab.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1qPdXOAY8LSL2X2phmWvpvrdmuDQGsHpe
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
!pip install -U smolagents[toolkit]
|
| 11 |
+
|
| 12 |
+
!pip install smolagents # Install smolagents
|
| 13 |
+
|
| 14 |
+
!pip install --upgrade smolagents # Update smolagents to the latest version
|
| 15 |
+
|
| 16 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
|
| 17 |
+
|
| 18 |
+
# Inicialize o modelo
|
| 19 |
+
model = InferenceClientModel()
|
| 20 |
+
|
| 21 |
+
# Inicialize a ferramenta de busca
|
| 22 |
+
search_tool = DuckDuckGoSearchTool()
|
| 23 |
+
|
| 24 |
+
# Crie o agente com a ferramenta de busca
|
| 25 |
+
agent = CodeAgent(tools=[search_tool], model=model)
|
| 26 |
+
|
| 27 |
+
# Execute uma consulta
|
| 28 |
+
response = agent.run("Qual a altura do Cristo Redentor?")
|
| 29 |
+
print(response)
|
| 30 |
+
|
| 31 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
|
| 32 |
+
|
| 33 |
+
# Inicialize o modelo
|
| 34 |
+
model = InferenceClientModel()
|
| 35 |
+
|
| 36 |
+
# Inicialize a ferramenta de busca
|
| 37 |
+
search_tool = DuckDuckGoSearchTool()
|
| 38 |
+
|
| 39 |
+
# Crie o agente com a ferramenta de busca
|
| 40 |
+
agent = CodeAgent(tools=[search_tool], model=model)
|
| 41 |
+
|
| 42 |
+
# Execute uma consulta
|
| 43 |
+
response = agent.run("Quem foi Ada Lovelace?")
|
| 44 |
+
print(response)
|