use list extension
This commit is contained in:
parent
b5c90c02bc
commit
f381208498
|
|
@ -2,7 +2,7 @@ namespace BotSharp.Abstraction.Utilities;
|
|||
|
||||
public static class ListExtenstion
|
||||
{
|
||||
public static bool IsEmpty(this IEnumerable<string> strList)
|
||||
public static bool IsEmpty<T>(this IEnumerable<T> strList)
|
||||
{
|
||||
return strList == null || !strList.Any();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public partial class AgentService
|
|||
hook.OnInstructionLoaded(agent.Instruction, templateDict);
|
||||
}
|
||||
|
||||
if (agent.Functions != null && agent.Functions.Any())
|
||||
if (!agent.Functions.IsEmpty())
|
||||
{
|
||||
var functions = agent.Functions;
|
||||
hook.OnFunctionsLoaded(ref functions);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ public partial class AgentService
|
|||
if (!string.IsNullOrEmpty(agent.Instruction))
|
||||
record.Instruction = agent.Instruction;
|
||||
|
||||
if (agent.Functions != null && agent.Functions.Any())
|
||||
if (!agent.Functions.IsEmpty())
|
||||
record.Functions = agent.Functions;
|
||||
|
||||
if (agent.Responses != null && agent.Responses.Any())
|
||||
if (!agent.Responses.IsEmpty())
|
||||
record.Responses = agent.Responses;
|
||||
|
||||
db.UpdateAgent(record);
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ public class FileRepository : IBotSharpRepository
|
|||
File.WriteAllText(instructionFile, agent.Instruction);
|
||||
}
|
||||
|
||||
if (agent.Functions != null || agent.Functions.Any())
|
||||
if (!agent.Functions.IsEmpty())
|
||||
{
|
||||
var functionFile = Path.Combine(dir, "functions.json");
|
||||
var functions = new List<string>();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class Router : IAgentRouting
|
|||
var records = db.RoutingItem.Select(x => x.ToRoutingItem()).ToArray();
|
||||
var profiles = db.RoutingProfile.ToList();
|
||||
|
||||
if (profiles != null && profiles.Any())
|
||||
if (!profiles.IsEmpty())
|
||||
{
|
||||
var state = _services.GetRequiredService<IConversationStateService>();
|
||||
var name = state.GetState("channel");
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ public class AgentUpdateModel
|
|||
if (Samples != null)
|
||||
agent.Samples = Samples;
|
||||
|
||||
if (Functions != null && Functions.Any())
|
||||
if (!Functions.IsEmpty())
|
||||
agent.Functions = Functions;
|
||||
|
||||
if (Responses != null && Responses.Any())
|
||||
if (!Responses.IsEmpty())
|
||||
agent.Responses = Responses;
|
||||
|
||||
return agent;
|
||||
|
|
|
|||
Loading…
Reference in a new issue