Skip to content

Commit 2fcb347

Browse files
committed
feat(agents)✨: Add notebook demonstrating AgentBot usage with tools and models
- Create 'agents.ipynb' showing how to use AgentBot with write_and_execute_script and search_internet_and_summarize. - Include examples for summarizing album ratings, training a classifier, and sports predictions. - Add 'devstral' model to ollama_model_names.txt for new model support.
1 parent 7c3dc11 commit 2fcb347

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

llamabot/bot/ollama_model_names.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
devstral
12
qwen2.5vl
23
phi4-reasoning
34
phi4-mini-reasoning

notebooks/agents.ipynb

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"%load_ext autoreload\n",
10+
"%autoreload 2"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"import llamabot as lmb\n"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"from llamabot.components.tools import (\n",
29+
" search_internet_and_summarize,\n",
30+
" write_and_execute_script,\n",
31+
")\n",
32+
"\n",
33+
"\n",
34+
"agent = lmb.AgentBot(\n",
35+
" tools=[write_and_execute_script],\n",
36+
" model_name=\"gpt-4.1-mini\",\n",
37+
")\n"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": null,
43+
"metadata": {},
44+
"outputs": [],
45+
"source": [
46+
"response = agent(\"Summarize for me the latest ratings of Taylor Swfit's latest album.\")"
47+
]
48+
},
49+
{
50+
"cell_type": "markdown",
51+
"metadata": {},
52+
"source": [
53+
"Now, let's try providing explicitly the `search_internet_and_summarize` tool."
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": null,
59+
"metadata": {},
60+
"outputs": [],
61+
"source": [
62+
"agent = lmb.AgentBot(\n",
63+
" tools=[write_and_execute_script, search_internet_and_summarize],\n",
64+
" model_name=\"gpt-4.1-mini\",\n",
65+
")\n"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": null,
71+
"metadata": {},
72+
"outputs": [],
73+
"source": [
74+
"response = agent(\"Summarize for me the latest ratings of Taylor Swfit's latest album.\")"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": null,
80+
"metadata": {},
81+
"outputs": [],
82+
"source": [
83+
"response = agent(\"Download the red wine quality dataset from https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv. Use the provided column headers. Train a random forest classifier with 100 trees and a maximum depth of 5 to predict the 'quality' column using the other features. Perform 5-fold cross-validation and return the mean and standard deviation of the accuracy.\")\n"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"metadata": {},
90+
"outputs": [],
91+
"source": [
92+
"print(response.content)\n"
93+
]
94+
},
95+
{
96+
"cell_type": "code",
97+
"execution_count": null,
98+
"metadata": {},
99+
"outputs": [],
100+
"source": [
101+
"response = agent(\"What are the predictions for Man Utd's europa league final game?\")"
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": null,
107+
"metadata": {},
108+
"outputs": [],
109+
"source": [
110+
"print(response.content)"
111+
]
112+
},
113+
{
114+
"cell_type": "code",
115+
"execution_count": null,
116+
"metadata": {},
117+
"outputs": [],
118+
"source": [
119+
"response = agent(\"What were the predictions for Man Utd's 1999 Champions League final?\")"
120+
]
121+
}
122+
],
123+
"metadata": {
124+
"kernelspec": {
125+
"display_name": "default",
126+
"language": "python",
127+
"name": "python3"
128+
},
129+
"language_info": {
130+
"codemirror_mode": {
131+
"name": "ipython",
132+
"version": 3
133+
},
134+
"file_extension": ".py",
135+
"mimetype": "text/x-python",
136+
"name": "python",
137+
"nbconvert_exporter": "python",
138+
"pygments_lexer": "ipython3",
139+
"version": "3.12.10"
140+
}
141+
},
142+
"nbformat": 4,
143+
"nbformat_minor": 2
144+
}

0 commit comments

Comments
 (0)