response_to_user after reasoning.

This commit is contained in:
hchen2020 2023-08-28 10:58:35 -05:00
parent 6f5cf2fcae
commit 5413f4f71b
3 changed files with 31 additions and 2 deletions

View file

@ -8,6 +8,9 @@ public class RetrievalArgs : RoutingArgs
[JsonPropertyName("question")]
public string Question { get; set; }
[JsonPropertyName("answer")]
public string Answer { get; set; }
[JsonPropertyName("reason")]
public string Reason { get; set; }

View file

@ -83,6 +83,15 @@ public partial class ConversationService
}, onMessageReceived);
return true;
}
else if (reasonedContext.FunctionName == "response_to_user")
{
await HandleAssistantMessage(new RoleDialogModel(AgentRole.Assistant, reasonedContext.Content)
{
CurrentAgentId = agent.Id,
Channel = lastDialog.Channel
}, onMessageReceived);
return true;
}
else if (reasonedContext.FunctionName == "continue_execute_task")
{
if (reasonedContext.CurrentAgentId != agent.Id)

View file

@ -34,7 +34,7 @@ public class Simulator
var response = await SendMessageToReasoner(agent);
var args = JsonSerializer.Deserialize<FunctionCallFromLlm>(response.Content);
response.FunctionName = args.Function;
response.Content = args.Parameters.Reason;
if (args.Function == "continue_execute_task")
{
response.FunctionArgs = JsonSerializer.Serialize(args.Parameters.Arguments);
@ -43,6 +43,16 @@ public class Simulator
var record = router.GetRecordByName(args.Parameters.AgentName);
response.CurrentAgentId = record.AgentId;
}
else if (args.Function == "interrupt_task_execution")
{
response.Content = args.Parameters.Reason;
response.ExecutionResult = args.Parameters.Reason;
}
else if (args.Function == "response_to_user")
{
response.Content = args.Parameters.Answer;
response.ExecutionResult = args.Parameters.Answer;
}
return response;
}
@ -63,7 +73,14 @@ public class Simulator
var args = JsonSerializer.Deserialize<FunctionCallFromLlm>(response.Content);
SaveStateByArgs(args.Parameters.Arguments);
if (args.Function == "retrieve_data_from_agent")
{
SaveStateByArgs(args.Parameters.Arguments);
}
else if (args.Function == "response_to_user")
{
return response;
}
// Retrieve information from specific agent
var router = _services.GetRequiredService<IAgentRouting>();