mirror of
https://github.com/hanzo-csharp/sdk.git
synced 2026-11-15 01:32:19 +00:00
Hanzo CI/CD / test (linux-amd64) (push) Skipped
Hanzo CI/CD / test (linux-arm64) (push) Skipped
Hanzo CI/CD / test-advisory (push) Skipped
Hanzo CI/CD / test-amd64 (push) Successful in 5m17s
Hanzo CI/CD / cicd (push) Failing after 3m12s
CI/CD / cicd (push) Failing after 11m24s
Hanzo CI/CD / verify (push) Skipped
56 lines
2.1 KiB
C#
56 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Hanzo.AI.Api;
|
|
using Hanzo.AI.Client;
|
|
using Hanzo.AI.Model;
|
|
|
|
namespace Hanzo.AI.Examples
|
|
{
|
|
/// <summary>
|
|
/// kai — one structured decision via Kai.
|
|
/// Operation: post_decisions — POST /v1/decisions with model "kai".
|
|
/// </summary>
|
|
public static class Kai
|
|
{
|
|
public static int Run()
|
|
{
|
|
var ai = new AiApi(Gateway.Configuration());
|
|
try
|
|
{
|
|
var reply = ai.PostDecisions(new AiDecisionsRequest(
|
|
model: "kai",
|
|
state: new
|
|
{
|
|
npc = "guard_01",
|
|
health = 82,
|
|
ammo = 14,
|
|
sound_contact = true,
|
|
distance_m = 11.5,
|
|
},
|
|
questions: new Dictionary<string, AiDecisionsQuestion>
|
|
{
|
|
["tactic"] = new AiDecisionsQuestion(new AiDecisionsChoice(
|
|
type: AiDecisionsChoice.TypeEnum.Choice,
|
|
criteria: new Dictionary<string, string>
|
|
{
|
|
["patrol"] = "keep moving along route when area is quiet",
|
|
["investigate"] = "move cautiously toward sound contact",
|
|
["engage"] = "open fire on confirmed visible target",
|
|
["retreat"] = "fall back when critically injured or out of ammo",
|
|
})),
|
|
}));
|
|
var answer = reply.Answers["tactic"];
|
|
Console.WriteLine($"model {reply.Model}");
|
|
Console.WriteLine($"choice {answer.Choice} (confidence {answer.Confidence:0.###})");
|
|
Console.WriteLine($"latency {reply.LatencyMs:0.#} ms");
|
|
return 0;
|
|
}
|
|
catch (ApiException e)
|
|
{
|
|
Console.Error.WriteLine($"kai failed: HTTP {e.ErrorCode} {e.ErrorContent}");
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
}
|