2025-05-13 16:45:19 +00:00
|
|
|
using BotSharp.Abstraction.Functions;
|
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Core.Functions;
|
|
|
|
|
|
|
|
|
|
public class GetWeatherFn : IFunctionCallback
|
|
|
|
|
{
|
|
|
|
|
private readonly IServiceProvider _services;
|
|
|
|
|
|
|
|
|
|
public GetWeatherFn(IServiceProvider services)
|
|
|
|
|
{
|
|
|
|
|
_services = services;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name => "get_weather";
|
|
|
|
|
public string Indication => "Querying weather";
|
|
|
|
|
|
|
|
|
|
public async Task<bool> Execute(RoleDialogModel message)
|
|
|
|
|
{
|
2025-05-14 23:14:01 +00:00
|
|
|
//var args = JsonSerializer.Deserialize<Location>(message.FunctionArgs, BotSharpOptions.defaultJsonOptions);
|
|
|
|
|
message.Content = $"It is a sunny day.";
|
2025-05-13 16:45:19 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Location
|
|
|
|
|
{
|
|
|
|
|
[JsonPropertyName("city")]
|
|
|
|
|
public string? City { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("state")]
|
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
|
|
|
public string? State { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("county")]
|
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
|
|
|
public string? County { get; set; }
|
|
|
|
|
}
|