refine
This commit is contained in:
parent
c3459e34d4
commit
a3344c6caf
|
|
@ -12,6 +12,7 @@ public interface IAgentService
|
|||
Task<Agent> CreateAgent(Agent agent);
|
||||
Task<string> RefreshAgents();
|
||||
Task<PagedItems<Agent>> GetAgents(AgentFilter filter);
|
||||
Task<List<IdName>> GetAgentOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Load agent configurations and trigger hooks
|
||||
|
|
|
|||
21
src/Infrastructure/BotSharp.Abstraction/Models/IdName.cs
Normal file
21
src/Infrastructure/BotSharp.Abstraction/Models/IdName.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
namespace BotSharp.Abstraction.Models;
|
||||
|
||||
public class IdName
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = default!;
|
||||
|
||||
public IdName(string id, string name)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Id}: {Name}";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using BotSharp.Abstraction.Models;
|
||||
using BotSharp.Abstraction.Routing.Settings;
|
||||
|
||||
namespace BotSharp.Core.Agents.Services;
|
||||
|
|
@ -26,6 +27,15 @@ public partial class AgentService
|
|||
};
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
[SharpCache(10, perInstanceCache: true)]
|
||||
#endif
|
||||
public async Task<List<IdName>> GetAgentOptions()
|
||||
{
|
||||
var agents = _db.GetAgents(AgentFilter.Empty());
|
||||
return agents?.Select(x => new IdName(x.Id, x.Name))?.OrderBy(x => x.Name)?.ToList() ?? [];
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
[SharpCache(10, perInstanceCache: true)]
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -149,6 +149,12 @@ public class AgentController : ControllerBase
|
|||
return await _agentService.DeleteAgent(agentId);
|
||||
}
|
||||
|
||||
[HttpGet("/agent/options")]
|
||||
public async Task<List<IdName>> GetAgentOptions()
|
||||
{
|
||||
return await _agentService.GetAgentOptions();
|
||||
}
|
||||
|
||||
[HttpGet("/agent/utility/options")]
|
||||
public IEnumerable<AgentUtility> GetAgentUtilityOptions()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class DialogMongoElement
|
|||
}
|
||||
}
|
||||
|
||||
[BsonIgnoreExtraElements(Inherited = true)]
|
||||
public class DialogMetaDataMongoElement
|
||||
{
|
||||
public string Role { get; set; } = default!;
|
||||
|
|
@ -50,7 +51,7 @@ public class DialogMetaDataMongoElement
|
|||
public string MessageType { get; set; } = default!;
|
||||
public string? FunctionName { get; set; }
|
||||
public string? SenderId { get; set; }
|
||||
public DateTime CreatedTime { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public static DialogMetaData ToDomainElement(DialogMetaDataMongoElement meta)
|
||||
{
|
||||
|
|
@ -62,7 +63,7 @@ public class DialogMetaDataMongoElement
|
|||
MessageType = meta.MessageType,
|
||||
FunctionName = meta.FunctionName,
|
||||
SenderId = meta.SenderId,
|
||||
CreatedTime = meta.CreatedTime,
|
||||
CreatedTime = meta.CreateTime,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ public class DialogMetaDataMongoElement
|
|||
MessageType = meta.MessageType,
|
||||
FunctionName = meta.FunctionName,
|
||||
SenderId = meta.SenderId,
|
||||
CreatedTime = meta.CreatedTime,
|
||||
CreateTime = meta.CreatedTime,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ public partial class MongoRepository
|
|||
var truncatedDialogs = foundDialog.Dialogs.Where((x, idx) => idx < foundIdx).ToList();
|
||||
|
||||
// Handle truncated states
|
||||
var refTime = foundDialog.Dialogs.ElementAt(foundIdx).MetaData.CreatedTime;
|
||||
var refTime = foundDialog.Dialogs.ElementAt(foundIdx).MetaData.CreateTime;
|
||||
var stateFilter = Builders<ConversationStateDocument>.Filter.Eq(x => x.ConversationId, conversationId);
|
||||
var foundStates = _dc.ConversationStates.Find(stateFilter).FirstOrDefault();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue