LangGraph
LangGraph is a framework for building reactive, multi-agent systems.
Quickstart
Confident AI provides a CallbackHandler
that can be used to trace LangGraph agent’s execution.
Install the following packages:
pip install -U deepeval langgraph langchain langchain-openai
Login with your API key and configure DeepEval’s CallbackHandler
as a callback for LangGraph:
main.py
import os
import time
from langgraph.prebuilt import create_react_agent
from deepeval.integrations.langchain.callback import CallbackHandler
import deepeval
os.environ["OPENAI_API_KEY"] = "<your-openai-api-key>"
deepeval.login_with_confident_api_key("<your-confident-api-key>")
def get_weather(city: str) -> str:
return f"It's always sunny in {city}!"
agent = create_react_agent(
model="openai:gpt-4o-mini",
tools=[get_weather],
prompt="You are a helpful assistant"
)
result = agent.invoke(
input = {"messages": [{"role": "user", "content": "what is the weather in sf"}]},
config = {"callbacks": [CallbackHandler()]}
)
time.sleep(5) # Wait for the trace to be published
Run your agent by executing the script:
python main.py
You can directly view the traces in the Observatory by clicking on the link in the output printed in the console.
💡
DeepEval’s CallbackHandler
is an implementation of LangChain’s BaseCallbackHandler
.
Last updated on