kaygraph


Namekaygraph JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryA context-graph framework for building production-ready AI applications.
upload_time2025-07-31 00:17:06
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords agentic ai context graphs llm workflow
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # KayGraph

An opinionated framework for building context-aware AI applications with production-ready graphs.

[![PyPI version](https://img.shields.io/pypi/v/kaygraph)](https://pypi.org/project/kaygraph/)
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
[![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)

## What is KayGraph?

KayGraph provides powerful abstractions for orchestrating complex AI workflows through **Context Graphs** - a pattern that seamlessly integrates operations, LLM calls, and state management into production-ready applications.

### Core Philosophy

- **Context-Aware Graphs**: Build sophisticated AI systems where every node has access to shared context
- **Opinionated Patterns**: Production-tested patterns for common AI workflows
- **Zero Dependencies**: Pure Python implementation with no external dependencies
- **Bring Your Own Tools**: Integrate any LLM, database, or service you prefer

## Installation

### Using uv (Recommended)

[uv](https://github.com/astral-sh/uv) is a fast Python package manager that provides better dependency resolution and faster installations:

```bash
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install KayGraph
uv pip install kaygraph

# Or install from source with development dependencies
git clone https://github.com/KayOS-AI/KayGraph.git
cd KayGraph/kaygraph-library
uv pip install -e ".[dev]"
```

### Using pip

```bash
pip install kaygraph
```

Or install from source:

```bash
git clone https://github.com/KayOS-AI/KayGraph.git
cd KayGraph/kaygraph-library
pip install -e .
```

## Quick Start

```python
from kaygraph import Node, Graph

# Define a simple node
class AnalyzeNode(Node):
    def prep(self, shared):
        # Read from shared context
        return shared.get("input_text")

    def exec(self, text):
        # Process data (e.g., LLM call)
        return analyze_sentiment(text)

    def post(self, shared, prep_res, exec_res):
        # Write to shared context
        shared["sentiment"] = exec_res
        return "complete"  # Next action

# Create and run a graph
graph = Graph()
analyze = AnalyzeNode("analyzer")
graph.add_node(analyze)

shared = {"input_text": "KayGraph makes AI development intuitive!"}
graph.run(shared)
print(shared["sentiment"])  # Output: "positive"
```

## Key Features

### 🏗️ Core Abstractions

- **Node**: Atomic unit of work with 3-phase lifecycle (prep → exec → post)
- **Graph**: Orchestrates node execution through labeled actions
- **Shared Store**: Context-aware state management across nodes

### 🎯 Production Patterns

- **Agent**: Autonomous decision-making systems
- **RAG**: Retrieval-augmented generation pipelines
- **Workflows**: Multi-step task orchestration
- **Batch Processing**: Efficient data processing at scale
- **Async Operations**: Non-blocking I/O operations

### 🚀 Enterprise Features

- **ValidatedNode**: Input/output validation
- **MetricsNode**: Performance monitoring
- **Comprehensive Logging**: Built-in debugging support
- **Error Handling**: Graceful failure recovery
- **Resource Management**: Context managers for cleanup

## Documentation

### Core Concepts
- [Node Design](docs/fundamentals/node.md) - Understanding the 3-phase lifecycle
- [Graph Orchestration](docs/fundamentals/graph.md) - Connecting nodes with actions
- [Shared Store](docs/fundamentals/communication.md) - Managing shared context

### Common Patterns
- [Building Agents](docs/patterns/agent.md)
- [RAG Pipelines](docs/patterns/rag.md)
- [Workflows](docs/patterns/graph.md)
- [Map-Reduce](docs/patterns/mapreduce.md)

### Advanced Topics
- [Async Operations](docs/fundamentals/async.md)
- [Batch Processing](docs/fundamentals/batch.md)
- [Parallel Execution](docs/fundamentals/parallel.md)
- [Production Best Practices](docs/production/)

## Development with AI Assistants

KayGraph is designed for **Agentic Coding** - where humans design and AI agents implement.

### Generate Cursor Rules

```bash
# Generate AI coding assistant rules from documentation
python utils/update_kaygraph_mdc.py
```

This creates `.cursor/rules/` with context-aware guidance for AI assistants.

## Project Structure

```
kaygraph-library/
├── kaygraph/          # Core framework
│   └── __init__.py    # All abstractions in one file
├── docs/              # Comprehensive documentation
├── tests/             # Unit tests
├── utils/             # Helper scripts
└── .cursor/rules/     # AI assistant guidance
```

## Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

## License

MIT License - see [LICENSE](LICENSE) for details.

---

Built with ❤️ by the KayOS Team

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "kaygraph",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "agentic, ai, context, graphs, llm, workflow",
    "author": null,
    "author_email": "KayOS Team <team@kayos.ai>",
    "download_url": "https://files.pythonhosted.org/packages/f3/2f/ddcd5030d01d5b41962423a00b5ade084859fdfe184025c0ceebe8d76d18/kaygraph-0.0.2.tar.gz",
    "platform": null,
    "description": "# KayGraph\n\nAn opinionated framework for building context-aware AI applications with production-ready graphs.\n\n[![PyPI version](https://img.shields.io/pypi/v/kaygraph)](https://pypi.org/project/kaygraph/)\n![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)\n[![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)\n\n## What is KayGraph?\n\nKayGraph provides powerful abstractions for orchestrating complex AI workflows through **Context Graphs** - a pattern that seamlessly integrates operations, LLM calls, and state management into production-ready applications.\n\n### Core Philosophy\n\n- **Context-Aware Graphs**: Build sophisticated AI systems where every node has access to shared context\n- **Opinionated Patterns**: Production-tested patterns for common AI workflows\n- **Zero Dependencies**: Pure Python implementation with no external dependencies\n- **Bring Your Own Tools**: Integrate any LLM, database, or service you prefer\n\n## Installation\n\n### Using uv (Recommended)\n\n[uv](https://github.com/astral-sh/uv) is a fast Python package manager that provides better dependency resolution and faster installations:\n\n```bash\n# Install uv\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n\n# Install KayGraph\nuv pip install kaygraph\n\n# Or install from source with development dependencies\ngit clone https://github.com/KayOS-AI/KayGraph.git\ncd KayGraph/kaygraph-library\nuv pip install -e \".[dev]\"\n```\n\n### Using pip\n\n```bash\npip install kaygraph\n```\n\nOr install from source:\n\n```bash\ngit clone https://github.com/KayOS-AI/KayGraph.git\ncd KayGraph/kaygraph-library\npip install -e .\n```\n\n## Quick Start\n\n```python\nfrom kaygraph import Node, Graph\n\n# Define a simple node\nclass AnalyzeNode(Node):\n    def prep(self, shared):\n        # Read from shared context\n        return shared.get(\"input_text\")\n\n    def exec(self, text):\n        # Process data (e.g., LLM call)\n        return analyze_sentiment(text)\n\n    def post(self, shared, prep_res, exec_res):\n        # Write to shared context\n        shared[\"sentiment\"] = exec_res\n        return \"complete\"  # Next action\n\n# Create and run a graph\ngraph = Graph()\nanalyze = AnalyzeNode(\"analyzer\")\ngraph.add_node(analyze)\n\nshared = {\"input_text\": \"KayGraph makes AI development intuitive!\"}\ngraph.run(shared)\nprint(shared[\"sentiment\"])  # Output: \"positive\"\n```\n\n## Key Features\n\n### \ud83c\udfd7\ufe0f Core Abstractions\n\n- **Node**: Atomic unit of work with 3-phase lifecycle (prep \u2192 exec \u2192 post)\n- **Graph**: Orchestrates node execution through labeled actions\n- **Shared Store**: Context-aware state management across nodes\n\n### \ud83c\udfaf Production Patterns\n\n- **Agent**: Autonomous decision-making systems\n- **RAG**: Retrieval-augmented generation pipelines\n- **Workflows**: Multi-step task orchestration\n- **Batch Processing**: Efficient data processing at scale\n- **Async Operations**: Non-blocking I/O operations\n\n### \ud83d\ude80 Enterprise Features\n\n- **ValidatedNode**: Input/output validation\n- **MetricsNode**: Performance monitoring\n- **Comprehensive Logging**: Built-in debugging support\n- **Error Handling**: Graceful failure recovery\n- **Resource Management**: Context managers for cleanup\n\n## Documentation\n\n### Core Concepts\n- [Node Design](docs/fundamentals/node.md) - Understanding the 3-phase lifecycle\n- [Graph Orchestration](docs/fundamentals/graph.md) - Connecting nodes with actions\n- [Shared Store](docs/fundamentals/communication.md) - Managing shared context\n\n### Common Patterns\n- [Building Agents](docs/patterns/agent.md)\n- [RAG Pipelines](docs/patterns/rag.md)\n- [Workflows](docs/patterns/graph.md)\n- [Map-Reduce](docs/patterns/mapreduce.md)\n\n### Advanced Topics\n- [Async Operations](docs/fundamentals/async.md)\n- [Batch Processing](docs/fundamentals/batch.md)\n- [Parallel Execution](docs/fundamentals/parallel.md)\n- [Production Best Practices](docs/production/)\n\n## Development with AI Assistants\n\nKayGraph is designed for **Agentic Coding** - where humans design and AI agents implement.\n\n### Generate Cursor Rules\n\n```bash\n# Generate AI coding assistant rules from documentation\npython utils/update_kaygraph_mdc.py\n```\n\nThis creates `.cursor/rules/` with context-aware guidance for AI assistants.\n\n## Project Structure\n\n```\nkaygraph-library/\n\u251c\u2500\u2500 kaygraph/          # Core framework\n\u2502   \u2514\u2500\u2500 __init__.py    # All abstractions in one file\n\u251c\u2500\u2500 docs/              # Comprehensive documentation\n\u251c\u2500\u2500 tests/             # Unit tests\n\u251c\u2500\u2500 utils/             # Helper scripts\n\u2514\u2500\u2500 .cursor/rules/     # AI assistant guidance\n```\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n---\n\nBuilt with \u2764\ufe0f by the KayOS Team\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A context-graph framework for building production-ready AI applications.",
    "version": "0.0.2",
    "project_urls": {
        "Documentation": "https://github.com/KayOS-AI/KayGraph",
        "Homepage": "https://github.com/KayOS-AI/KayGraph",
        "Issues": "https://github.com/KayOS-AI/KayGraph/issues"
    },
    "split_keywords": [
        "agentic",
        " ai",
        " context",
        " graphs",
        " llm",
        " workflow"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a91d914d1d3b6f229aa137438763602ff22814cfddfae40fc8a636f528e422d5",
                "md5": "4e71b7ea52cb116f254f41fa9648fbf0",
                "sha256": "aa2448e0cfe9aeae4f49a228eb9f0622b09c1023250d74a725e036794c25a4d2"
            },
            "downloads": -1,
            "filename": "kaygraph-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4e71b7ea52cb116f254f41fa9648fbf0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 9501,
            "upload_time": "2025-07-31T00:17:05",
            "upload_time_iso_8601": "2025-07-31T00:17:05.447726Z",
            "url": "https://files.pythonhosted.org/packages/a9/1d/914d1d3b6f229aa137438763602ff22814cfddfae40fc8a636f528e422d5/kaygraph-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f32fddcd5030d01d5b41962423a00b5ade084859fdfe184025c0ceebe8d76d18",
                "md5": "4d907fe33ad5805f5a431a489ac835c1",
                "sha256": "f12aa93903c6fe4fd05ad7ab18bcbff310fb3eb36e73bc219de869b4cae30ae6"
            },
            "downloads": -1,
            "filename": "kaygraph-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "4d907fe33ad5805f5a431a489ac835c1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 662647,
            "upload_time": "2025-07-31T00:17:06",
            "upload_time_iso_8601": "2025-07-31T00:17:06.597434Z",
            "url": "https://files.pythonhosted.org/packages/f3/2f/ddcd5030d01d5b41962423a00b5ade084859fdfe184025c0ceebe8d76d18/kaygraph-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-31 00:17:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "KayOS-AI",
    "github_project": "KayGraph",
    "github_not_found": true,
    "lcname": "kaygraph"
}
        
Elapsed time: 1.99246s