add func vis mode
This commit is contained in:
parent
19e957ef25
commit
5a6ac3df4e
|
|
@ -9,6 +9,7 @@ public enum AgentField
|
|||
Disabled,
|
||||
Type,
|
||||
RoutingMode,
|
||||
FuncVisMode,
|
||||
InheritAgentId,
|
||||
Profile,
|
||||
Label,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
namespace BotSharp.Abstraction.Agents.Enums;
|
||||
|
||||
public class AgentFuncVisMode
|
||||
{
|
||||
public const string Manual = "manual";
|
||||
public const string Auto = "auto";
|
||||
}
|
||||
|
|
@ -21,6 +21,13 @@ public class Agent
|
|||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Function Visibility Mode: Manual or Auto
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonPropertyName("functionVisibilityMode")]
|
||||
public string? FuncVisMode { get; set; }
|
||||
|
||||
public DateTime CreatedDateTime { get; set; }
|
||||
public DateTime UpdatedDateTime { get; set; }
|
||||
|
||||
|
|
@ -296,6 +303,12 @@ public class Agent
|
|||
return this;
|
||||
}
|
||||
|
||||
public Agent SetFuncVisMode(string? visMode)
|
||||
{
|
||||
FuncVisMode = visMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Agent SetProfiles(List<string> profiles)
|
||||
{
|
||||
Profiles = profiles ?? [];
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public partial class AgentService
|
|||
record.MaxMessageCount = agent.MaxMessageCount;
|
||||
record.Type = agent.Type;
|
||||
record.Mode = agent.Mode;
|
||||
record.FuncVisMode = agent.FuncVisMode;
|
||||
record.Profiles = agent.Profiles ?? [];
|
||||
record.Labels = agent.Labels ?? [];
|
||||
record.RoutingRules = agent.RoutingRules ?? [];
|
||||
|
|
@ -96,6 +97,7 @@ public partial class AgentService
|
|||
.SetName(foundAgent.Name)
|
||||
.SetType(foundAgent.Type)
|
||||
.SetRoutingMode(foundAgent.Mode)
|
||||
.SetFuncVisMode(foundAgent.FuncVisMode)
|
||||
.SetIsPublic(foundAgent.IsPublic)
|
||||
.SetDisabled(foundAgent.Disabled)
|
||||
.SetDescription(foundAgent.Description)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ namespace BotSharp.Core.Repository
|
|||
case AgentField.RoutingMode:
|
||||
UpdateAgentRoutingMode(agent.Id, agent.Mode);
|
||||
break;
|
||||
case AgentField.FuncVisMode:
|
||||
UpdateAgentFuncVisMode(agent.Id, agent.FuncVisMode);
|
||||
break;
|
||||
case AgentField.InheritAgentId:
|
||||
UpdateAgentInheritAgentId(agent.Id, agent.InheritAgentId);
|
||||
break;
|
||||
|
|
@ -156,6 +159,17 @@ namespace BotSharp.Core.Repository
|
|||
File.WriteAllText(agentFile, json);
|
||||
}
|
||||
|
||||
private void UpdateAgentFuncVisMode(string agentId, string? visMode)
|
||||
{
|
||||
var (agent, agentFile) = GetAgentFromFile(agentId);
|
||||
if (agent == null) return;
|
||||
|
||||
agent.FuncVisMode = visMode;
|
||||
agent.UpdatedDateTime = DateTime.UtcNow;
|
||||
var json = JsonSerializer.Serialize(agent, _options);
|
||||
File.WriteAllText(agentFile, json);
|
||||
}
|
||||
|
||||
private void UpdateAgentInheritAgentId(string agentId, string? inheritAgentId)
|
||||
{
|
||||
var (agent, agentFile) = GetAgentFromFile(agentId);
|
||||
|
|
@ -385,6 +399,7 @@ namespace BotSharp.Core.Repository
|
|||
agent.Name = inputAgent.Name;
|
||||
agent.Type = inputAgent.Type;
|
||||
agent.Mode = inputAgent.Mode;
|
||||
agent.FuncVisMode = inputAgent.FuncVisMode;
|
||||
agent.IsPublic = inputAgent.IsPublic;
|
||||
agent.Disabled = inputAgent.Disabled;
|
||||
agent.Description = inputAgent.Description;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using BotSharp.Abstraction.Agents.Models;
|
||||
using BotSharp.Abstraction.Functions.Models;
|
||||
using BotSharp.Abstraction.Routing.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BotSharp.OpenAPI.ViewModels.Agents;
|
||||
|
||||
|
|
@ -15,6 +15,12 @@ public class AgentCreationModel
|
|||
/// </summary>
|
||||
public string? Mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Agent function visibility mode
|
||||
/// </summary>
|
||||
[JsonPropertyName("function_visibility_mode")]
|
||||
public string? FuncVisMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// LLM default system instructions
|
||||
/// </summary>
|
||||
|
|
@ -74,6 +80,7 @@ public class AgentCreationModel
|
|||
Name = Name,
|
||||
Type = Type,
|
||||
Mode = Mode,
|
||||
FuncVisMode = FuncVisMode,
|
||||
Disabled = Disabled,
|
||||
IsPublic = IsPublic,
|
||||
Description = Description,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@ public class AgentUpdateModel
|
|||
/// </summary>
|
||||
public string? Mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Agent function visibility mode
|
||||
/// </summary>
|
||||
[JsonPropertyName("function_visibility_mode")]
|
||||
public string? FuncVisMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Instruction
|
||||
/// </summary>
|
||||
|
|
@ -101,6 +107,7 @@ public class AgentUpdateModel
|
|||
Name = Name ?? string.Empty,
|
||||
Type = Type,
|
||||
Mode = Mode,
|
||||
FuncVisMode = FuncVisMode,
|
||||
IsPublic = IsPublic,
|
||||
Disabled = Disabled,
|
||||
Description = Description ?? string.Empty,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ public class AgentViewModel
|
|||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Mode { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonPropertyName("function_visibility_mode")]
|
||||
public string? FuncVisMode { get; set; }
|
||||
|
||||
public string Instruction { get; set; }
|
||||
|
||||
[JsonPropertyName("channel_instructions")]
|
||||
|
|
@ -86,6 +91,7 @@ public class AgentViewModel
|
|||
Description = agent.Description,
|
||||
Type = agent.Type,
|
||||
Mode = agent.Mode,
|
||||
FuncVisMode = agent.FuncVisMode,
|
||||
Instruction = agent.Instruction,
|
||||
ChannelInstructions = agent.ChannelInstructions ?? [],
|
||||
Templates = agent.Templates ?? [],
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public class AgentDocument : MongoBase
|
|||
public string Description { get; set; } = default!;
|
||||
public string Type { get; set; } = default!;
|
||||
public string? Mode { get; set; }
|
||||
public string? FunctionVisibilityMode { get; set; }
|
||||
public string? InheritAgentId { get; set; }
|
||||
public string? IconUrl { get; set; }
|
||||
public string Instruction { get; set; } = default!;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ public partial class MongoRepository
|
|||
case AgentField.RoutingMode:
|
||||
UpdateAgentRoutingMode(agent.Id, agent.Mode);
|
||||
break;
|
||||
case AgentField.FuncVisMode:
|
||||
UpdateAgentFuncVisMode(agent.Id, agent.FuncVisMode);
|
||||
break;
|
||||
case AgentField.InheritAgentId:
|
||||
UpdateAgentInheritAgentId(agent.Id, agent.InheritAgentId);
|
||||
break;
|
||||
|
|
@ -149,6 +152,16 @@ public partial class MongoRepository
|
|||
_dc.Agents.UpdateOne(filter, update);
|
||||
}
|
||||
|
||||
private void UpdateAgentFuncVisMode(string agentId, string? visMode)
|
||||
{
|
||||
var filter = Builders<AgentDocument>.Filter.Eq(x => x.Id, agentId);
|
||||
var update = Builders<AgentDocument>.Update
|
||||
.Set(x => x.FunctionVisibilityMode, visMode)
|
||||
.Set(x => x.UpdatedTime, DateTime.UtcNow);
|
||||
|
||||
_dc.Agents.UpdateOne(filter, update);
|
||||
}
|
||||
|
||||
private void UpdateAgentInheritAgentId(string agentId, string? inheritAgentId)
|
||||
{
|
||||
var filter = Builders<AgentDocument>.Filter.Eq(x => x.Id, agentId);
|
||||
|
|
@ -349,6 +362,7 @@ public partial class MongoRepository
|
|||
.Set(x => x.MergeUtility, agent.MergeUtility)
|
||||
.Set(x => x.Type, agent.Type)
|
||||
.Set(x => x.Mode, agent.Mode)
|
||||
.Set(x => x.FunctionVisibilityMode, agent.FuncVisMode)
|
||||
.Set(x => x.MaxMessageCount, agent.MaxMessageCount)
|
||||
.Set(x => x.Profiles, agent.Profiles)
|
||||
.Set(x => x.Labels, agent.Labels)
|
||||
|
|
@ -529,6 +543,7 @@ public partial class MongoRepository
|
|||
IsPublic = x.IsPublic,
|
||||
Type = x.Type,
|
||||
Mode = x.Mode,
|
||||
FunctionVisibilityMode = x.FuncVisMode,
|
||||
InheritAgentId = x.InheritAgentId,
|
||||
Disabled = x.Disabled,
|
||||
MergeUtility = x.MergeUtility,
|
||||
|
|
@ -627,6 +642,7 @@ public partial class MongoRepository
|
|||
MergeUtility = agentDoc.MergeUtility,
|
||||
Type = agentDoc.Type,
|
||||
Mode = agentDoc.Mode,
|
||||
FuncVisMode = agentDoc.FunctionVisibilityMode,
|
||||
InheritAgentId = agentDoc.InheritAgentId,
|
||||
Profiles = agentDoc.Profiles ?? [],
|
||||
Labels = agentDoc.Labels ?? [],
|
||||
|
|
|
|||
Loading…
Reference in a new issue