LangChain Agents

Neil HaddleyAugust 25, 2024

Agents

Agents are systems that use LLMs as reasoning engines to determine which actions to take and the inputs to pass them. After executing actions, the results can be fed back into the LLM to determine whether more actions are needed, or whether it is okay to finish.

I created two LangChain Agents

I created a LangChain Agent that used Wikipedia

I created a LangChain Agent that used DuckDuckGo and a Maths tool

I created a new Jupyter Notebook

I created a new Jupyter Notebook

I created a new Python Environment

I created a new Python Environment

I clicked the + Create Python Environment link

I clicked the + Create Python Environment link

I clicked the Venv link

I clicked the Venv link

I selected Python 3.12.4

I selected Python 3.12.4

I used pip install

I used pip install

I imported dependencies

I imported dependencies

I ensured that an OPENAI_API_KEY could be relieved from the local .env file

I ensured that an OPENAI_API_KEY could be relieved from the local .env file

I created a large language model wrapper

I created a large language model wrapper

I ensured that I could access Wikipedia

I ensured that I could access Wikipedia

I created a prompt template

I created a prompt template

I created an agent, added the Wikipedia tool and invoked the agent (with verbose=True)

I created an agent, added the Wikipedia tool and invoked the agent (with verbose=True)

I created a second agent, added a maths tool and added DuckDuckGo

I created a second agent, added a maths tool and added DuckDuckGo

I invoked the second agent (with verbose=True)

I invoked the second agent (with verbose=True)