add missing field

This commit is contained in:
Jicheng Lu 2024-01-15 21:26:18 -06:00
parent fa769227e0
commit d50ef81f3e
7 changed files with 19 additions and 6 deletions

View file

@ -75,7 +75,7 @@ public class Agent
/// Default is True, user will enable this by installing appropriate plugin. /// Default is True, user will enable this by installing appropriate plugin.
/// </summary> /// </summary>
public bool Disabled { get; set; } = true; public bool Disabled { get; set; } = true;
public string IconUrl { get; set; } public string? IconUrl { get; set; }
/// <summary> /// <summary>
/// Profile by channel /// Profile by channel

View file

@ -13,7 +13,10 @@ public partial class AgentService
if (!isDeleted) return; if (!isDeleted) return;
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>(); var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
var agentDir = Path.Combine(dbSettings.FileRepository, _agentSettings.DataDir); var agentDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
dbSettings.FileRepository,
_agentSettings.DataDir);
var user = _db.GetUserById(_user.Id); var user = _db.GetUserById(_user.Id);
var agents = new List<Agent>(); var agents = new List<Agent>();
var userAgents = new List<UserAgent>(); var userAgents = new List<UserAgent>();

View file

@ -27,7 +27,7 @@ public partial class AgentService
record.Templates = agent.Templates ?? new List<AgentTemplate>(); record.Templates = agent.Templates ?? new List<AgentTemplate>();
record.Responses = agent.Responses ?? new List<AgentResponse>(); record.Responses = agent.Responses ?? new List<AgentResponse>();
record.Samples = agent.Samples ?? new List<string>(); record.Samples = agent.Samples ?? new List<string>();
if (!agent.LlmConfig.IsInherit) if (agent.LlmConfig != null && !agent.LlmConfig.IsInherit)
{ {
record.LlmConfig = agent.LlmConfig; record.LlmConfig = agent.LlmConfig;
} }
@ -47,7 +47,9 @@ public partial class AgentService
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>(); var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
var agentSettings = _services.GetRequiredService<AgentSettings>(); var agentSettings = _services.GetRequiredService<AgentSettings>();
var filePath = Path.Combine(dbSettings.FileRepository, agentSettings.DataDir); var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
dbSettings.FileRepository,
agentSettings.DataDir);
var clonedAgent = Agent.Clone(agent); var clonedAgent = Agent.Clone(agent);
var foundAgent = FetchAgentFileById(agent.Id, filePath); var foundAgent = FetchAgentFileById(agent.Id, filePath);

View file

@ -6,6 +6,7 @@ public class AgentDocument : MongoBase
{ {
public string Name { get; set; } public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
public string? IconUrl { get; set; }
public string Instruction { get; set; } public string Instruction { get; set; }
public List<AgentTemplateMongoElement> Templates { get; set; } public List<AgentTemplateMongoElement> Templates { get; set; }
public List<FunctionDefMongoElement> Functions { get; set; } public List<FunctionDefMongoElement> Functions { get; set; }

View file

@ -6,6 +6,7 @@ public class AgentLlmConfigMongoElement
{ {
public string? Provider { get; set; } public string? Provider { get; set; }
public string? Model { get; set; } public string? Model { get; set; }
public bool IsInherit { get; set; }
public static AgentLlmConfigMongoElement? ToMongoElement(AgentLlmConfig? config) public static AgentLlmConfigMongoElement? ToMongoElement(AgentLlmConfig? config)
{ {
@ -14,7 +15,8 @@ public class AgentLlmConfigMongoElement
return new AgentLlmConfigMongoElement return new AgentLlmConfigMongoElement
{ {
Provider = config.Provider, Provider = config.Provider,
Model = config.Model Model = config.Model,
IsInherit = config.IsInherit,
}; };
} }
@ -25,7 +27,8 @@ public class AgentLlmConfigMongoElement
return new AgentLlmConfig return new AgentLlmConfig
{ {
Provider = config.Provider, Provider = config.Provider,
Model = config.Model Model = config.Model,
IsInherit = config.IsInherit,
}; };
} }
} }

View file

@ -252,6 +252,7 @@ public partial class MongoRepository
{ {
Id = agent.Id, Id = agent.Id,
Name = agent.Name, Name = agent.Name,
IconUrl = agent.IconUrl,
Description = agent.Description, Description = agent.Description,
Instruction = agent.Instruction, Instruction = agent.Instruction,
Templates = !agent.Templates.IsNullOrEmpty() ? agent.Templates Templates = !agent.Templates.IsNullOrEmpty() ? agent.Templates
@ -338,6 +339,7 @@ public partial class MongoRepository
{ {
Id = x.Id, Id = x.Id,
Name = x.Name, Name = x.Name,
IconUrl = x.IconUrl,
Description = x.Description, Description = x.Description,
Instruction = x.Instruction, Instruction = x.Instruction,
Templates = !x.Templates.IsNullOrEmpty() ? x.Templates Templates = !x.Templates.IsNullOrEmpty() ? x.Templates
@ -402,6 +404,7 @@ public partial class MongoRepository
{ {
Id = !string.IsNullOrEmpty(x.Id) ? x.Id : Guid.NewGuid().ToString(), Id = !string.IsNullOrEmpty(x.Id) ? x.Id : Guid.NewGuid().ToString(),
Name = x.Name, Name = x.Name,
IconUrl = x.IconUrl,
Description = x.Description, Description = x.Description,
Instruction = x.Instruction, Instruction = x.Instruction,
Templates = x.Templates? Templates = x.Templates?

View file

@ -42,6 +42,7 @@ public partial class MongoRepository
Name = x.Name, Name = x.Name,
Description = x.Description, Description = x.Description,
Instruction = x.Instruction, Instruction = x.Instruction,
IconUrl = x.IconUrl,
Templates = x.Templates? Templates = x.Templates?
.Select(t => AgentTemplateMongoElement.ToMongoElement(t))? .Select(t => AgentTemplateMongoElement.ToMongoElement(t))?
.ToList() ?? new List<AgentTemplateMongoElement>(), .ToList() ?? new List<AgentTemplateMongoElement>(),