Skip to content

Commit

Permalink
update agents notebook with exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
burtenshaw committed Jan 10, 2025
1 parent 76e273d commit b62eb3a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions 8_agents/notebooks/agents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
]
},
{
Expand All @@ -34,6 +43,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel\n",
"\n",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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 "
]
},
{
Expand All @@ -180,5 +185,7 @@
"language": "python",
"name": "python3"
}
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit b62eb3a

Please sign in to comment.