Avoid duplicated utility templates.
This commit is contained in:
parent
8a6eb7d2ef
commit
36a387eb3e
|
|
@ -35,12 +35,15 @@ public class BasicAgentHook : AgentHookBase
|
|||
|
||||
foreach (var prompt in templates)
|
||||
{
|
||||
agent.SecondaryInstructions.Add(prompt);
|
||||
if (!agent.SecondaryInstructions.Any(x => x.Contains(prompt.Content, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
agent.SecondaryInstructions.Add(prompt.Content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private (IEnumerable<FunctionDef>, IEnumerable<string>) GetUtilityContent(Agent agent)
|
||||
private (IEnumerable<FunctionDef>, IEnumerable<AgentTemplate>) GetUtilityContent(Agent agent)
|
||||
{
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
var (functionNames, templateNames) = GetUniqueContent(agent.Utilities);
|
||||
|
|
@ -60,7 +63,7 @@ public class BasicAgentHook : AgentHookBase
|
|||
|
||||
var ua = db.GetAgent(BuiltInAgentId.UtilityAssistant);
|
||||
var functions = ua?.Functions?.Where(x => functionNames.Contains(x.Name, StringComparer.OrdinalIgnoreCase))?.ToList() ?? [];
|
||||
var templates = ua?.Templates?.Where(x => templateNames.Contains(x.Name, StringComparer.OrdinalIgnoreCase))?.Select(x => x.Content)?.ToList() ?? [];
|
||||
var templates = ua?.Templates?.Where(x => templateNames.Contains(x.Name, StringComparer.OrdinalIgnoreCase))?.ToList() ?? [];
|
||||
return (functions, templates);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,6 +167,12 @@ public class TwilioInboundController : TwilioController
|
|||
new("twilio_call_sid", request.CallSid),
|
||||
};
|
||||
|
||||
if (request.Direction == "inbound")
|
||||
{
|
||||
states.Add(new MessageState("calling_phone_from", request.From));
|
||||
states.Add(new MessageState("calling_phone_to", request.To));
|
||||
}
|
||||
|
||||
var requestStates = ParseStates(request.States);
|
||||
foreach (var s in requestStates)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue