Using Opik with LangGraph
This notebook showcases how to use Opik with LangGraph. LangGraph is a library for building stateful, multi-actor applications with LLMs, used to create agent and multi-agent workflows
In this notebook, we will create a simple LangGraph workflow and focus on how to track it’s execution with Opik. To learn more about LangGraph, check out the official documentation.
Creating an account on Opik Cloud
Comet provides a hosted version of the Opik platform, simply create an account and grab you API Key.
You can also run the Opik platform locally, see the installation guide for more information.
Create the LangGraph graph
The LangGraph graph we will be created in made up of 3 nodes:
classify_input
: Classify the input questionhandle_greeting
: Handle the greeting questionhandle_search
: Handle the search question
Note: We will not be using any LLM calls or tools in this example to keep things simple. However in most cases, you will want to use tools to interact with external systems.
Calling the graph with Opik tracing enabled
In order to log the execution of the graph, we need to define the OpikTracer callback:
The graph execution is now logged on the Opik platform and can be viewed in the UI: