Add ITool + ToolRegistry + GetCurrentTimeTool
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace backend.Tools;
|
||||
|
||||
public class GetCurrentTimeTool : ITool
|
||||
{
|
||||
public string Name => "get_current_time";
|
||||
public string Description => "Returns the current UTC time as an ISO-8601 string.";
|
||||
public bool RunsDuringResponse => false;
|
||||
|
||||
public JsonElement ParameterSchema { get; } =
|
||||
JsonDocument.Parse("""{"type":"object","properties":{},"required":[]}""").RootElement;
|
||||
|
||||
public Task<ToolResult> ExecuteAsync(ToolInvocation invocation, DeviceContext device, CancellationToken ct)
|
||||
{
|
||||
var now = DateTimeOffset.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||
var output = JsonDocument.Parse($$"""{"now":"{{now}}"}""").RootElement;
|
||||
return Task.FromResult(new ToolResult(output));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user