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
pip install duragraph-python
# With OpenAI support
pip install duragraph-python[openai]
# With Anthropic support
pip install duragraph-python[anthropic]
# All features
pip install duragraph-python[all]
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
Prompt Management
from duragraph.prompts import prompt
@llm_node(model="gpt-4o-mini")
@prompt("support/classify_intent", version="2.1.0")
def classify(self, state):
# Prompt is fetched from prompt store automatically
return state
Streaming
async for event in agent.stream({"message": "Hello"}):
if event.type == "token":
print(event.data, end="")
elif event.type == "node_complete":
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
CLI
# Initialize new project
duragraph init my-agent
# Run locally in development mode
duragraph dev
# Deploy to control plane
duragraph deploy --control-plane http://localhost:8081
# Visualize graph
duragraph visualize my_agent.py
Configuration
# pyproject.toml
[tool.duragraph]
control_plane = "http://localhost:8081"
[tool.duragraph.llm]
default_model = "gpt-4o-mini"
[tool.duragraph.llm.providers.openai]
api_key = "${OPENAI_API_KEY}"
Documentation
Requirements
- Python 3.10+
- DuraGraph Control Plane (for deployment)
Contributing
Contributions are welcome! Please read our Contributing Guide.
License
Apache 2.0 - see LICENSE for details.
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 duragraph_python-0.1.0.tar.gz.
File metadata
- Download URL: duragraph_python-0.1.0.tar.gz
- Upload date:
- Size: 110.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d375b3ac008012f3fd55cc06cb54fb272c67ba85893830926d4151d3c0e7e40
|
|
| MD5 |
1c1a3fc33a9e286716002709298bdcf9
|
|
| BLAKE2b-256 |
66a21b08b7b44ca8be60a8fbee6f6f887c7f6c7ed08a211ff5bd881ac7c93ced
|
Provenance
The following attestation bundles were made for duragraph_python-0.1.0.tar.gz:
Publisher:
publish.yml on Duragraph/duragraph-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
duragraph_python-0.1.0.tar.gz -
Subject digest:
3d375b3ac008012f3fd55cc06cb54fb272c67ba85893830926d4151d3c0e7e40 - Sigstore transparency entry: 781110916
- Sigstore integration time:
-
Permalink:
Duragraph/duragraph-python@665ea13b032812a82bd91ce4929e36c954494264 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Duragraph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@665ea13b032812a82bd91ce4929e36c954494264 -
Trigger Event:
release
-
Statement type:
File details
Details for the file duragraph_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: duragraph_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58a11f5de60cd687658632128928ccc6ed5d7bffa5d2aa01b2823693613729b3
|
|
| MD5 |
d33ed1dbac000ca6f95c81fa7c4e1fac
|
|
| BLAKE2b-256 |
ffe1e82f17ce71e12cba9347b42d596ad67e0baac393e8ab114b315a04ad0d05
|
Provenance
The following attestation bundles were made for duragraph_python-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Duragraph/duragraph-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
duragraph_python-0.1.0-py3-none-any.whl -
Subject digest:
58a11f5de60cd687658632128928ccc6ed5d7bffa5d2aa01b2823693613729b3 - Sigstore transparency entry: 781110919
- Sigstore integration time:
-
Permalink:
Duragraph/duragraph-python@665ea13b032812a82bd91ce4929e36c954494264 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Duragraph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@665ea13b032812a82bd91ce4929e36c954494264 -
Trigger Event:
release
-
Statement type: