Skip to content

Commit f41820f

Browse files
authored
Merge pull request #928 from iceljc/master
refine state key search
2 parents a006f6a + 9f71816 commit f41820f

File tree

24 files changed

+246
-79
lines changed

24 files changed

+246
-79
lines changed

src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public interface IAgentService
1212
Task<Agent> CreateAgent(Agent agent);
1313
Task<string> RefreshAgents();
1414
Task<PagedItems<Agent>> GetAgents(AgentFilter filter);
15-
Task<List<IdName>> GetAgentOptions();
15+
Task<List<IdName>> GetAgentOptions(List<string>? agentIds = null);
1616

1717
/// <summary>
1818
/// Load agent configurations and trigger hooks

src/Infrastructure/BotSharp.Abstraction/Conversations/Enums/MessageTypeName.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ public static class MessageTypeName
66
public const string Notification = "notification";
77
public const string FunctionCall = "function";
88
public const string Audio = "audio";
9+
public const string Error = "error";
910
}

src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,7 @@ Task<bool> SendMessage(string agentId,
6262

6363
void SaveStates();
6464

65-
/// <summary>
66-
/// Get conversation keys for searching
67-
/// </summary>
68-
/// <param name="query">search query</param>
69-
/// <param name="convLimit">conversation limit</param>
70-
/// <param name="preLoad">if pre-loading, then keys are not filter by the search query</param>
71-
/// <returns></returns>
72-
Task<List<string>> GetConversationStateSearhKeys(string query, int convLimit = 100, int keyLimit = 10, bool preload = false);
65+
Task<List<string>> GetConversationStateSearhKeys(ConversationStateKeysFilter filter);
7366

7467
Task<bool> MigrateLatestStates(int batchSize = 100, int errorLimit = 10);
7568
}

src/Infrastructure/BotSharp.Abstraction/Loggers/Services/ILoggerService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using BotSharp.Abstraction.Instructs.Models;
21
using BotSharp.Abstraction.Loggers.Models;
2+
using BotSharp.Abstraction.Repositories.Filters;
33

44
namespace BotSharp.Abstraction.Loggers.Services;
55

@@ -12,5 +12,6 @@ public interface ILoggerService
1212

1313
#region Instruction
1414
Task<PagedItems<InstructionLogModel>> GetInstructionLogs(InstructLogFilter filter);
15+
Task<List<string>> GetInstructionLogSearchKeys(InstructLogKeysFilter filter);
1516
#endregion
1617
}

src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/ConversationFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public class ConversationFilter
2323
/// <summary>
2424
/// Check whether each key in the list is in the conversation states and its value equals to target value if not empty
2525
/// </summary>
26-
public IEnumerable<KeyValue>? States { get; set; } = [];
26+
public List<KeyValue>? States { get; set; }
2727

28-
public IEnumerable<string>? Tags { get; set; } = [];
28+
public List<string>? Tags { get; set; }
2929

3030
public static ConversationFilter Empty()
3131
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace BotSharp.Abstraction.Repositories.Filters;
2+
3+
public class ConversationStateKeysFilter
4+
{
5+
public string? Query { get; set; }
6+
public int KeyLimit { get; set; } = 10;
7+
public int ConvLimit { get; set; } = 100;
8+
public bool PreLoad { get; set; }
9+
public List<string>? AgentIds { get; set; }
10+
public List<string>? UserIds { get; set; }
11+
12+
public ConversationStateKeysFilter()
13+
{
14+
15+
}
16+
17+
public static ConversationStateKeysFilter Empty()
18+
{
19+
return new();
20+
}
21+
}

src/Infrastructure/BotSharp.Abstraction/Instructs/Models/InstructLogFilter.cs renamed to src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/InstructLogFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BotSharp.Abstraction.Instructs.Models;
1+
namespace BotSharp.Abstraction.Repositories.Filters;
22

33
public class InstructLogFilter : Pagination
44
{
@@ -11,6 +11,6 @@ public class InstructLogFilter : Pagination
1111

1212
public static InstructLogFilter Empty()
1313
{
14-
return new InstructLogFilter();
14+
return new();
1515
}
1616
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace BotSharp.Abstraction.Repositories.Filters;
2+
3+
public class InstructLogKeysFilter
4+
{
5+
public string? Query { get; set; }
6+
public int KeyLimit { get; set; } = 10;
7+
public int LogLimit { get; set; } = 100;
8+
public bool PreLoad { get; set; }
9+
public List<string>? AgentIds { get; set; }
10+
public List<string>? UserIds { get; set; }
11+
12+
public InstructLogKeysFilter()
13+
{
14+
15+
}
16+
17+
public static InstructLogKeysFilter Empty()
18+
{
19+
return new();
20+
}
21+
}

src/Infrastructure/BotSharp.Abstraction/Repositories/IBotSharpRepository.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using BotSharp.Abstraction.Instructs.Models;
21
using BotSharp.Abstraction.Loggers.Models;
32
using BotSharp.Abstraction.Plugins.Models;
43
using BotSharp.Abstraction.Repositories.Filters;
@@ -149,7 +148,7 @@ List<string> GetIdleConversations(int batchSize, int messageLimit, int bufferHou
149148
=> throw new NotImplementedException();
150149
List<string> TruncateConversation(string conversationId, string messageId, bool cleanLog = false)
151150
=> throw new NotImplementedException();
152-
List<string> GetConversationStateSearchKeys(int messageLowerLimit = 2, int convUpperLimit = 100)
151+
List<string> GetConversationStateSearchKeys(ConversationStateKeysFilter filter)
153152
=> throw new NotImplementedException();
154153
List<string> GetConversationsToMigrate(int batchSize = 100)
155154
=> throw new NotImplementedException();
@@ -182,6 +181,9 @@ bool SaveInstructionLogs(IEnumerable<InstructionLogModel> logs)
182181

183182
PagedItems<InstructionLogModel> GetInstructionLogs(InstructLogFilter filter)
184183
=> throw new NotImplementedException();
184+
185+
List<string> GetInstructionLogSearchKeys(InstructLogKeysFilter filter)
186+
=> throw new NotImplementedException();
185187
#endregion
186188

187189
#region Statistics

src/Infrastructure/BotSharp.Abstraction/Users/IUserService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public interface IUserService
1010
Task<PagedItems<User>> GetUsers(UserFilter filter);
1111
Task<List<User>> SearchLoginUsers(User filter);
1212
Task<User?> GetUserDetails(string userId, bool includeAgent = false);
13-
Task<bool> IsAdminUser(string userId);
13+
Task<(bool, User?)> IsAdminUser(string userId);
1414
Task<UserAuthorization> GetUserAuthorizations(IEnumerable<string>? agentIds = null);
1515
Task<bool> UpdateUser(User user, bool isUpdateUserAgents = false);
1616
Task<User> CreateUser(User user);

0 commit comments

Comments
 (0)