Parser for logs from LangGraph
Project description
LangGraph Log Parser
Documentation
Documentation is available at: https://serafinski.github.io/LangGraph-Log-Parser/
Purpose
This Python package facilitates the parsing of run logs generated by LangGraph. During execution, logs are stored in an SQLite database in an encoded format (using msgpack). These logs are then decoded and exported to a json format. Subsequently, the json files are transformed into csv files for further analysis.
Once in csv format, the data can be analyzed using methods from the py4pm library. These methods calculate specific statistics related to the multi-agent infrastructure's performance and enable visualizations of the process behavior and execution flow.
This pipeline provides a streamlined approach for extracting, transforming, and analyzing logs, offering valuable insights into multi-agent systems.
Installation
This package requires Python 3.9 or higher. Check below for more information on creating environment.
If you would like to develop this package, use poetry with Python 3.10 - since 3.10 is the needed minimum by Sphinx. Install needed dependencies with:
poetry install --with dev,test,docs
Prerequisites
This package requires Graphviz to be installed on your system.
Windows
Download the Graphviz installer from the Graphviz website.
macOS
Install Graphviz using Homebrew:
brew install graphviz
Linux
For Debian, Ubuntu, use the following command:
sudo apt-get install graphviz
For Fedora, Rocky Linux, RHEL or CentOS use the following command:
sudo dnf install graphviz
Environment setup
To create virtual environment (using conda), use the following commands:
conda create -n langgraph_log_parser python=3.9
conda activate langgraph_log_parser
pip install langgraph_log_parser
Basic Example
This example is based on the Building a Basic Chatbot from LangGraph documentation.
It will require You to install the following packages (besides langgraph_log_parser):
pip install python-dotenv langchain-openai
Example:
from dotenv import load_dotenv
from typing import Annotated
from typing_extensions import TypedDict
from langchain_openai import ChatOpenAI
from langgraph.graph import StateGraph, START, END
from langgraph.graph.message import add_messages
from langgraph_log_parser import *
exp = create_experiment("main")
memory = exp.memory
load_dotenv()
class State(TypedDict):
messages: Annotated[list, add_messages]
graph_builder = StateGraph(State)
llm = ChatOpenAI(model="gpt-4o-mini")
def chatbot(state: State):
return {"messages": [llm.invoke(state["messages"])]}
graph_builder.add_node("chatbot_node", chatbot)
graph_builder.add_edge(START, "chatbot_node")
graph_builder.add_edge("chatbot_node", END)
graph = graph_builder.compile(checkpointer=memory)
print()
run_multiple_iterations(graph, 1, 5, {"messages": [("user", "Tell me a joke")]})
print()
graph_config = GraphConfig(
nodes=["chatbot_node"]
)
prepare_data(exp, graph_config)
print()
event_log = load_event_log(exp)
print_analysis(event_log)
print()
generate_artifacts(event_log, graph, exp)
When You have multiple architectures analyzed, You can use the following code to compare them (by default, it will look in experiments directory):
from langgraph_log_parser import compare
infrastructures = ["main", "other1", "other2"]
compare(infrastructures)
This should generate a file in a comparison_reports directory, with the name: main_vs_other1_vs_other2.html.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langgraph_log_parser-0.1.14.tar.gz.
File metadata
- Download URL: langgraph_log_parser-0.1.14.tar.gz
- Upload date:
- Size: 47.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.1 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b654f83e9d4f73924e34682d027884a714a26f48e5c6f85fe34c83cabaa94b22
|
|
| MD5 |
b172d1e2b2fc1a2913cac1ff9673eac9
|
|
| BLAKE2b-256 |
5b23b2ddacda01f2e33527d08fa259c6f430a22682b343d0425361d40e566e08
|
File details
Details for the file langgraph_log_parser-0.1.14-py3-none-any.whl.
File metadata
- Download URL: langgraph_log_parser-0.1.14-py3-none-any.whl
- Upload date:
- Size: 52.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.1 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59b3d791e6638a8c997a5dec7338ee48528e44e91d02369935e9439c4ed15df6
|
|
| MD5 |
ee2ed5bd5bfb8f21ab8a66c2b3681f6f
|
|
| BLAKE2b-256 |
f4babf73d5360b340fc302ecc9d2a723c8cc37b4286c574321cb95ecae11a1d4
|