From b62eb3a758b75029236c4e2410fa3cd52a8cca37 Mon Sep 17 00:00:00 2001 From: burtenshaw Date: Fri, 10 Jan 2025 09:43:31 +0100 Subject: [PATCH] update agents notebook with exercises --- 8_agents/notebooks/agents.ipynb | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/8_agents/notebooks/agents.ipynb b/8_agents/notebooks/agents.ipynb index 52bd1afe..7a09dec6 100644 --- a/8_agents/notebooks/agents.ipynb +++ b/8_agents/notebooks/agents.ipynb @@ -17,8 +17,17 @@ "cell_type": "code", "execution_count": null, "metadata": {}, + "outputs": [], "source": [ - "!pip install smolagents" + "!pip install smolagents\n", + "\n", + "# Install the requirements in Google Colab\n", + "# !pip install transformers datasets trl huggingface_hub\n", + "\n", + "# Authenticate to Hugging Face\n", + "from huggingface_hub import login\n", + "\n", + "login()" ] }, { @@ -34,6 +43,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, + "outputs": [], "source": [ "from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel\n", "\n", @@ -72,6 +82,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, + "outputs": [], "source": [ "from smolagents import CodeAgent, tool\n", "from typing import Union, List\n", @@ -137,17 +148,14 @@ "cell_type": "code", "execution_count": null, "metadata": {}, + "outputs": [], "source": [ "from smolagents import Agent\n", "from smolagents.tools import DuckDuckGoSearch\n", - "from smolagents.memory import SqliteMemory\n", "\n", "# Initialize the agent with memory\n", "research_agent = Agent(\n", - " name=\"research_assistant\",\n", - " description=\"I help find and synthesize information while maintaining context\",\n", - " tools=[DuckDuckGoSearch()],\n", - " memory=SqliteMemory(db_path=\"research_memory.db\")\n", + " ... # TODO: Define the agent\n", ")\n", "\n", "# Test with a multi-turn conversation\n", @@ -157,10 +165,7 @@ " \"What are some popular algorithms for this type?\"\n", "]\n", "\n", - "for question in questions:\n", - " print(f\"\\nQ: {question}\")\n", - " response = research_agent.run(question)\n", - " print(f\"A: {response}\")" + "# TODO: Test the agent " ] }, { @@ -180,5 +185,7 @@ "language": "python", "name": "python3" } - } -} \ No newline at end of file + }, + "nbformat": 4, + "nbformat_minor": 2 +}