add agent mode
This commit is contained in:
parent
6649e529cc
commit
069170a01c
|
|
@ -0,0 +1,7 @@
|
|||
namespace BotSharp.Abstraction.Agents.Enums;
|
||||
|
||||
public class AgentMode
|
||||
{
|
||||
public const string Eager = "eager";
|
||||
public const string Lazy = "lazy";
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ public class Agent
|
|||
/// <summary>
|
||||
/// Routing Mode: lazy or eager
|
||||
/// </summary>
|
||||
public string Mode { get; set; } = "eager";
|
||||
public string Mode { get; set; } = AgentMode.Eager;
|
||||
|
||||
public DateTime CreatedDateTime { get; set; }
|
||||
public DateTime UpdatedDateTime { get; set; }
|
||||
|
|
@ -277,7 +277,7 @@ public class Agent
|
|||
return this;
|
||||
}
|
||||
|
||||
public Agent SetAgentType(string type)
|
||||
public Agent SetType(string type)
|
||||
{
|
||||
Type = type;
|
||||
return this;
|
||||
|
|
@ -288,7 +288,7 @@ public class Agent
|
|||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
/// <returns></returns>
|
||||
public Agent SetAgentMode(string mode)
|
||||
public Agent SetMode(string mode)
|
||||
{
|
||||
Mode = mode;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public partial class AgentService
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"Failed to migrate agent in file directory: {dir}\r\nError: {ex.Message}");
|
||||
_logger.LogError(ex, $"Failed to migrate agent in file directory: {dir}\r\nError: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,12 +94,12 @@ public partial class AgentService
|
|||
{
|
||||
clonedAgent.SetId(foundAgent.Id)
|
||||
.SetName(foundAgent.Name)
|
||||
.SetDescription(foundAgent.Description)
|
||||
.SetType(foundAgent.Type)
|
||||
.SetMode(foundAgent.Mode)
|
||||
.SetIsPublic(foundAgent.IsPublic)
|
||||
.SetDisabled(foundAgent.Disabled)
|
||||
.SetDescription(foundAgent.Description)
|
||||
.SetMergeUtility(foundAgent.MergeUtility)
|
||||
.SetAgentType(foundAgent.Type)
|
||||
.SetAgentMode(foundAgent.Mode)
|
||||
.SetProfiles(foundAgent.Profiles)
|
||||
.SetLabels(foundAgent.Labels)
|
||||
.SetRoutingRules(foundAgent.RoutingRules)
|
||||
|
|
|
|||
|
|
@ -83,10 +83,10 @@ public partial class ConversationService
|
|||
{
|
||||
// Check the routing mode
|
||||
var states = _services.GetRequiredService<IConversationStateService>();
|
||||
var routingMode = states.GetState(StateConst.ROUTING_MODE, "eager");
|
||||
var routingMode = states.GetState(StateConst.ROUTING_MODE, AgentMode.Eager);
|
||||
routing.Context.Push(agent.Id, reason: "request started", updateLazyRouting: false);
|
||||
|
||||
if (routingMode == "lazy")
|
||||
if (routingMode == AgentMode.Lazy)
|
||||
{
|
||||
message.CurrentAgentId = states.GetState(StateConst.LAZY_ROUTING_AGENT_ID, message.CurrentAgentId);
|
||||
routing.Context.Push(message.CurrentAgentId, reason: "lazy routing", updateLazyRouting: false);
|
||||
|
|
|
|||
|
|
@ -383,11 +383,12 @@ namespace BotSharp.Core.Repository
|
|||
if (agent == null) return;
|
||||
|
||||
agent.Name = inputAgent.Name;
|
||||
agent.Description = inputAgent.Description;
|
||||
agent.Type = inputAgent.Type;
|
||||
agent.Mode = inputAgent.Mode;
|
||||
agent.IsPublic = inputAgent.IsPublic;
|
||||
agent.Disabled = inputAgent.Disabled;
|
||||
agent.Description = inputAgent.Description;
|
||||
agent.MergeUtility = inputAgent.MergeUtility;
|
||||
agent.Type = inputAgent.Type;
|
||||
agent.Profiles = inputAgent.Profiles;
|
||||
agent.Labels = inputAgent.Labels;
|
||||
agent.Utilities = inputAgent.Utilities;
|
||||
|
|
|
|||
|
|
@ -290,8 +290,8 @@ public class RoutingContext : IRoutingContext
|
|||
|
||||
// Set next handling agent for lazy routing mode
|
||||
var states = _services.GetRequiredService<IConversationStateService>();
|
||||
var routingMode = states.GetState(StateConst.ROUTING_MODE, "eager");
|
||||
if (routingMode == "lazy")
|
||||
var routingMode = states.GetState(StateConst.ROUTING_MODE, AgentMode.Eager);
|
||||
if (routingMode == AgentMode.Lazy)
|
||||
{
|
||||
var agentId = GetCurrentAgentId();
|
||||
if (agentId != BuiltInAgentId.Fallback)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ public class AgentCreationModel
|
|||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Type { get; set; } = AgentType.Task;
|
||||
public string Mode { get; set; } = AgentMode.Eager;
|
||||
|
||||
/// <summary>
|
||||
/// LLM default system instructions
|
||||
|
|
@ -66,6 +67,10 @@ public class AgentCreationModel
|
|||
return new Agent
|
||||
{
|
||||
Name = Name,
|
||||
Type = Type,
|
||||
Mode = Mode,
|
||||
Disabled = Disabled,
|
||||
IsPublic = IsPublic,
|
||||
Description = Description,
|
||||
Instruction = Instruction,
|
||||
ChannelInstructions = ChannelInstructions,
|
||||
|
|
@ -75,9 +80,6 @@ public class AgentCreationModel
|
|||
Samples = Samples,
|
||||
Utilities = Utilities,
|
||||
McpTools = McpTools,
|
||||
IsPublic = IsPublic,
|
||||
Type = Type,
|
||||
Disabled = Disabled,
|
||||
MergeUtility = MergeUtility,
|
||||
MaxMessageCount = MaxMessageCount,
|
||||
Profiles = Profiles,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ public class AgentUpdateModel
|
|||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string Type { get; set; } = AgentType.Task;
|
||||
public string Mode { get; set; } = AgentMode.Eager;
|
||||
|
||||
/// <summary>
|
||||
/// Instruction
|
||||
/// </summary>
|
||||
|
|
@ -93,12 +95,13 @@ public class AgentUpdateModel
|
|||
var agent = new Agent()
|
||||
{
|
||||
Name = Name ?? string.Empty,
|
||||
Description = Description ?? string.Empty,
|
||||
Type = Type,
|
||||
Mode = Mode,
|
||||
IsPublic = IsPublic,
|
||||
Disabled = Disabled,
|
||||
Description = Description ?? string.Empty,
|
||||
MergeUtility = MergeUtility,
|
||||
MaxMessageCount = MaxMessageCount,
|
||||
Type = Type,
|
||||
Profiles = Profiles ?? [],
|
||||
Labels = Labels ?? [],
|
||||
RoutingRules = RoutingRules?.Select(x => RoutingRuleUpdateModel.ToDomainElement(x))?.ToList() ?? [],
|
||||
|
|
|
|||
Loading…
Reference in a new issue