rename
This commit is contained in:
parent
e70cd70e46
commit
99dd39d9ba
|
|
@ -57,7 +57,7 @@ public abstract class AgentHookBase : IAgentHook
|
|||
{
|
||||
}
|
||||
|
||||
public virtual void OnLoadAgentUtility(Agent agent, IEnumerable<AgentUtilityLoadModel> utilities)
|
||||
public virtual void OnLoadAgentUtility(Agent agent, IEnumerable<AgentUtility> utilities)
|
||||
{
|
||||
if (agent.Type == AgentType.Routing || utilities.IsNullOrEmpty()) return;
|
||||
|
||||
|
|
@ -70,14 +70,14 @@ public abstract class AgentHookBase : IAgentHook
|
|||
agent.Functions ??= [];
|
||||
var agentUtilities = agent.Utilities ?? [];
|
||||
|
||||
foreach (var item in utilities)
|
||||
foreach (var utillity in utilities)
|
||||
{
|
||||
if (item.UtilityName.IsNullOrEmpty() || item.Content == null) continue;
|
||||
if (utillity.Name.IsNullOrEmpty() || utillity.Content == null) continue;
|
||||
|
||||
var isEnabled = agentUtilities.Contains(item.UtilityName);
|
||||
var isEnabled = agentUtilities.Contains(utillity.Name);
|
||||
if (!isEnabled) continue;
|
||||
|
||||
var (fns, prompts) = GetUtilityContent(item.Content);
|
||||
var (fns, prompts) = GetUtilityContent(utillity.Content);
|
||||
|
||||
if (!fns.IsNullOrEmpty())
|
||||
{
|
||||
|
|
@ -121,10 +121,6 @@ public abstract class AgentHookBase : IAgentHook
|
|||
var prompt = agent?.Templates?.FirstOrDefault(x => x.Name.IsEqualTo(template.Name))?.Content ?? string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(prompt)) continue;
|
||||
|
||||
if (!template.Data.IsNullOrEmpty())
|
||||
{
|
||||
prompt = render.Render(prompt, template.Data);
|
||||
}
|
||||
prompts.Add(prompt);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,5 +32,5 @@ public interface IAgentHook
|
|||
/// <returns></returns>
|
||||
void OnAgentLoaded(Agent agent);
|
||||
|
||||
void OnLoadAgentUtility(Agent agent, IEnumerable<AgentUtilityLoadModel> utilities);
|
||||
void OnLoadAgentUtility(Agent agent, IEnumerable<AgentUtility> utilities);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
namespace BotSharp.Abstraction.Agents.Models;
|
||||
|
||||
public class AgentUtilityLoadModel
|
||||
public class AgentUtility
|
||||
{
|
||||
public string UtilityName { get; set; }
|
||||
public string Name { get; set; }
|
||||
public UtilityContent Content { get; set; }
|
||||
|
||||
public AgentUtilityLoadModel()
|
||||
public AgentUtility()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public AgentUtilityLoadModel(string utilityName, UtilityContent content)
|
||||
public AgentUtility(string utilityName, UtilityContent content)
|
||||
{
|
||||
UtilityName = utilityName;
|
||||
Name = utilityName;
|
||||
Content = content;
|
||||
}
|
||||
}
|
||||
|
|
@ -44,17 +44,14 @@ public class UtilityFunction : UtilityBase
|
|||
|
||||
public class UtilityTemplate : UtilityBase
|
||||
{
|
||||
public Dictionary<string, object>? Data { get; set; }
|
||||
|
||||
public UtilityTemplate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UtilityTemplate(string name, Dictionary<string, object>? data = null)
|
||||
public UtilityTemplate(string name)
|
||||
{
|
||||
Name = name;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -15,9 +15,9 @@ public class AudioHandlerHook : AgentHookBase, IAgentHook
|
|||
|
||||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var utilityLoad = new AgentUtilityLoadModel
|
||||
var utilityLoad = new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.AudioHandler,
|
||||
Name = UtilityName.AudioHandler,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(HANDLER_AUDIO)],
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ public class EmailHandlerHook : AgentHookBase
|
|||
|
||||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var utilityLoad = new AgentUtilityLoadModel
|
||||
var utilityLoad = new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.EmailHandler,
|
||||
Name = UtilityName.EmailHandler,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(EMAIL_READER_FN), new(EMAIL_SENDER_FN)],
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ public class ExcelHandlerHook : AgentHookBase, IAgentHook
|
|||
|
||||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var utilityLoad = new AgentUtilityLoadModel
|
||||
var utilityLoad = new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.ExcelHandler,
|
||||
Name = UtilityName.ExcelHandler,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(HANDLER_EXCEL)],
|
||||
|
|
|
|||
|
|
@ -15,38 +15,38 @@ public class FileHandlerHook : AgentHookBase, IAgentHook
|
|||
|
||||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var utilityLoads = new List<AgentUtilityLoadModel>
|
||||
var utilityLoads = new List<AgentUtility>
|
||||
{
|
||||
new AgentUtilityLoadModel
|
||||
new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.ImageGenerator,
|
||||
Name = UtilityName.ImageGenerator,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(GENERATE_IMAGE_FN)],
|
||||
Templates = [new($"{GENERATE_IMAGE_FN}.fn")]
|
||||
}
|
||||
},
|
||||
new AgentUtilityLoadModel
|
||||
new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.ImageReader,
|
||||
Name = UtilityName.ImageReader,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(READ_IMAGE_FN)],
|
||||
Templates = [new($"{READ_IMAGE_FN}.fn")]
|
||||
}
|
||||
},
|
||||
new AgentUtilityLoadModel
|
||||
new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.ImageEditor,
|
||||
Name = UtilityName.ImageEditor,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(EDIT_IMAGE_FN)],
|
||||
Templates = [new($"{EDIT_IMAGE_FN}.fn")]
|
||||
}
|
||||
},
|
||||
new AgentUtilityLoadModel
|
||||
new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.PdfReader,
|
||||
Name = UtilityName.PdfReader,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(READ_PDF_FN)],
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ public class HttpHandlerHook : AgentHookBase
|
|||
|
||||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var utilityLoad = new AgentUtilityLoadModel
|
||||
var utilityLoad = new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.HttpHandler,
|
||||
Name = UtilityName.HttpHandler,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(HTTP_HANDLER_FN)],
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ public class KnowledgeBaseAgentHook : AgentHookBase, IAgentHook
|
|||
|
||||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var utilityLoad = new AgentUtilityLoadModel
|
||||
var utilityLoad = new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.KnowledgeRetrieval,
|
||||
Name = UtilityName.KnowledgeRetrieval,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(KNOWLEDGE_RETRIEVAL_FN)],
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ public class PlannerAgentHook : AgentHookBase
|
|||
|
||||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var utilityLoad = new AgentUtilityLoadModel
|
||||
var utilityLoad = new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.TwoStagePlanner,
|
||||
Name = UtilityName.TwoStagePlanner,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [
|
||||
|
|
|
|||
|
|
@ -19,38 +19,35 @@ public class SqlDriverAgentHook : AgentHookBase, IAgentHook
|
|||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var dbType = SqlDriverHelper.GetDatabaseType(_services);
|
||||
var promptData = new Dictionary<string, object>
|
||||
{
|
||||
{ "db_type", dbType }
|
||||
};
|
||||
agent.TemplateDict["db_type"] = dbType;
|
||||
|
||||
var utilityLoads = new List<AgentUtilityLoadModel>
|
||||
var utilityLoads = new List<AgentUtility>
|
||||
{
|
||||
new AgentUtilityLoadModel
|
||||
new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.SqlTableDefinition,
|
||||
Name = UtilityName.SqlTableDefinition,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = new List<UtilityFunction> { new(SQL_TABLE_DEFINITION_FN) },
|
||||
Templates = new List<UtilityTemplate> { new($"{SQL_TABLE_DEFINITION_FN}.fn", promptData) }
|
||||
Templates = new List<UtilityTemplate> { new($"{SQL_TABLE_DEFINITION_FN}.fn") }
|
||||
}
|
||||
},
|
||||
new AgentUtilityLoadModel
|
||||
new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.SqlDictionaryLookup,
|
||||
Name = UtilityName.SqlDictionaryLookup,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = new List<UtilityFunction> { new(VERIFY_DICTIONARY_TERM_FN) },
|
||||
Templates = new List<UtilityTemplate> { new($"{VERIFY_DICTIONARY_TERM_FN}.fn", promptData) }
|
||||
Templates = new List<UtilityTemplate> { new($"{VERIFY_DICTIONARY_TERM_FN}.fn") }
|
||||
}
|
||||
},
|
||||
new AgentUtilityLoadModel
|
||||
new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.SqlExecutor,
|
||||
Name = UtilityName.SqlExecutor,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = new List<UtilityFunction> { new(SQL_SELECT_FN), new(SQL_TABLE_DEFINITION_FN) },
|
||||
Templates = new List<UtilityTemplate> { new($"sql_executor.fn", promptData) }
|
||||
Templates = new List<UtilityTemplate> { new($"sql_executor.fn") }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ namespace BotSharp.Plugin.Twilio.OutboundPhoneCallHandler.Hooks
|
|||
|
||||
public override void OnAgentLoaded(Agent agent)
|
||||
{
|
||||
var utilityLoad = new AgentUtilityLoadModel
|
||||
var utilityLoad = new AgentUtility
|
||||
{
|
||||
UtilityName = UtilityName.OutboundPhoneCall,
|
||||
Name = UtilityName.OutboundPhoneCall,
|
||||
Content = new UtilityContent
|
||||
{
|
||||
Functions = [new(OUTBOUND_PHONE_CALL_FN)],
|
||||
|
|
|
|||
Loading…
Reference in a new issue