Merge branch 'master' into hdongDev

This commit is contained in:
YouWeiDH 2024-05-28 20:00:17 +08:00
commit c32c4f57b1
4 changed files with 12 additions and 3 deletions

View file

@ -51,6 +51,7 @@ public interface IConversationService
/// </summary>
/// <param name="resetStates">Whether to reset all states</param>
/// <param name="reason">Append user init words</param>
/// <param name="excludedStates"></param>
/// <returns></returns>
Task UpdateBreakpoint(bool resetStates = false, string? reason = null);
Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates);
}

View file

@ -4,7 +4,7 @@ namespace BotSharp.Core.Conversations.Services;
public partial class ConversationService : IConversationService
{
public async Task UpdateBreakpoint(bool resetStates = false, string? reason = null)
public async Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates)
{
var db = _services.GetRequiredService<IBotSharpRepository>();
var routingCtx = _services.GetRequiredService<IRoutingContext>();
@ -22,7 +22,13 @@ public partial class ConversationService : IConversationService
{
var states = _services.GetRequiredService<IConversationStateService>();
// keep language state
states.CleanStates(StateConst.LANGUAGE);
if (excludedStates == null) excludedStates = new string[] { };
if (!excludedStates.Contains(StateConst.LANGUAGE))
{
excludedStates = excludedStates.Append(StateConst.LANGUAGE).ToArray();
}
states.CleanStates(excludedStates);
}
var hooks = _services.GetServices<IConversationHook>()

View file

@ -118,6 +118,7 @@ public class RoutingContext : IRoutingContext
var message = new RoleDialogModel(AgentRole.User, $"Try to route to agent {agent.Name}")
{
CurrentAgentId = currentAgentId,
FunctionName = "route_to_agent",
FunctionArgs = JsonSerializer.Serialize(new FunctionCallFromLlm
{

View file

@ -298,6 +298,7 @@ public class ConversationController : ControllerBase
MessageId = msg.MessageId,
Text = msg.Indication,
Function = "indicating",
Instruction = msg.Instruction,
States = new Dictionary<string, string>()
};
await OnChunkReceived(Response, indicator);