Add states to chat message result

This commit is contained in:
hchen 2023-11-03 09:16:16 -05:00
parent cb154520e7
commit 73331bbb1d
6 changed files with 17 additions and 12 deletions

View file

@ -1,5 +1,3 @@
using BotSharp.Abstraction.Models;
namespace BotSharp.Abstraction.Instructs.Models;
public class InstructResult : ITrackableMessage

View file

@ -86,7 +86,7 @@ public class HFPlanner : IPlaner
private string GetNextStepPrompt(Agent router)
{
var template = router.Templates.First(x => x.Name == "next_step_prompt").Content;
var template = router.Templates.First(x => x.Name == "next_step_prompt.hf_planner").Content;
var render = _services.GetRequiredService<ITemplateRender>();
var prompt = render.Render(template, router.TemplateDict);
return prompt.Trim();

View file

@ -17,10 +17,10 @@ public class RetrieveDataFromAgentRoutingHandler : RoutingHandlerBase, IRoutingH
public List<ParameterPropertyDef> Parameters => new List<ParameterPropertyDef>
{
new ParameterPropertyDef("reason", "why retrieve data"),
new ParameterPropertyDef("question", "the question you will ask the agent to get the necessary data"),
new ParameterPropertyDef("reason", "why choose this function"),
new ParameterPropertyDef("question", "the question you will ask the next action agent to get the necessary information"),
new ParameterPropertyDef("next_action_agent", "agent that can handle the question"),
new ParameterPropertyDef("user_goal_agent", "agent that can achieve user original goal"),
new ParameterPropertyDef("args", "required parameters extracted from question and hand over to the next agent")
{
Type = "object"

View file

@ -72,6 +72,8 @@ public class ConversationController : ControllerBase, IApiAdapter
});
var state = _services.GetRequiredService<IConversationStateService>();
response.States = state.GetStates();
response.MessageId = inputMsg.MessageId;
return response;

View file

@ -1,18 +1,22 @@
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Models;
using BotSharp.Abstraction.Instructs.Models;
using System.Text.Json.Serialization;
namespace BotSharp.OpenAPI.ViewModels.Conversations;
public class MessageResponseModel : ITrackableMessage
public class MessageResponseModel : InstructResult
{
public string MessageId { get; set; }
public string Text { get; set; }
public string Function { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public object Data { get; set; }
/// <summary>
/// Planner instruction
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public FunctionCallFromLlm Instruction { get; set; }
/// <summary>
/// Rich message for UI rendering
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public object? RichContent { get; set; }
}

View file

@ -0,0 +1 @@
Break down the users most recent needs and figure out the next steps. Response must be in appropriate JSON format.