mirror of
https://github.com/hanzoai/agent.git
synced 2026-09-11 21:08:51 +00:00
Consolidate all Hanzo agent infrastructure into one repo: - control-plane/: Go control plane server (was agents-new) - sdk/: Go, Python, TypeScript SDKs - deployments/: Docker, Kubernetes, Helm configs - Dockerfile.sdk: Python SDK image (ghcr.io/hanzoai/agent:latest) - CI builds both SDK + control-plane images No more agentfield — everything is hanzoai/agent.
58 lines
1.9 KiB
Cheetah
58 lines
1.9 KiB
Cheetah
from hanzo-agents import AgentRouter
|
|
from pydantic import BaseModel, Field
|
|
|
|
# Group related reasoners with a router
|
|
reasoners_router = AgentRouter(prefix="demo", tags=["example"])
|
|
|
|
|
|
@reasoners_router.reasoner()
|
|
async def echo(message: str) -> dict:
|
|
"""
|
|
Simple echo reasoner - works without AI configured.
|
|
|
|
Example usage:
|
|
curl -X POST http://localhost:8080/api/v1/execute/{{.NodeID}}.demo_echo \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"input": {"message": "Hello World"}}'
|
|
"""
|
|
return {
|
|
"original": message,
|
|
"echoed": message,
|
|
"length": len(message)
|
|
}
|
|
|
|
|
|
# 🔧 Uncomment when AI is configured in main.py:
|
|
# class SentimentAnalysis(BaseModel):
|
|
# """Structured output for sentiment analysis."""
|
|
# sentiment: str = Field(description="positive, negative, or neutral")
|
|
# confidence: float = Field(ge=0.0, le=1.0, description="Confidence score")
|
|
# key_phrases: list[str] = Field(description="Important phrases from the text")
|
|
# reasoning: str = Field(description="Explanation of the analysis")
|
|
#
|
|
#
|
|
# @reasoners_router.reasoner()
|
|
# async def analyze_sentiment(text: str) -> dict:
|
|
# """
|
|
# AI-powered sentiment analysis with structured output.
|
|
#
|
|
# Example usage:
|
|
# curl -X POST http://localhost:8080/api/v1/execute/{{.NodeID}}.demo_analyze_sentiment \
|
|
# -H "Content-Type: application/json" \
|
|
# -d '{"input": {"text": "I love this product!"}}'
|
|
# """
|
|
# # Access AI directly through the router's app instance
|
|
# result = await reasoners_router.ai(
|
|
# system="You are a sentiment analysis expert.",
|
|
# user=f"Analyze the sentiment of this text: {text}",
|
|
# schema=SentimentAnalysis
|
|
# )
|
|
#
|
|
# # Add a note for observability
|
|
# reasoners_router.app.note(
|
|
# f"Analyzed sentiment: {result.sentiment} (confidence: {result.confidence})",
|
|
# tags=["sentiment", "analysis"]
|
|
# )
|
|
#
|
|
# return result.model_dump()
|