Python SDK for DuraGraph - Reliable AI Workflow Orchestration
Project description
DuraGraph Python SDK
Python SDK for DuraGraph - Reliable AI Workflow Orchestration.
Build AI agents with decorators, deploy to a control plane, and get full observability out of the box.
Installation
The package is published as duragraph-python on PyPI. We recommend uv for dependency management.
# With uv (recommended)
uv add duragraph-python
uv add 'duragraph-python[openai]'
uv add 'duragraph-python[anthropic]'
uv add 'duragraph-python[all]'
# With pip
pip install duragraph-python
Quick Start
from duragraph import Graph, llm_node, entrypoint
@Graph(id="customer_support")
class CustomerSupportAgent:
"""A customer support agent that classifies and responds to queries."""
@entrypoint
@llm_node(model="gpt-4o-mini")
def classify(self, state):
"""Classify the customer intent."""
return {"intent": "billing"}
@llm_node(model="gpt-4o-mini")
def respond(self, state):
"""Generate a response based on intent."""
return {"response": f"I'll help you with {state['intent']}."}
# Define flow
classify >> respond
# Run locally
agent = CustomerSupportAgent()
result = agent.run({"message": "I have a billing question"})
print(result)
# Or deploy to control plane
agent.serve("http://localhost:8081")
Features
Decorator-Based Graph Definition
from duragraph import Graph, llm_node, tool_node, router_node, human_node
@Graph(id="my_agent")
class MyAgent:
@llm_node(model="gpt-4o-mini", temperature=0.7)
def process(self, state):
return state
@tool_node
def search(self, state):
results = my_search_function(state["query"])
return {"results": results}
@router_node
def route(self, state):
return "path_a" if state["condition"] else "path_b"
@human_node(prompt="Please review")
def review(self, state):
return state
Streaming
async for event in agent.stream({"message": "Hello"}):
if event.type == "token":
print(event.data, end="")
elif event.type == "node_completed":
print(f"\nNode {event.node_id} completed")
Subgraphs
@Graph(id="research")
class ResearchAgent:
@llm_node
def research(self, state):
return {"findings": "..."}
@Graph(id="main")
class MainAgent:
research = ResearchAgent.as_subgraph()
@entrypoint
def plan(self, state):
return state
plan >> research
Requirements
- Python 3.10+
- DuraGraph Control Plane (for deployment)
Documentation
Related Repositories
| Repository | Description |
|---|---|
| duragraph | Core API server |
Go SDK (go-sdk/) |
Go SDK |
| duragraph-examples | Example projects |
| duragraph-docs | Documentation |
Contributing
See CONTRIBUTING.md for guidelines.
License
Apache 2.0 - See LICENSE for details.
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
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 duragraph-0.3.0.tar.gz.
File metadata
- Download URL: duragraph-0.3.0.tar.gz
- Upload date:
- Size: 324.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a3ce488fb835c1d524bee49289315ca2899dbae9bc42b900dabbdb54cc06827
|
|
| MD5 |
c553d49a40ee7332f67081abb112f11c
|
|
| BLAKE2b-256 |
a40137752cd535209262761ffb6ff04f2bc6fc3ba73854d3b233006f24ece0fd
|
Provenance
The following attestation bundles were made for duragraph-0.3.0.tar.gz:
Publisher:
pypi.yml on Duragraph/duragraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
duragraph-0.3.0.tar.gz -
Subject digest:
6a3ce488fb835c1d524bee49289315ca2899dbae9bc42b900dabbdb54cc06827 - Sigstore transparency entry: 1490771325
- Sigstore integration time:
-
Permalink:
Duragraph/duragraph@08a59035bfa936e5b647e243890b753b67376dc0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Duragraph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@08a59035bfa936e5b647e243890b753b67376dc0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file duragraph-0.3.0-py3-none-any.whl.
File metadata
- Download URL: duragraph-0.3.0-py3-none-any.whl
- Upload date:
- Size: 82.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
047ab8dd71228908f3fc0073eb3bf814733a76bcc15df1e7bca9d193c7521a71
|
|
| MD5 |
ac16515ab673c8ab5307c6d4a1021275
|
|
| BLAKE2b-256 |
bcdef055ecfc307d6437155196945936a94f47ca8c4a1f40d194f1f1853e96d2
|
Provenance
The following attestation bundles were made for duragraph-0.3.0-py3-none-any.whl:
Publisher:
pypi.yml on Duragraph/duragraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
duragraph-0.3.0-py3-none-any.whl -
Subject digest:
047ab8dd71228908f3fc0073eb3bf814733a76bcc15df1e7bca9d193c7521a71 - Sigstore transparency entry: 1490771461
- Sigstore integration time:
-
Permalink:
Duragraph/duragraph@08a59035bfa936e5b647e243890b753b67376dc0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Duragraph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@08a59035bfa936e5b647e243890b753b67376dc0 -
Trigger Event:
workflow_dispatch
-
Statement type: