mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
Transforms hanzoai/agents from a marketplace config repo into a full agent orchestration platform by merging the AgentField infrastructure: - Go control plane (K8s-like agent orchestration, service mesh, DAG workflows) - Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC) - TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows) - Go SDK (idiomatic agent builder + client) - React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI) - Docker/K8s/Helm deployment configs - Examples: hello world, deep research, RAG, simulation, benchmarks - Functional test suite across Python/Go/TypeScript All references rebranded: AgentField → Hanzo Agents - Module: github.com/hanzoai/agents/control-plane - Python: hanzo_agents - TypeScript: @hanzo/agents - Go: github.com/hanzoai/agents/sdk/go - Env vars: HANZO_AGENTS_* - Config: hanzo-agents.yaml Previous marketplace configs moved to config/ directory.
79 lines
2.0 KiB
Python
79 lines
2.0 KiB
Python
"""
|
|
Hello World Agent - Minimal Hanzo Agents Example
|
|
|
|
Demonstrates:
|
|
- One skill (deterministic function)
|
|
- Two reasoners (AI-powered functions)
|
|
- Call graph: say_hello → get_greeting (skill) + add_emoji (reasoner)
|
|
"""
|
|
|
|
from hanzo_agents import Agent
|
|
from hanzo_agents import AIConfig
|
|
from pydantic import BaseModel
|
|
import os
|
|
|
|
# Initialize agent
|
|
app = Agent(
|
|
node_id="hello-world",
|
|
hanzo_agents_server=os.getenv("HANZO_AGENTS_URL", "http://localhost:8080"),
|
|
ai_config=AIConfig(
|
|
model=os.getenv("SMALL_MODEL", "openai/gpt-4o-mini"), temperature=0.7
|
|
),
|
|
)
|
|
|
|
# ============= SKILL (DETERMINISTIC) =============
|
|
|
|
|
|
@app.skill()
|
|
def get_greeting(name: str) -> dict:
|
|
"""Returns a greeting template (deterministic - no AI)"""
|
|
return {"message": f"Hello, {name}! Welcome to Hanzo Agents."}
|
|
|
|
|
|
# ============= REASONERS (AI-POWERED) =============
|
|
|
|
|
|
class EmojiResult(BaseModel):
|
|
"""Simple schema for emoji addition"""
|
|
|
|
text: str
|
|
emoji: str
|
|
|
|
|
|
@app.reasoner()
|
|
async def add_emoji(text: str) -> EmojiResult:
|
|
"""Uses AI to add an appropriate emoji to text"""
|
|
return await app.ai(
|
|
user=f"Add one appropriate emoji to this greeting: {text}", schema=EmojiResult
|
|
)
|
|
|
|
|
|
@app.reasoner()
|
|
async def say_hello(name: str) -> dict:
|
|
"""
|
|
Main entry point - orchestrates skill and reasoner.
|
|
|
|
Call graph:
|
|
say_hello (entry point)
|
|
├─→ get_greeting (skill)
|
|
└─→ add_emoji (reasoner)
|
|
"""
|
|
# Step 1: Get greeting from skill (deterministic)
|
|
greeting = get_greeting(name)
|
|
|
|
# Step 2: Add emoji using AI (reasoner)
|
|
result = await add_emoji(greeting["message"])
|
|
|
|
return {"greeting": result.text, "emoji": result.emoji, "name": name}
|
|
|
|
|
|
# ============= START SERVER OR CLI =============
|
|
|
|
if __name__ == "__main__":
|
|
print("🚀 Hello World Agent")
|
|
print("📍 Node: hello-world")
|
|
print("🌐 Control Plane: http://localhost:8080")
|
|
|
|
# Universal entry point - auto-detects CLI vs server mode
|
|
app.run(auto_port=True)
|