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

42 lines
1.3 KiB
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
2023-11-14 20:56:51 +00:00
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public bool ExecutingDirectly { get; set; }
2023-11-08 22:27:42 +00:00
2024-02-02 04:16:57 +00:00
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
2024-02-19 22:55:41 +00:00
public bool HandleDialogsByPlanner { get; set; }
2024-02-02 04:16:57 +00:00
2024-01-06 22:24:22 +00:00
/// <summary>
/// Router routed to a wrong agent.
/// Set this flag as True will force router to re-route current request to a new agent.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public bool UnmatchedAgent { 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
}