Skip to content

Commit

Permalink
Added notebook requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
MrtinoRG committed Jun 14, 2024
1 parent c4e40ab commit 51f52d6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
51 changes: 29 additions & 22 deletions agents/agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"metadata": {},
"source": [
"---\n",
"author: Martiño Ríos García\n",
"date: 2024-05-17\n",
"title: 5 | Agents\n",
"keep-ipynb: True\n",
"include-in-header:\n",
Expand All @@ -24,6 +22,15 @@
"---\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"::: {.callout-caution} \n",
"To run this notebook, it is recommended to have access to at least one GPU. With access to a GPU it took less than 5 minutes to run this notebook. The notebook can be run without access to a GPU, but the time will probably increase notably.\n",
":::"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -509,6 +516,24 @@
"Then we define the prompt, the agent and what it is called by LangChain as the \"chain\".\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"# Import the ReAct prompt from the hub.\n",
"prompt = hub.pull(\"hwchase17/react\")\n",
"# Construct the ReAct agent\n",
"agent = create_react_agent(llm, tools, prompt)\n",
"# Define the chain for the agent.\n",
"agent_executor = AgentExecutor(\n",
" agent=agent,\n",
" tools=tools,\n",
" verbose=True,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -538,29 +563,11 @@
"\n",
"What are the variables referred in this prompt?\\\n",
"\n",
"- `tools` include all the tools available with the `func`, `name`, `description` and `args_schema` detailed when creating the tool so the model know all the details about the tools.\\\n",
"- `tools` is a list with all the tools available. The list includes the `func`, `name`, `description` and `args_schema` arguments detailed when the tools were created.\\\n",
"- `tool_names` is a list with the names of the tools available.\\\n",
"- `input`is the query from the user.\\\n",
"- `agent_scratchpad` contains the previous iterations by the agent.\\\n",
":::\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"# Import the ReAct prompt from the hub.\n",
"prompt = hub.pull(\"hwchase17/react\")\n",
"# Construct the ReAct agent\n",
"agent = create_react_agent(llm, tools, prompt)\n",
"# Define the chain for the agent.\n",
"agent_executor = AgentExecutor(\n",
" agent=agent,\n",
" tools=tools,\n",
" verbose=True,\n",
")"
":::"
]
},
{
Expand Down
17 changes: 3 additions & 14 deletions finetune/choosing_paradigm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"metadata": {},
"source": [
"---\n",
"author: Martiño Ríos García\n",
"date: 2024-05-17\n",
"title: 4 | Choosing the learning paradigm\n",
"keep-ipynb: True\n",
"include-in-header:\n",
Expand All @@ -31,7 +29,7 @@
"metadata": {},
"source": [
"::: {.callout-caution}\n",
"To run this Notebook, you will need access to at least one GPU. The results that are printed were obtained using a single A100 graphic card with 80 GB of memory. Note that even using such a powerful GPU took the notebook more than 10 hours to complete.\n",
"To run this notebook, you will need access to at least one GPU. The results that are printed were obtained using a single A100 graphic card with 80 GB of memory. Note that even using such a powerful GPU took the notebook more than 10 hours to complete.\n",
":::"
]
},
Expand Down Expand Up @@ -84,19 +82,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "1777e540",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/kevinmaikjablonka/miniconda3/envs/dataextract/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"outputs": [],
"source": [
"import json \n",
"from dotenv import load_dotenv\n",
Expand Down

0 comments on commit 51f52d6

Please sign in to comment.