Designing Agentic Systems with LangChain
Dilini K. Sumanapala, PhD
Founder & AI Engineer, Genverv Ltd.
# Module imports
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
import math
# LLM Setup model = ChatOpenAI(openai_api_key="<OPENAI_API_TOKEN">, model="gpt-4o-mini")
# Create the agent agent = create_react_agent(model, tools)
# Create a query query = "What is (2+8) multiplied by 9?"
# Invoke the agent and print the response response = agent.invoke({"messages": [("human", query)]})
# Print the agent's response print(response['messages'][-1].content)
<script.py> output:
The result of (2 + 8) multiplied by 9 is 90.
Designing Agentic Systems with LangChain