Getting Started with Python#

This guide helps you get started with The Edge Agent Python implementation.

Installation#

From PyPI#

pip install the-edge-agent

From Source#

cd python/
pip install -e .

With Optional Dependencies#

# LLM support
pip install the-edge-agent[llm]

# RAG with ChromaDB
pip install the-edge-agent[rag-chroma]

# All features
pip install the-edge-agent[all]

Quick Start#

Python API#

import the_edge_agent as tea

# Create a simple graph
graph = tea.StateGraph({"value": int, "result": str})

# Add a processing node
graph.add_node("process", run=lambda state: {
    "result": f"Processed: {state['value']}"
})

# Connect nodes
graph.set_entry_point("process")
graph.set_finish_point("process")

# Execute
for event in graph.compile().invoke({"value": 42}):
    print(event)
# Output: {'type': 'final', 'state': {'value': 42, 'result': 'Processed: 42'}}

YAML Agent#

Create a file my_agent.yaml:

name: greeting-agent
state_schema:
  name: str
  greeting: str

nodes:
  - name: greet
    run: |
      return {"greeting": f"Hello, {state['name']}!"}

edges:
  - from: __start__
    to: greet
  - from: greet
    to: __end__

Run it:

from the_edge_agent import YAMLEngine

engine = YAMLEngine()
graph = engine.load_from_file("my_agent.yaml")

for event in graph.stream({"name": "World"}):
    print(event)

Next Steps#

System Requirements#

  • Python 3.7+

  • Optional: Graphviz (for visualization)

# Ubuntu/Debian
sudo apt-get install libgraphviz-dev graphviz -y

# macOS
brew install graphviz