add agent tools api
This commit is contained in:
parent
f65eeddb8e
commit
8d798a4399
|
|
@ -51,4 +51,6 @@ public interface IAgentService
|
|||
List<Agent> GetAgentsByUser(string userId);
|
||||
|
||||
PluginDef GetPlugin(string agentId);
|
||||
|
||||
IEnumerable<string> GetAgentTools();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BotSharp.Core.Agents.Services;
|
||||
|
||||
|
|
@ -53,4 +54,14 @@ public partial class AgentService : IAgentService
|
|||
var agents = _db.GetAgentsByUser(userId);
|
||||
return agents;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAgentTools()
|
||||
{
|
||||
var tools = typeof(AgentTool).GetFields(BindingFlags.Public | BindingFlags.Static)
|
||||
.Where(f => f.IsLiteral && f.FieldType == typeof(string))
|
||||
.Select(x => x.GetRawConstantValue()?.ToString())
|
||||
.ToList();
|
||||
|
||||
return tools;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,4 +140,10 @@ public class AgentController : ControllerBase
|
|||
{
|
||||
return await _agentService.DeleteAgent(agentId);
|
||||
}
|
||||
|
||||
[HttpGet("/agent/tools")]
|
||||
public IEnumerable<string> GetAgentTools()
|
||||
{
|
||||
return _agentService.GetAgentTools();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue