Merge branch 'master' of https://github.com/SciSharp/BotSharp into features/refine-function-indication
This commit is contained in:
commit
4bdde0669a
|
|
@ -10,7 +10,7 @@ namespace BotSharp.Abstraction.Agents;
|
||||||
public interface IAgentService
|
public interface IAgentService
|
||||||
{
|
{
|
||||||
Task<Agent> CreateAgent(Agent agent);
|
Task<Agent> CreateAgent(Agent agent);
|
||||||
Task<string> RefreshAgents();
|
Task<string> RefreshAgents(IEnumerable<string>? agentIds = null);
|
||||||
Task<PagedItems<Agent>> GetAgents(AgentFilter filter);
|
Task<PagedItems<Agent>> GetAgents(AgentFilter filter);
|
||||||
Task<List<IdName>> GetAgentOptions(List<string>? agentIds = null, bool byName = false);
|
Task<List<IdName>> GetAgentOptions(List<string>? agentIds = null, bool byName = false);
|
||||||
Task<IEnumerable<AgentUtility>> GetAgentUtilityOptions();
|
Task<IEnumerable<AgentUtility>> GetAgentUtilityOptions();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ namespace BotSharp.Core.Agents.Services;
|
||||||
|
|
||||||
public partial class AgentService
|
public partial class AgentService
|
||||||
{
|
{
|
||||||
public async Task<string> RefreshAgents()
|
public async Task<string> RefreshAgents(IEnumerable<string>? agentIds = null)
|
||||||
{
|
{
|
||||||
string refreshResult;
|
string refreshResult;
|
||||||
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
|
var dbSettings = _services.GetRequiredService<BotSharpDatabaseSettings>();
|
||||||
|
|
@ -28,7 +28,13 @@ public partial class AgentService
|
||||||
}
|
}
|
||||||
|
|
||||||
var refreshedAgents = new List<string>();
|
var refreshedAgents = new List<string>();
|
||||||
foreach (var dir in Directory.GetDirectories(agentDir))
|
var dirs = Directory.GetDirectories(agentDir);
|
||||||
|
if (!agentIds.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
dirs = dirs.Where(x => agentIds.Contains(x.Split(Path.DirectorySeparatorChar).Last())).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var dir in dirs)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +84,7 @@ public partial class AgentService
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
refreshResult = "No agent gets refreshed!";
|
refreshResult = "No agent gets migrated!";
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation(refreshResult);
|
_logger.LogInformation(refreshResult);
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,9 @@ public class AgentController : ControllerBase
|
||||||
|
|
||||||
[BotSharpAuth]
|
[BotSharpAuth]
|
||||||
[HttpPost("/refresh-agents")]
|
[HttpPost("/refresh-agents")]
|
||||||
public async Task<string> RefreshAgents()
|
public async Task<string> RefreshAgents([FromBody] AgentMigrationModel request)
|
||||||
{
|
{
|
||||||
return await _agentService.RefreshAgents();
|
return await _agentService.RefreshAgents(request?.AgentIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("/agent/file/{agentId}")]
|
[HttpPut("/agent/file/{agentId}")]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace BotSharp.OpenAPI.ViewModels.Agents;
|
||||||
|
|
||||||
|
public class AgentMigrationModel
|
||||||
|
{
|
||||||
|
[JsonPropertyName("agent_ids")]
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public IEnumerable<string>? AgentIds { get; set; }
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue