mirror of
https://github.com/hanzoai/agents.git
synced 2026-11-02 06:39:03 +00:00
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]>
50 lines
1.3 KiB
Cheetah
50 lines
1.3 KiB
Cheetah
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/hanzoai/agents/sdk/go/agent"
|
|
"github.com/hanzoai/agents/sdk/go/ai"
|
|
)
|
|
|
|
func registerReasoners(app *agent.Agent) {
|
|
// Simple echo reasoner - works without AI configured
|
|
//
|
|
// Example usage:
|
|
// curl -X POST http://localhost:8080/v1/execute/{{.NodeID}}.echo \
|
|
// -H "Content-Type: application/json" \
|
|
// -d '{"input": {"message": "Hello World"}}'
|
|
app.RegisterReasoner("echo", func(ctx context.Context, input map[string]any) (any, error) {
|
|
message, _ := input["message"].(string)
|
|
return map[string]any{
|
|
"original": message,
|
|
"echoed": message,
|
|
"length": len(message),
|
|
}, nil
|
|
})
|
|
|
|
// 🔧 Uncomment when AI is configured in main.go:
|
|
//
|
|
// AI-powered sentiment analysis
|
|
//
|
|
// Example usage:
|
|
// curl -X POST http://localhost:8080/v1/execute/{{.NodeID}}.analyze_sentiment \
|
|
// -H "Content-Type: application/json" \
|
|
// -d '{"input": {"text": "I love this product!"}}'
|
|
//
|
|
// app.RegisterReasoner("analyze_sentiment", func(ctx context.Context, input map[string]any) (any, error) {
|
|
// text, _ := input["text"].(string)
|
|
//
|
|
// result, err := app.AI(ctx,
|
|
// fmt.Sprintf("Analyze the sentiment of this text: %s", text),
|
|
// ai.WithSystem("You are a sentiment analysis expert."),
|
|
// )
|
|
// if err != nil {
|
|
// return nil, err
|
|
// }
|
|
//
|
|
// return result, nil
|
|
// })
|
|
}
|