Files
zeekayandHanzo Dev ff7d100496 Everything that calls the control plane calls /v1
The server mounts /v1, /v1/ui and /v2/ui. The UI and its dev proxy, the helm
and kubernetes health probes, functional tests, project templates, examples
and scripts still called /api/v1, so the probes failed and the UI's requests
missed.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-11 04:10:35 -07:00

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/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/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()