BotSharp/src/Infrastructure/BotSharp.Abstraction/Functions/Models/FunctionCallFromLlm.cs

29 lines
857 B
C#
Raw Normal View History

2023-08-28 03:50:10 +00:00
using BotSharp.Abstraction.Routing.Models;
2023-09-22 20:38:58 +00:00
using System.Text.Json;
2023-08-28 03:50:10 +00:00
namespace BotSharp.Abstraction.Functions.Models;
2023-09-25 22:46:00 +00:00
public class FunctionCallFromLlm : RoutingArgs
2023-08-28 03:50:10 +00:00
{
2023-09-22 20:38:58 +00:00
[JsonPropertyName("question")]
public string? Question { get; set; }
[JsonPropertyName("args")]
2023-10-20 03:47:14 +00:00
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public JsonDocument? Arguments { get; set; }
2023-09-19 12:17:50 +00:00
public override string ToString()
{
2023-09-25 22:46:00 +00:00
var route = string.IsNullOrEmpty(AgentName) ? "" : $"<Route to {AgentName.ToUpper()} because {Reason}>";
if (string.IsNullOrEmpty(Response))
2023-09-22 20:38:58 +00:00
{
2023-09-25 22:46:00 +00:00
return $"[{Function} {route} {JsonSerializer.Serialize(Arguments)}]: {Question}";
2023-09-22 20:38:58 +00:00
}
else
{
return $"[{Function} {route} {JsonSerializer.Serialize(Arguments)}]: {Question} => {Response}";
2023-09-22 20:38:58 +00:00
}
2023-09-19 12:17:50 +00:00
}
2023-08-28 03:50:10 +00:00
}