Player not loading? Watch on YouTube
This tutorial builds a fruit store AI agent in a Python notebook with LangChain and LangGraph. The supplied metadata specifies Python 3.13 and GPT-4o-mini, with basic Python knowledge and an OpenAI API key as prerequisites. The example calls OpenAI's API; it does not demonstrate how to run models locally.
The setup uses uv to initialize the project and install LangChain, LangGraph, python-dotenv and langchain-openai. The presenter loads the API key from a .env file and warns against printing it in production. Fruit inventory and customer reviews live in Python dictionaries. Four functions expose inventory lookup, review lookup, file writing and file reading through the @tool decorator. The presenter explains how docstrings describe each tool's purpose to the model.
A system prompt, the model and the tools feed into create_agent(). LangGraph's InMemorySaver supplies conversation memory, with a thread ID identifying the chat. This memory lasts for the session rather than persisting after the project closes. A reusable use_agent() function invokes the agent and prints the final message. The walkthrough also corrects the model parameter name and the message input structure after errors.
The demonstration asks for a mango's price, writes its details to mango.txt and checks whether the agent recalls the previous question. Production database access and MCP connections appear as possible extensions, not implemented parts of this example.