diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs index 52c16ea7..1280c865 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs @@ -75,7 +75,7 @@ public class Agent /// Default is True, user will enable this by installing appropriate plugin. /// public bool Disabled { get; set; } = true; - public string IconUrl { get; set; } + public string? IconUrl { get; set; } /// /// Profile by channel diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs index f644faea..43757571 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs @@ -13,7 +13,10 @@ public partial class AgentService if (!isDeleted) return; var dbSettings = _services.GetRequiredService(); - 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 agents = new List(); var userAgents = new List(); diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs index 5058d432..459cace4 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs @@ -27,7 +27,7 @@ public partial class AgentService record.Templates = agent.Templates ?? new List(); record.Responses = agent.Responses ?? new List(); record.Samples = agent.Samples ?? new List(); - if (!agent.LlmConfig.IsInherit) + if (agent.LlmConfig != null && !agent.LlmConfig.IsInherit) { record.LlmConfig = agent.LlmConfig; } @@ -47,7 +47,9 @@ public partial class AgentService var dbSettings = _services.GetRequiredService(); var agentSettings = _services.GetRequiredService(); - 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 foundAgent = FetchAgentFileById(agent.Id, filePath); diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs index c9e7298b..b0f1d6e1 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs @@ -6,6 +6,7 @@ public class AgentDocument : MongoBase { public string Name { get; set; } public string Description { get; set; } + public string? IconUrl { get; set; } public string Instruction { get; set; } public List Templates { get; set; } public List Functions { get; set; } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentLlmConfigMongoElement.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentLlmConfigMongoElement.cs index 70c77097..90ae8194 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentLlmConfigMongoElement.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentLlmConfigMongoElement.cs @@ -6,6 +6,7 @@ public class AgentLlmConfigMongoElement { public string? Provider { get; set; } public string? Model { get; set; } + public bool IsInherit { get; set; } public static AgentLlmConfigMongoElement? ToMongoElement(AgentLlmConfig? config) { @@ -14,7 +15,8 @@ public class AgentLlmConfigMongoElement return new AgentLlmConfigMongoElement { Provider = config.Provider, - Model = config.Model + Model = config.Model, + IsInherit = config.IsInherit, }; } @@ -25,7 +27,8 @@ public class AgentLlmConfigMongoElement return new AgentLlmConfig { Provider = config.Provider, - Model = config.Model + Model = config.Model, + IsInherit = config.IsInherit, }; } } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs index fe6d067d..36fc9ff9 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs @@ -252,6 +252,7 @@ public partial class MongoRepository { Id = agent.Id, Name = agent.Name, + IconUrl = agent.IconUrl, Description = agent.Description, Instruction = agent.Instruction, Templates = !agent.Templates.IsNullOrEmpty() ? agent.Templates @@ -338,6 +339,7 @@ public partial class MongoRepository { Id = x.Id, Name = x.Name, + IconUrl = x.IconUrl, Description = x.Description, Instruction = x.Instruction, Templates = !x.Templates.IsNullOrEmpty() ? x.Templates @@ -402,6 +404,7 @@ public partial class MongoRepository { Id = !string.IsNullOrEmpty(x.Id) ? x.Id : Guid.NewGuid().ToString(), Name = x.Name, + IconUrl = x.IconUrl, Description = x.Description, Instruction = x.Instruction, Templates = x.Templates? diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs index aa65f4c8..16b8080c 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs @@ -42,6 +42,7 @@ public partial class MongoRepository Name = x.Name, Description = x.Description, Instruction = x.Instruction, + IconUrl = x.IconUrl, Templates = x.Templates? .Select(t => AgentTemplateMongoElement.ToMongoElement(t))? .ToList() ?? new List(),