Visualization UML diagram tool for LangChain workflows
Subscribe to events using a callback and store them in PlantUML format to easily visualize LangChain workflow in Activity Diagram and Sequence Diagram. You can easily subscribe to events and keep them in a form that is easy to visualize and analyze using PlantUML.
Activity Diagram
Sequence Diagram
Quick Start
Install this library:
pip install langchain-plantuml
Then:
- Add import langchain_plantuml as the first import in your Python entrypoint file
- Create a callback using the activity_diagram_callback function
- Hook into your LLM application
- Call the export_uml_content method of activity_diagram_callback to export the PlantUML content
- Save PlantUML content to a file
- Exporting PlantUML to PNG
Running the minimal activity diagram example.
from langchain import OpenAI, LLMChain, PromptTemplate
from langchain.memory import ConversationBufferMemory
from langchain_plantuml import diagram
template = """You are a chatbot having a conversation with a human.
{chat_history}
Human: {human_input}
Chatbot:"""
prompt = PromptTemplate(
input_variables=["chat_history", "human_input"], template=template
)
memory = ConversationBufferMemory(memory_key="chat_history")
activity_diagram = diagram.activity_diagram_callback(note_max_length=2000)
sequence_diagram = diagram.sequence_diagram_callback(note_max_length=2000)
llm_chain = LLMChain(
llm=OpenAI(),
prompt=prompt,
verbose=True,
memory=memory,
callbacks=[activity_diagram, sequence_diagram]
)
try:
llm_chain.predict(human_input="What did biden say about ketanji brown jackson in the state of the union address?")
finally:
activity_diagram.save_uml_content("example_1_activity-plantuml.puml")
sequence_diagram.save_uml_content("example_1_sequence-plantuml.puml")
You will get the following PlantUML activity diagram
Sequence Diagram
callback_handler = diagram.sequence_diagram_callback()
Custom note max Length(default 1000)
callback_handler = diagram.activity_diagram_callback(note_max_length=2000)
Custom note wrap width(default 500)
callback_handler = diagram.activity_diagram_callback(note_wrap_width=500)
Exporting PlantUML to PNG
You can download plantuml.1.2023.10.jar
java -DPLANTUML_LIMIT_SIZE=81920 -jar plantuml-1.2023.10.jar example-activity.puml
Metadata
Release files for langchain-plantuml 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_plantuml-0.0.8.tar.gz | 11.0 kB | Without provenance | Details for langchain_plantuml-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_plantuml-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for langchain_plantuml-0.0.8-py3-none-any.whl |
Total release size: 26.4 kB
Release files / langchain_plantuml-0.0.8.tar.gz
| Download URL | langchain_plantuml-0.0.8.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98922ce4a388aa09e7cc93ddce9440166c634e079254802a3afb93b38e89e818
|
|
BLAKE2b-256 checksum How to use checksums |
337e3a6468b893c2529d2d0306da2cb1225a0957843257978b70b3e3b5564ade
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / langchain_plantuml-0.0.8-py3-none-any.whl
| Download URL | langchain_plantuml-0.0.8-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f3aea08e9e9e996de0a4d2cf7b7610030d8e55d007ece1e6734a2d759a49ff9
|
|
BLAKE2b-256 checksum How to use checksums |
2b1530a92fb375ce38ab7fcca4b9460f2b23a69f11b95eb8de454521298bdda0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for langchain-plantuml 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.