|
15 | 15 | "metadata": {}, |
16 | 16 | "outputs": [], |
17 | 17 | "source": [ |
18 | | - "from logging import DEBUG\n", |
19 | | - "\n", |
20 | | - "from llm_agents_from_scratch import LLMAgent\n", |
21 | | - "from llm_agents_from_scratch.logger import get_logger, set_log_level\n", |
22 | | - "\n", |
23 | | - "set_log_level(DEBUG)\n", |
24 | | - "nb_logger = get_logger(\"notebook\")" |
| 18 | + "from llm_agents_from_scratch import LLMAgent" |
25 | 19 | ] |
26 | 20 | }, |
27 | 21 | { |
|
172 | 166 | { |
173 | 167 | "cell_type": "code", |
174 | 168 | "execution_count": 9, |
175 | | - "id": "4d09a484-9eb7-4525-923e-d00ebfe0434a", |
| 169 | + "id": "c3a940e0-3fb0-43e9-8858-f5277a79df37", |
176 | 170 | "metadata": {}, |
177 | 171 | "outputs": [], |
178 | 172 | "source": [ |
179 | | - "from llm_agents_from_scratch.data_structures.agent import Task" |
| 173 | + "LOGGING_ENABLED = True" |
180 | 174 | ] |
181 | 175 | }, |
182 | 176 | { |
183 | 177 | "cell_type": "code", |
184 | 178 | "execution_count": 10, |
| 179 | + "id": "bfb51e69-ea36-495d-bcc1-fc7d164b6d40", |
| 180 | + "metadata": {}, |
| 181 | + "outputs": [], |
| 182 | + "source": [ |
| 183 | + "import logging\n", |
| 184 | + "\n", |
| 185 | + "from llm_agents_from_scratch.logger import enable_console_logging\n", |
| 186 | + "\n", |
| 187 | + "if LOGGING_ENABLED:\n", |
| 188 | + " enable_console_logging(logging.INFO)" |
| 189 | + ] |
| 190 | + }, |
| 191 | + { |
| 192 | + "cell_type": "code", |
| 193 | + "execution_count": 11, |
| 194 | + "id": "4d09a484-9eb7-4525-923e-d00ebfe0434a", |
| 195 | + "metadata": {}, |
| 196 | + "outputs": [], |
| 197 | + "source": [ |
| 198 | + "from llm_agents_from_scratch.data_structures import Task" |
| 199 | + ] |
| 200 | + }, |
| 201 | + { |
| 202 | + "cell_type": "code", |
| 203 | + "execution_count": 12, |
185 | 204 | "id": "1d5d512e-d400-4398-980f-a4142d367add", |
186 | 205 | "metadata": {}, |
187 | 206 | "outputs": [], |
|
193 | 212 | }, |
194 | 213 | { |
195 | 214 | "cell_type": "code", |
196 | | - "execution_count": 11, |
| 215 | + "execution_count": 13, |
197 | 216 | "id": "e99cca54-0d21-4c9d-9a17-bf595d110fe5", |
198 | 217 | "metadata": {}, |
199 | 218 | "outputs": [ |
|
202 | 221 | "output_type": "stream", |
203 | 222 | "text": [ |
204 | 223 | "INFO (llm_agents_fs.LLMAgent) : 🚀 Starting task: Add one to fifty-five point three. Use an appropriate tool!\n", |
205 | | - "DEBUG (llm_agents_fs.TaskHandler) : 🧵 Rollout: \n", |
206 | | - "INFO (llm_agents_fs.TaskHandler) : 🧠 New Step: Add one to fifty-five point three. Use an appropriate tool!\n", |
207 | 224 | "INFO (llm_agents_fs.TaskHandler) : ⚙️ Processing Step: Add one to fifty-five point three. Use an appropriate tool!\n", |
208 | | - "DEBUG (llm_agents_fs.TaskHandler) : 🧵 Rollout: \n", |
209 | | - "DEBUG (llm_agents_fs.TaskHandler) : 💬 SYSTEM: You are a helpful assistant.\n", |
210 | | - "DEBUG (llm_agents_fs.TaskHandler) : 💬 USER: Add one to fifty-five point three. Use an appropriate tool!\n", |
211 | | - "DEBUG (llm_agents_fs.TaskHandler) : 💬 ASSISTANT: \n", |
212 | | - "INFO (llm_agents_fs.TaskHandler) : 🛠️ Executing Tool Call: add_one\n", |
213 | | - "INFO (llm_agents_fs.TaskHandler) : ✅ Successful Tool Call: 56.3\n", |
214 | | - "INFO (llm_agents_fs.TaskHandler) : ✅ Step Result: After adding one to fifty-five point three, the result is 56.3.\n", |
215 | | - "DEBUG (llm_agents_fs.TaskHandler) : 🧵 Rollout: user: Add one to fifty-five point three. Use an appropriate tool!\n", |
216 | | - "assistant: I need to make a tool call(s) to add_one\n", |
217 | | - "tool: \n", |
218 | | - "The below is a tool call response for a given tool call.\n", |
219 | | - "<tool-call>\n", |
220 | | - "tool name: add_one\n", |
221 | | - "arguments: {'x': '55.3'}\n", |
222 | | - "</tool-call>\n", |
223 | | - "\n", |
224 | | - "<result>\n", |
225 | | - "56.3\n", |
226 | | - "</result>\n", |
227 | | - "\n", |
228 | | - "assistant: After adding one to fifty-five point three, the result is 56.3.\n", |
229 | | - "INFO (llm_agents_fs.TaskHandler) : 🧠 New Step: There is sufficient context to complete the task within the provided history — another tool call may not even be necessary! Proceed with completion and mark this as the last step. NOTE: that the real user has not seen this dialogue, and so just provide the final task result without referencing it.\n", |
230 | | - "INFO (llm_agents_fs.TaskHandler) : ⚙️ Processing Step: There is sufficient context to complete the task within the provided history — another tool call may not even be necessary! Proceed with completion and mark this as the last step. NOTE: that the real user has not seen this dialogue, and so just provide the final task result without referencing it.\n", |
231 | | - "DEBUG (llm_agents_fs.TaskHandler) : 🧵 Rollout: user: Add one to fifty-five point three. Use an appropriate tool!\n", |
232 | | - "assistant: I need to make a tool call(s) to add_one\n", |
233 | | - "tool: \n", |
234 | | - "The below is a tool call response for a given tool call.\n", |
235 | | - "<tool-call>\n", |
236 | | - "tool name: add_one\n", |
237 | | - "arguments: {'x': '55.3'}\n", |
238 | | - "</tool-call>\n", |
239 | | - "\n", |
240 | | - "<result>\n", |
241 | | - "56.3\n", |
242 | | - "</result>\n", |
243 | | - "\n", |
244 | | - "assistant: After adding one to fifty-five point three, the result is 56.3.\n", |
245 | | - "DEBUG (llm_agents_fs.TaskHandler) : 💬 SYSTEM: You are a helpful assistant.\n", |
246 | | - "\n", |
247 | | - "Here is some past dialogue and context, where another assistant was working\n", |
248 | | - "towards completing the task.\n", |
249 | | - "\n", |
250 | | - "<history>\n", |
251 | | - "user: Add one to fifty-five point three. Use an appropriate tool!\n", |
252 | | - "assistant: I need to make a tool call(s) to add_one\n", |
253 | | - "tool: \n", |
254 | | - "The below is a tool call response for a given tool call.\n", |
255 | | - "<tool-call>\n", |
256 | | - "tool name: add_one\n", |
257 | | - "arguments: {'x': '55.3'}\n", |
258 | | - "</tool-call>\n", |
259 | | - "\n", |
260 | | - "<result>\n", |
261 | | - "56.3\n", |
262 | | - "</result>\n", |
263 | | - "\n", |
264 | | - "assistant: After adding one to fifty-five point three, the result is 56.3.\n", |
265 | | - "</history>\n", |
266 | | - "\n", |
267 | | - "DEBUG (llm_agents_fs.TaskHandler) : 💬 USER: There is sufficient context to complete the task within the provided history — another tool call may not even be necessary! Proceed with completion and mark this as the last step. NOTE: that the real user has not seen this dialogue, and so just provide the final task result without referencing it.\n", |
268 | | - "DEBUG (llm_agents_fs.TaskHandler) : 💬 ASSISTANT: \n", |
269 | 225 | "INFO (llm_agents_fs.TaskHandler) : 🛠️ Executing Tool Call: add_one\n", |
270 | 226 | "INFO (llm_agents_fs.TaskHandler) : ✅ Successful Tool Call: 56.3\n", |
271 | | - "INFO (llm_agents_fs.TaskHandler) : ✅ Step Result: After adding one to fifty-five point three, the result is 56.3.\n", |
272 | | - "INFO (llm_agents_fs.LLMAgent) : 🏁 Task completed: After adding one to fifty-five point three, the result is 56.3.\n" |
| 227 | + "INFO (llm_agents_fs.TaskHandler) : ✅ Step Result: Adding one to fifty-five point three gives us fifty-six point three.\n", |
| 228 | + "INFO (llm_agents_fs.TaskHandler) : No new step required.\n", |
| 229 | + "INFO (llm_agents_fs.LLMAgent) : 🏁 Task completed: Adding one to fifty-five point three gives us fifty-six point three.\n" |
273 | 230 | ] |
274 | 231 | } |
275 | 232 | ], |
|
279 | 236 | }, |
280 | 237 | { |
281 | 238 | "cell_type": "code", |
282 | | - "execution_count": 12, |
| 239 | + "execution_count": 14, |
283 | 240 | "id": "0fde7c61-f0d9-4ef9-b0b6-90386667bbb8", |
284 | 241 | "metadata": {}, |
285 | 242 | "outputs": [ |
286 | 243 | { |
287 | | - "data": { |
288 | | - "text/plain": [ |
289 | | - "TaskResult(task=Task(instruction='Add one to fifty-five point three. Use an appropriate tool!'), content='After adding one to fifty-five point three, the result is 56.3.', rollout=\"user: Add one to fifty-five point three. Use an appropriate tool!\\nassistant: I need to make a tool call(s) to add_one\\ntool: \\nThe below is a tool call response for a given tool call.\\n<tool-call>\\ntool name: add_one\\narguments: {'x': '55.3'}\\n</tool-call>\\n\\n<result>\\n56.3\\n</result>\\n\\nassistant: After adding one to fifty-five point three, the result is 56.3.user: There is sufficient context to complete the task within the provided history — another tool call may not even be necessary! Proceed with completion and mark this as the last step. NOTE: that the real user has not seen this dialogue, and so just provide the final task result without referencing it.\\nassistant: I need to make a tool call(s) to add_one\\ntool: \\nThe below is a tool call response for a given tool call.\\n<tool-call>\\ntool name: add_one\\narguments: {'x': '55.3'}\\n</tool-call>\\n\\n<result>\\n56.3\\n</result>\\n\\nassistant: After adding one to fifty-five point three, the result is 56.3.\", error=False)" |
290 | | - ] |
291 | | - }, |
292 | | - "execution_count": 12, |
293 | | - "metadata": {}, |
294 | | - "output_type": "execute_result" |
| 244 | + "name": "stdout", |
| 245 | + "output_type": "stream", |
| 246 | + "text": [ |
| 247 | + "The result is fifty-six point three.\n" |
| 248 | + ] |
295 | 249 | } |
296 | 250 | ], |
297 | 251 | "source": [ |
298 | | - "result" |
| 252 | + "print(result.task_result)" |
299 | 253 | ] |
300 | 254 | }, |
301 | 255 | { |
302 | 256 | "cell_type": "code", |
303 | | - "execution_count": null, |
| 257 | + "execution_count": 15, |
304 | 258 | "id": "93b1cfa1-1ac0-420d-b36e-007de5cdfc7f", |
305 | 259 | "metadata": {}, |
| 260 | + "outputs": [ |
| 261 | + { |
| 262 | + "name": "stdout", |
| 263 | + "output_type": "stream", |
| 264 | + "text": [ |
| 265 | + "assistant: Add one to fifty-five point three. Use an appropriate tool!\n", |
| 266 | + "assistant: I need to make a tool call(s) to add_one\n", |
| 267 | + "tool: {\n", |
| 268 | + " \"tool_call\": {\n", |
| 269 | + " \"tool_name\": \"add_one\",\n", |
| 270 | + " \"arguments\": {\n", |
| 271 | + " \"x\": \"55.3\"\n", |
| 272 | + " }\n", |
| 273 | + " },\n", |
| 274 | + " \"content\": \"56.3\",\n", |
| 275 | + " \"error\": false\n", |
| 276 | + "}\n", |
| 277 | + "assistant: Adding one to fifty-five point three gives us fifty-six point three.\n" |
| 278 | + ] |
| 279 | + } |
| 280 | + ], |
| 281 | + "source": [ |
| 282 | + "print(result.rollout)" |
| 283 | + ] |
| 284 | + }, |
| 285 | + { |
| 286 | + "cell_type": "code", |
| 287 | + "execution_count": null, |
| 288 | + "id": "e1a01698-dcdc-4796-a41b-6029eafa9ab5", |
| 289 | + "metadata": {}, |
306 | 290 | "outputs": [], |
307 | 291 | "source": [] |
308 | 292 | } |
|
0 commit comments