Skip to main content

`graph-topper` is a small extension to the `lang-graph` library that allows for graph definitions via decorators, bringing flow-control and logic to one place.

Project description

graph_topper

PyPI - Version

graph-topper is a small extension to the lang-graph library that allows for graph definitions via decorators, bringing flow-control and logic to one place.

Mostly a hobby project, but aims to fulfill all expectations of a fully fledged python library, such as clean code, tests, docs and a pypi release.


✨ Features

  • Define node logic and node connections in one place
  • Stops circular references in the graph via native python syntax (node directionality is implied by the order in which the methods are defined)
  • More compact graph definition (define node and incoming edges in one line)
  • Avoids error-prone string references (by using method names by default)
  • Retails all functionality of lang-graph

📦 Installation

pip install graph_topper

⚡ Quick Examples

Goal: construct the following graph

flowchart LR
    START --> a
    a --> b
    a --> c
    b --> END
    c --> check{check}
    check -.-> |"True"| END
    check -.-> |"False"| c

with graph_topper

from graph_topper import Topper
from langgraph.constants import END

from somewhere import State

topper = Topper(State)

@topper.node()
def a(state: State): ...

@topper.node(dependencies=[a])
def b(state: State): ...

@topper.node(dependencies=[a])
def c(state: State): ...

@topper.branch(c, {True: END, False: c})
def check(state: State): ...

without graph_topper

from langgraph.constants import END, START
from langgraph.graph import StateGraph

from somewhere import State

def a(state: State): ...

def b(state: State): ...

def c(state: State): ...

def check(state: State): ...

graph = StateGraph(State)
graph.add_node("a", a)
graph.add_node("b", b)
graph.add_node("c", c)

graph.add_edge(START, "a")
graph.add_edge("a", "b")
graph.add_edge("a", "c")

graph.add_conditional_edges("c", check, {True: END, False: "c"})

🤝 Contributing

Contributions are welcome! Feel free to open issues, suggest improvements, or submit pull requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graph_topper-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graph_topper-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file graph_topper-0.1.0.tar.gz.

File metadata

  • Download URL: graph_topper-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for graph_topper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca281aa76e695f264df34e3b7a330d84522def3138b874c52ec6ac6175add15e
MD5 f44c8150e40339d622b5b0d552eda71c
BLAKE2b-256 90c6bcc466675a58ce7b5d46a43c059a65ea31da293633857505e0b3bc72425e

See more details on using hashes here.

File details

Details for the file graph_topper-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for graph_topper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd3d8d03028354fa80ebf1faa9923c1739cbb9ed31d861fdaf31def0afa6ff46
MD5 9925ac13419e9f51894ba17632635fec
BLAKE2b-256 f37c09244d967c036c3906fee8dfac0aece5f188078701cc8123790439e9e0b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page