commit
da9becb053
|
|
@ -18,4 +18,9 @@ public class FunctionCallingResponse
|
|||
|
||||
[JsonPropertyName("args")]
|
||||
public JsonDocument? Args { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{FunctionName}({JsonSerializer.Serialize(Args)}) => {Content}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,4 +4,6 @@ public class StateConst
|
|||
{
|
||||
public const string EXPECTED_ACTION_AGENT = "expected_next_action_agent";
|
||||
public const string EXPECTED_GOAL_AGENT = "expected_user_goal_agent";
|
||||
public const string NEXT_ACTION_AGENT = "next_action_agent";
|
||||
public const string USER_GOAL_AGENT = "user_goal_agent";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class HumanInterventionNeededHandler : RoutingHandlerBase, IRoutingHandle
|
|||
{
|
||||
new ParameterPropertyDef("reason", "why need customer service"),
|
||||
new ParameterPropertyDef("summary", "the whole conversation summary with important information"),
|
||||
new ParameterPropertyDef("response", "confirm with user that whether to connect with customer service")
|
||||
new ParameterPropertyDef("response", "asking user whether to connect with customer service representative")
|
||||
};
|
||||
|
||||
public HumanInterventionNeededHandler(IServiceProvider services, ILogger<HumanInterventionNeededHandler> logger, RoutingSettings settings)
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ public class RouteToAgentRoutingHandler : RoutingHandlerBase, IRoutingHandler
|
|||
{
|
||||
public string Name => "route_to_agent";
|
||||
|
||||
public string Description => "Route request to appropriate agent.";
|
||||
public string Description => "Route request to appropriate virtual agent.";
|
||||
|
||||
public List<ParameterPropertyDef> Parameters => new List<ParameterPropertyDef>
|
||||
{
|
||||
new ParameterPropertyDef("next_action_reason", "the reason why route to this agent")
|
||||
new ParameterPropertyDef("next_action_reason", "the reason why route to this virtual agent")
|
||||
{
|
||||
Required = true
|
||||
},
|
||||
|
|
@ -18,11 +18,11 @@ public class RouteToAgentRoutingHandler : RoutingHandlerBase, IRoutingHandler
|
|||
{
|
||||
Required = true
|
||||
},
|
||||
new ParameterPropertyDef("user_goal_description", "user original goal")
|
||||
new ParameterPropertyDef("user_goal_description", "user goal based on user initial task.")
|
||||
{
|
||||
Required = true
|
||||
},
|
||||
new ParameterPropertyDef("user_goal_agent", "user original goal")
|
||||
new ParameterPropertyDef("user_goal_agent", "agent who can acheive user initial task, must align with user_goal_description ")
|
||||
{
|
||||
Required = true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace BotSharp.Core.Routing;
|
|||
|
||||
public partial class RoutingService
|
||||
{
|
||||
private List<FunctionCallingResponse> _functionCallStack = new List<FunctionCallingResponse>();
|
||||
public async Task<bool> InvokeFunction(string name, RoleDialogModel message)
|
||||
{
|
||||
var function = _services.GetServices<IFunctionCallback>().FirstOrDefault(x => x.Name == name);
|
||||
|
|
@ -35,6 +36,13 @@ public partial class RoutingService
|
|||
try
|
||||
{
|
||||
result = await function.Execute(message);
|
||||
_functionCallStack.Add(new FunctionCallingResponse
|
||||
{
|
||||
Role = AgentRole.Function,
|
||||
FunctionName = message.FunctionName,
|
||||
Args = JsonDocument.Parse(message.FunctionArgs ?? "{}"),
|
||||
Content = message.Content
|
||||
});
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
|
|
@ -69,11 +77,11 @@ public partial class RoutingService
|
|||
}
|
||||
|
||||
// Save to Storage as well
|
||||
/*if (!message.StopCompletion && message.FunctionName != "route_to_agent")
|
||||
if (!message.StopCompletion && message.FunctionName != "route_to_agent")
|
||||
{
|
||||
var storage = _services.GetRequiredService<IConversationStorage>();
|
||||
storage.Append(Context.ConversationId, message);
|
||||
}*/
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
What is the next step based on the CONVERSATION?
|
||||
Route to the last handling agent in priority.
|
||||
|
||||
{% if expected_next_action_agent != empty -%}
|
||||
Expected next action agent is {{ expected_next_action_agent }}.
|
||||
{%- endif -%}
|
||||
{%- if expected_user_goal_agent != empty -%}
|
||||
Expected user goal agent is {{ expected_user_goal_agent }}.
|
||||
{%- else -%}
|
||||
Next action agent is inferred based on user lastest response.
|
||||
{%- endif %}
|
||||
{% if expected_user_goal_agent != empty -%}
|
||||
Expected user goal agent is {{ expected_user_goal_agent }}.
|
||||
{%- else -%}
|
||||
User goal agent is inferred based on user initial request.
|
||||
{%- endif %}
|
||||
|
||||
If user wants to speak to customer service, use function human_intervention_needed.
|
||||
If user wants to or is processing with a specific task that can be handled by agents, respond in appropriate output format defined to let proper agent to handle the task.
|
||||
Loading…
Reference in a new issue