Merge branch 'master' of https://github.com/SciSharp/BotSharp into features/refine-file-instruct
This commit is contained in:
commit
f5242a83b3
|
|
@ -35,7 +35,7 @@
|
|||
<PackageVersion Include="EntityFrameworkCore.BootKit" Version="8.9.0" />
|
||||
<PackageVersion Include="Fluid.Core" Version="2.11.1" />
|
||||
<PackageVersion Include="Nanoid" Version="3.1.0" />
|
||||
<PackageVersion Include="Swashbuckle.AspNetCore" Version="8.1.0" />
|
||||
<PackageVersion Include="Swashbuckle.AspNetCore" Version="8.1.2" />
|
||||
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="8.0.1" />
|
||||
<PackageVersion Include="Anthropic.SDK" Version="5.1.1" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
|
|
@ -132,12 +132,12 @@
|
|||
<PackageVersion Include="BotSharp.Plugin.ChatHub" Version="$(BotSharpVersion)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.14" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.16" />
|
||||
<PackageVersion Include="AspNet.Security.OAuth.GitHub" Version="8.3.0" />
|
||||
<PackageVersion Include="AspNet.Security.OAuth.Keycloak" Version="8.3.0" />
|
||||
<PackageVersion Include="AspNet.Security.OAuth.Weixin" Version="8.3.0" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.14" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.14" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.16" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.16" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Google" Version="6.0.27" />
|
||||
|
|
@ -147,4 +147,4 @@
|
|||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.25" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.26" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public interface IAgentService
|
|||
|
||||
FunctionParametersDef? RenderFunctionProperty(Agent agent, FunctionDef def);
|
||||
|
||||
bool RenderVisibility(string? visibilityExpression, Dictionary<string, object> dict);
|
||||
|
||||
/// <summary>
|
||||
/// Get agent detail without trigger any hook.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -2,60 +2,38 @@ namespace BotSharp.Abstraction.Agents.Models;
|
|||
|
||||
public class AgentUtility
|
||||
{
|
||||
public string Category { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool Disabled { get; set; }
|
||||
public IEnumerable<UtilityFunction> Functions { get; set; } = [];
|
||||
public IEnumerable<UtilityTemplate> Templates { get; set; } = [];
|
||||
|
||||
[JsonPropertyName("visibility_expression")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? VisibilityExpression { get; set; }
|
||||
|
||||
public IEnumerable<UtilityItem> Items { get; set; } = [];
|
||||
|
||||
public AgentUtility()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public AgentUtility(
|
||||
string name,
|
||||
IEnumerable<UtilityFunction>? functions = null,
|
||||
IEnumerable<UtilityTemplate>? templates = null)
|
||||
{
|
||||
Name = name;
|
||||
Functions = functions ?? [];
|
||||
Templates = templates ?? [];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
return $"{Category}-{Name}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class UtilityFunction : UtilityBase
|
||||
public class UtilityItem
|
||||
{
|
||||
public UtilityFunction()
|
||||
{
|
||||
|
||||
}
|
||||
[JsonPropertyName("function_name")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? FunctionName { get; set; }
|
||||
|
||||
public UtilityFunction(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
[JsonPropertyName("template_name")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? TemplateName { get; set; }
|
||||
|
||||
public class UtilityTemplate : UtilityBase
|
||||
{
|
||||
public UtilityTemplate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UtilityTemplate(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public class UtilityBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
[JsonPropertyName("visibility_expression")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? VisibilityExpression { get; set; }
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
using BotSharp.Abstraction.Loggers.Models;
|
||||
using BotSharp.Abstraction.Repositories.Filters;
|
||||
|
||||
namespace BotSharp.Abstraction.Conversations;
|
||||
|
|
@ -53,7 +52,7 @@ public interface IConversationService
|
|||
/// <returns></returns>
|
||||
Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates);
|
||||
|
||||
Task<string> GetConversationSummary(IEnumerable<string> conversationId);
|
||||
Task<string> GetConversationSummary(ConversationSummaryModel model);
|
||||
|
||||
Task<Conversation> GetConversationRecordOrCreateNew(string agentId);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BotSharp.Abstraction.Models;
|
||||
|
||||
public class ConversationSummaryModel
|
||||
{
|
||||
[JsonPropertyName("conversation_ids")]
|
||||
public IEnumerable<string> ConversationIds { get; set; } = new List<string>();
|
||||
|
||||
private string _agentId;
|
||||
|
||||
[JsonPropertyName("agent_id")]
|
||||
public string AgentId
|
||||
{
|
||||
get => _agentId ?? BuiltInAgentId.AIAssistant;
|
||||
set => _agentId = value;
|
||||
}
|
||||
|
||||
private string _templateName;
|
||||
|
||||
[JsonPropertyName("template_name")]
|
||||
public string TemplateName
|
||||
{
|
||||
get => _templateName ?? "conversation.summary";
|
||||
set => _templateName = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using BotSharp.Abstraction.Users.Models;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BotSharp.Abstraction.Users;
|
||||
|
|
@ -11,7 +12,8 @@ public interface IAuthenticationHook
|
|||
/// <param name="id"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
Task<User> Authenticate(string id, string password);
|
||||
Task<User> Authenticate(string id, string password)
|
||||
=> Task.FromResult(new User());
|
||||
|
||||
/// <summary>
|
||||
/// Add extra claims to user
|
||||
|
|
@ -30,31 +32,38 @@ public interface IAuthenticationHook
|
|||
bool UserAuthenticated(User user, Token token)
|
||||
=> true;
|
||||
|
||||
Task OAuthCompleted(TicketReceivedContext context)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Bfore user updating
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
Task UserUpdating(User user);
|
||||
Task UserUpdating(User user)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// After user created
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
Task UserCreated(User user);
|
||||
Task UserCreated(User user)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Reset password
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
Task SendVerificationCode(User user);
|
||||
Task SendVerificationCode(User user)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Delete users
|
||||
/// </summary>
|
||||
/// <param name="userIds"></param>
|
||||
/// <returns></returns>
|
||||
Task DelUsers(List<string> userIds);
|
||||
Task DelUsers(List<string> userIds)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ namespace BotSharp.Core.Crontab.Enum;
|
|||
|
||||
public class UtilityName
|
||||
{
|
||||
public const string ScheduleTask = "crontab.schedule-task";
|
||||
public const string ScheduleTask = "schedule-task";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,19 @@ public class CrontabUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
new AgentUtility
|
||||
{
|
||||
Category = "crontab",
|
||||
Name = UtilityName.ScheduleTask,
|
||||
Functions = [new(SCHEDULE_TASK_FN), new(TASK_WAIT_FN)],
|
||||
Templates = [new($"{SCHEDULE_TASK_FN}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = SCHEDULE_TASK_FN,
|
||||
TemplateName = $"{SCHEDULE_TASK_FN}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = TASK_WAIT_FN
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ public class BasicAgentHook : AgentHookBase
|
|||
var isConvMode = conv.IsConversationMode();
|
||||
if (!isConvMode) return;
|
||||
|
||||
agent.Utilities ??= [];
|
||||
agent.SecondaryFunctions ??= [];
|
||||
agent.SecondaryInstructions ??= [];
|
||||
agent.Utilities ??= [];
|
||||
|
||||
var (functions, templates) = GetUtilityContent(agent);
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ public class BasicAgentHook : AgentHookBase
|
|||
private (IEnumerable<FunctionDef>, IEnumerable<AgentTemplate>) GetUtilityContent(Agent agent)
|
||||
{
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
var (functionNames, templateNames) = GetUniqueContent(agent.Utilities);
|
||||
var (functionNames, templateNames) = FilterUtilityContent(agent.Utilities, agent);
|
||||
|
||||
if (agent.MergeUtility)
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ public class BasicAgentHook : AgentHookBase
|
|||
if (!string.IsNullOrEmpty(entryAgentId))
|
||||
{
|
||||
var entryAgent = db.GetAgent(entryAgentId, basicsOnly: true);
|
||||
var (fns, tps) = GetUniqueContent(entryAgent?.Utilities);
|
||||
var (fns, tps) = FilterUtilityContent(entryAgent?.Utilities, agent);
|
||||
functionNames = functionNames.Concat(fns).Distinct().ToList();
|
||||
templateNames = templateNames.Concat(tps).Distinct().ToList();
|
||||
}
|
||||
|
|
@ -55,23 +55,41 @@ public class BasicAgentHook : AgentHookBase
|
|||
return (functions, templates);
|
||||
}
|
||||
|
||||
private (IEnumerable<string>, IEnumerable<string>) GetUniqueContent(IEnumerable<AgentUtility>? utilities)
|
||||
private (IEnumerable<string>, IEnumerable<string>) FilterUtilityContent(IEnumerable<AgentUtility>? utilities, Agent agent)
|
||||
{
|
||||
if (utilities.IsNullOrEmpty())
|
||||
{
|
||||
return ([], []);
|
||||
}
|
||||
|
||||
utilities = utilities?.Where(x => !string.IsNullOrEmpty(x.Name) && !x.Disabled)?.ToList() ?? [];
|
||||
var functionNames = utilities.SelectMany(x => x.Functions)
|
||||
.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.StartsWith(UTIL_PREFIX))
|
||||
.Select(x => x.Name)
|
||||
.Distinct().ToList();
|
||||
var templateNames = utilities.SelectMany(x => x.Templates)
|
||||
.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.StartsWith(UTIL_PREFIX))
|
||||
.Select(x => x.Name)
|
||||
.Distinct().ToList();
|
||||
var agentService = _services.GetRequiredService<IAgentService>();
|
||||
var innerUtilities = utilities!.Where(x => !string.IsNullOrEmpty(x.Name) && !x.Disabled).ToList();
|
||||
|
||||
return (functionNames, templateNames);
|
||||
var functionNames = new List<string>();
|
||||
var templateNames = new List<string>();
|
||||
|
||||
foreach (var utility in innerUtilities)
|
||||
{
|
||||
var isVisible = agentService.RenderVisibility(utility.VisibilityExpression, agent.TemplateDict);
|
||||
if (!isVisible || utility.Items.IsNullOrEmpty()) continue;
|
||||
|
||||
foreach (var item in utility.Items)
|
||||
{
|
||||
isVisible = agentService.RenderVisibility(item.VisibilityExpression, agent.TemplateDict);
|
||||
if (!isVisible) continue;
|
||||
|
||||
if (item.FunctionName?.StartsWith(UTIL_PREFIX) == true)
|
||||
{
|
||||
functionNames.Add(item.FunctionName);
|
||||
}
|
||||
|
||||
if (item.TemplateName?.StartsWith(UTIL_PREFIX) == true)
|
||||
{
|
||||
templateNames.Add(item.TemplateName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (functionNames.Distinct(), templateNames.Distinct());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,13 +71,25 @@ public partial class AgentService
|
|||
|
||||
profile.Plugin = GetPlugin(profile.Id);
|
||||
|
||||
//add default instruction to ChannelInstructions
|
||||
var defaultInstruction = new ChannelInstruction() { Channel = string.Empty, Instruction = profile?.Instruction };
|
||||
profile.ChannelInstructions.Insert(0, defaultInstruction);
|
||||
AddDefaultInstruction(profile, profile.Instruction);
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default instruction to ChannelInstructions
|
||||
/// </summary>
|
||||
private void AddDefaultInstruction(Agent agent, string instruction)
|
||||
{
|
||||
//check if instruction is empty
|
||||
if (string.IsNullOrWhiteSpace(instruction)) return;
|
||||
//check if instruction is already set
|
||||
if (agent.ChannelInstructions.Exists(p => p.Channel == string.Empty)) return;
|
||||
//Add default instruction to ChannelInstructions
|
||||
var defaultInstruction = new ChannelInstruction() { Channel = string.Empty, Instruction = instruction };
|
||||
agent.ChannelInstructions.Insert(0, defaultInstruction);
|
||||
}
|
||||
|
||||
public async Task InheritAgent(Agent agent)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(agent?.InheritAgentId)) return;
|
||||
|
|
@ -98,6 +110,7 @@ public partial class AgentService
|
|||
if (string.IsNullOrWhiteSpace(agent.Instruction))
|
||||
{
|
||||
agent.Instruction = inheritedAgent.Instruction;
|
||||
AddDefaultInstruction(agent, inheritedAgent.Instruction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using BotSharp.Abstraction.Infrastructures;
|
||||
using BotSharp.Abstraction.Routing.Models;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
|
@ -18,12 +17,15 @@ public partial class AgentService
|
|||
var agent = await GetAgent(id);
|
||||
if (agent == null) return null;
|
||||
|
||||
agent.TemplateDict = [];
|
||||
agent.SecondaryInstructions = [];
|
||||
agent.SecondaryFunctions = [];
|
||||
|
||||
await InheritAgent(agent);
|
||||
OverrideInstructionByChannel(agent);
|
||||
AddOrUpdateParameters(agent);
|
||||
|
||||
// Populate state into dictionary
|
||||
agent.TemplateDict = new Dictionary<string, object>();
|
||||
PopulateState(agent.TemplateDict);
|
||||
|
||||
// After agent is loaded
|
||||
|
|
|
|||
|
|
@ -46,12 +46,7 @@ public partial class AgentService
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(def.VisibilityExpression))
|
||||
{
|
||||
var render = _services.GetRequiredService<ITemplateRender>();
|
||||
var result = render.Render(def.VisibilityExpression, new Dictionary<string, object>
|
||||
{
|
||||
{ "states", agent.TemplateDict }
|
||||
});
|
||||
isRender = isRender && result == "visible";
|
||||
isRender = RenderVisibility(def.VisibilityExpression, agent.TemplateDict);
|
||||
}
|
||||
|
||||
return isRender;
|
||||
|
|
@ -76,12 +71,7 @@ public partial class AgentService
|
|||
if (node.TryGetProperty(visibleExpress, out var element))
|
||||
{
|
||||
var expression = element.GetString();
|
||||
var render = _services.GetRequiredService<ITemplateRender>();
|
||||
var result = render.Render(expression, new Dictionary<string, object>
|
||||
{
|
||||
{ "states", agent.TemplateDict }
|
||||
});
|
||||
matched = result == "visible";
|
||||
matched = RenderVisibility(expression, agent.TemplateDict);
|
||||
}
|
||||
|
||||
if (matched)
|
||||
|
|
@ -137,4 +127,20 @@ public partial class AgentService
|
|||
|
||||
return content;
|
||||
}
|
||||
|
||||
public bool RenderVisibility(string? visibilityExpression, Dictionary<string, object> dict)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(visibilityExpression))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var render = _services.GetRequiredService<ITemplateRender>();
|
||||
var result = render.Render(visibilityExpression, new Dictionary<string, object>
|
||||
{
|
||||
{ "states", dict ?? [] }
|
||||
});
|
||||
|
||||
return result.IsEqualTo("visible");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,21 @@
|
|||
using BotSharp.Abstraction.Conversations.Enums;
|
||||
using BotSharp.Abstraction.MLTasks;
|
||||
using BotSharp.Abstraction.Models;
|
||||
using BotSharp.Abstraction.Templating;
|
||||
|
||||
namespace BotSharp.Core.Conversations.Services;
|
||||
|
||||
public partial class ConversationService
|
||||
{
|
||||
public async Task<string> GetConversationSummary(IEnumerable<string> conversationIds)
|
||||
public async Task<string> GetConversationSummary(ConversationSummaryModel model)
|
||||
{
|
||||
if (conversationIds.IsNullOrEmpty()) return string.Empty;
|
||||
if (model.ConversationIds.IsNullOrEmpty()) return string.Empty;
|
||||
|
||||
var routing = _services.GetRequiredService<IRoutingService>();
|
||||
var agentService = _services.GetRequiredService<IAgentService>();
|
||||
|
||||
var contents = new List<string>();
|
||||
foreach ( var conversationId in conversationIds)
|
||||
foreach (var conversationId in model.ConversationIds)
|
||||
{
|
||||
if (string.IsNullOrEmpty(conversationId)) continue;
|
||||
|
||||
|
|
@ -31,16 +32,16 @@ public partial class ConversationService
|
|||
|
||||
if (contents.IsNullOrEmpty()) return string.Empty;
|
||||
|
||||
var router = await agentService.LoadAgent(AIAssistant);
|
||||
var prompt = GetPrompt(router, contents);
|
||||
var summary = await Summarize(router, prompt);
|
||||
var agent = await agentService.LoadAgent(model.AgentId);
|
||||
var prompt = GetPrompt(agent, model.TemplateName, contents);
|
||||
var summary = await Summarize(agent, prompt);
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
private string GetPrompt(Agent agent, List<string> contents)
|
||||
private string GetPrompt(Agent agent, string templateName, List<string> contents)
|
||||
{
|
||||
var template = agent.Templates.First(x => x.Name == "conversation.summary").Content;
|
||||
var template = agent.Templates.First(x => x.Name == templateName).Content;
|
||||
var render = _services.GetRequiredService<ITemplateRender>();
|
||||
|
||||
var texts = new List<string>();
|
||||
|
|
|
|||
|
|
@ -9,9 +9,14 @@ public class InstructUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
utilities.Add(new AgentUtility
|
||||
{
|
||||
Name = "instruct.template",
|
||||
Functions = [new($"{EXECUTE_TEMPLATE}")],
|
||||
Templates = [new($"{EXECUTE_TEMPLATE}.fn")]
|
||||
Category = "instruct",
|
||||
Name = "template",
|
||||
Items = [
|
||||
new UtilityItem {
|
||||
FunctionName = $"{EXECUTE_TEMPLATE}",
|
||||
TemplateName = $"{EXECUTE_TEMPLATE}.fn"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,20 @@ public class RoutingUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
utilities.Add(new AgentUtility
|
||||
{
|
||||
Category = "routing",
|
||||
Name = "routing.tools",
|
||||
Functions = [new($"{REDIRECT_TO_AGENT}"), new($"{FALLBACK_TO_ROUTER}")],
|
||||
Templates = [new($"{REDIRECT_TO_AGENT}.fn"), new($"{FALLBACK_TO_ROUTER}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = $"{REDIRECT_TO_AGENT}",
|
||||
TemplateName = $"{REDIRECT_TO_AGENT}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = $"{FALLBACK_TO_ROUTER}",
|
||||
TemplateName = $"{FALLBACK_TO_ROUTER}.fn"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ public class UserService : IUserService
|
|||
foreach (var hook in hooks)
|
||||
{
|
||||
user = await hook.Authenticate(id, password);
|
||||
if (user == null)
|
||||
if (user == null || string.IsNullOrEmpty(user.Id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ using Microsoft.Net.Http.Headers;
|
|||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.IdentityModel.JsonWebTokens;
|
||||
using BotSharp.OpenAPI.BackgroundServices;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
|
||||
namespace BotSharp.OpenAPI;
|
||||
|
||||
|
|
@ -61,6 +63,9 @@ public static class BotSharpOpenApiExtensions
|
|||
}
|
||||
}).AddCookie(options =>
|
||||
{
|
||||
// Add these lines for cross-origin cookie support
|
||||
options.Cookie.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.None;
|
||||
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
|
||||
}).AddPolicyScheme(schema, "Mixed authentication", options =>
|
||||
{
|
||||
// runs on each request
|
||||
|
|
@ -82,15 +87,16 @@ public static class BotSharpOpenApiExtensions
|
|||
};
|
||||
});
|
||||
|
||||
#region OpenId
|
||||
// GitHub OAuth
|
||||
if (!string.IsNullOrWhiteSpace(config["OAuth:GitHub:ClientId"]) && !string.IsNullOrWhiteSpace(config["OAuth:GitHub:ClientSecret"]))
|
||||
{
|
||||
builder = builder.AddGitHub(options =>
|
||||
{
|
||||
options.ClientId = config["OAuth:GitHub:ClientId"];
|
||||
options.ClientSecret = config["OAuth:GitHub:ClientSecret"];
|
||||
options.Scope.Add("user:email");
|
||||
});
|
||||
{
|
||||
options.ClientId = config["OAuth:GitHub:ClientId"];
|
||||
options.ClientSecret = config["OAuth:GitHub:ClientSecret"];
|
||||
options.Events.OnTicketReceived = OnTicketReceivedContext;
|
||||
});
|
||||
}
|
||||
|
||||
// Google Identiy OAuth
|
||||
|
|
@ -100,6 +106,7 @@ public static class BotSharpOpenApiExtensions
|
|||
{
|
||||
options.ClientId = config["OAuth:Google:ClientId"];
|
||||
options.ClientSecret = config["OAuth:Google:ClientSecret"];
|
||||
options.Events.OnTicketReceived = OnTicketReceivedContext;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -113,8 +120,9 @@ public static class BotSharpOpenApiExtensions
|
|||
options.ClientId = config["OAuth:Keycloak:ClientId"];
|
||||
options.ClientSecret = config["OAuth:Keycloak:ClientSecret"];
|
||||
options.AccessType = AspNet.Security.OAuth.Keycloak.KeycloakAuthenticationAccessType.Confidential;
|
||||
int version = Convert.ToInt32(config["OAuth:Keycloak:Version"]??"22") ;
|
||||
options.Version = new Version(version,0);
|
||||
int version = Convert.ToInt32(config["OAuth:Keycloak:Version"] ?? "22");
|
||||
options.Version = new Version(version, 0);
|
||||
options.Events.OnTicketReceived = OnTicketReceivedContext;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -129,13 +137,17 @@ public static class BotSharpOpenApiExtensions
|
|||
options.Backchannel = builder.Services.BuildServiceProvider()
|
||||
.GetRequiredService<IHttpClientFactory>()
|
||||
.CreateClient();
|
||||
options.Events.OnTicketReceived = OnTicketReceivedContext;
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Add services to the container.
|
||||
services.AddControllers()
|
||||
.AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
|
||||
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new RichContentJsonConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new TemplateMessageJsonConverter());
|
||||
});
|
||||
|
|
@ -182,6 +194,16 @@ public static class BotSharpOpenApiExtensions
|
|||
return services;
|
||||
}
|
||||
|
||||
private static async Task OnTicketReceivedContext(TicketReceivedContext context)
|
||||
{
|
||||
var services = context.HttpContext.RequestServices;
|
||||
var hooks = services.GetServices<IAuthenticationHook>();
|
||||
foreach (var hook in hooks)
|
||||
{
|
||||
await hook.OAuthCompleted(context);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use Swagger/OpenAPI
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -167,7 +167,9 @@ public class AgentController : ControllerBase
|
|||
{
|
||||
hook.AddUtilities(utilities);
|
||||
}
|
||||
return utilities.Where(x => !string.IsNullOrWhiteSpace(x.Name)).OrderBy(x => x.Name).ToList();
|
||||
return utilities.Where(x => !string.IsNullOrWhiteSpace(x.Category)
|
||||
&& !string.IsNullOrWhiteSpace(x.Name)
|
||||
&& !x.Items.IsNullOrEmpty()).ToList();
|
||||
}
|
||||
|
||||
[HttpGet("/agent/labels")]
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public class ConversationController : ControllerBase
|
|||
public async Task<string> GetConversationSummary([FromBody] ConversationSummaryModel input)
|
||||
{
|
||||
var service = _services.GetRequiredService<IConversationService>();
|
||||
return await service.GetConversationSummary(input.ConversationIds);
|
||||
return await service.GetConversationSummary(input);
|
||||
}
|
||||
|
||||
[HttpPut("/conversation/{conversationId}/update-title")]
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BotSharp.OpenAPI.ViewModels.Conversations;
|
||||
|
||||
public class ConversationSummaryModel
|
||||
{
|
||||
[JsonPropertyName("conversation_ids")]
|
||||
public List<string> ConversationIds { get; set; } = new List<string>();
|
||||
}
|
||||
|
|
@ -2,5 +2,5 @@ namespace BotSharp.Plugin.AudioHandler.Enums;
|
|||
|
||||
public class UtilityName
|
||||
{
|
||||
public const string AudioHandler = "audio.audio-handler";
|
||||
public const string AudioHandler = "audio-handler";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,15 @@ public class AudioHandlerUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
var utility = new AgentUtility
|
||||
{
|
||||
Category = "audio",
|
||||
Name = UtilityName.AudioHandler,
|
||||
Functions = [new(HANDLER_AUDIO)],
|
||||
Templates = [new($"{HANDLER_AUDIO}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = HANDLER_AUDIO,
|
||||
TemplateName = $"{HANDLER_AUDIO}.fn"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
utilities.Add(utility);
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ namespace BotSharp.Plugin.EmailHandler.Enums;
|
|||
|
||||
public class UtilityName
|
||||
{
|
||||
public const string EmailHandler = "email.email-handler";
|
||||
public const string EmailHandler = "email-handler";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,20 @@ public class EmailHandlerUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
var utility = new AgentUtility
|
||||
{
|
||||
Category = "email",
|
||||
Name = UtilityName.EmailHandler,
|
||||
Functions = [new(EMAIL_READER_FN), new(EMAIL_SENDER_FN)],
|
||||
Templates = [new($"{EMAIL_READER_FN}.fn"), new($"{EMAIL_SENDER_FN}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = EMAIL_READER_FN,
|
||||
TemplateName = $"{EMAIL_READER_FN}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = EMAIL_SENDER_FN,
|
||||
TemplateName = $"{EMAIL_SENDER_FN}.fn"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
utilities.Add(utility);
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ namespace BotSharp.Plugin.ExcelHandler.Enums;
|
|||
|
||||
public class UtilityName
|
||||
{
|
||||
public const string ExcelHandler = "excel.excel-handler";
|
||||
public const string ExcelHandler = "excel-handler";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,15 @@ public class ExcelHandlerUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
var utility = new AgentUtility
|
||||
{
|
||||
Category = "file",
|
||||
Name = UtilityName.ExcelHandler,
|
||||
Functions = [new(HANDLER_EXCEL)],
|
||||
Templates = [new($"{HANDLER_EXCEL}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = HANDLER_EXCEL,
|
||||
TemplateName = $"{HANDLER_EXCEL}.fn"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
utilities.Add(utility);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ namespace BotSharp.Plugin.FileHandler.Enums;
|
|||
|
||||
public class UtilityName
|
||||
{
|
||||
public const string ImageGenerator = "file.image-generator";
|
||||
public const string ImageReader = "file.image-reader";
|
||||
public const string ImageEditor = "file.image-editor";
|
||||
public const string PdfReader = "file.pdf-reader";
|
||||
public const string ImageGenerator = "image-generator";
|
||||
public const string ImageReader = "image-reader";
|
||||
public const string ImageEditor = "image-editor";
|
||||
public const string PdfReader = "pdf-reader";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,27 +13,50 @@ public class FileHandlerUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
new AgentUtility
|
||||
{
|
||||
Category = "file",
|
||||
Name = UtilityName.ImageGenerator,
|
||||
Functions = [new(GENERATE_IMAGE_FN)],
|
||||
Templates = [new($"{GENERATE_IMAGE_FN}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = GENERATE_IMAGE_FN,
|
||||
TemplateName = $"{GENERATE_IMAGE_FN}.fn"
|
||||
}
|
||||
]
|
||||
},
|
||||
new AgentUtility
|
||||
{
|
||||
Category = "file",
|
||||
Name = UtilityName.ImageReader,
|
||||
Functions = [new(READ_IMAGE_FN)],
|
||||
Templates = [new($"{READ_IMAGE_FN}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = READ_IMAGE_FN,
|
||||
TemplateName = $"{READ_IMAGE_FN}.fn"
|
||||
}
|
||||
]
|
||||
},
|
||||
new AgentUtility
|
||||
{
|
||||
Name = UtilityName.ImageEditor,
|
||||
Functions = [new(EDIT_IMAGE_FN)],
|
||||
Templates = [new($"{EDIT_IMAGE_FN}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = EDIT_IMAGE_FN,
|
||||
TemplateName = $"{EDIT_IMAGE_FN}.fn"
|
||||
}
|
||||
]
|
||||
},
|
||||
new AgentUtility
|
||||
{
|
||||
Category = "file",
|
||||
Name = UtilityName.PdfReader,
|
||||
Functions = [new(READ_PDF_FN)],
|
||||
Templates = [new($"{READ_PDF_FN}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = READ_PDF_FN,
|
||||
TemplateName = $"{READ_PDF_FN}.fn"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ namespace BotSharp.Plugin.HttpHandler.Enums;
|
|||
|
||||
public class UtilityName
|
||||
{
|
||||
public const string HttpHandler = "http.http-handler";
|
||||
public const string HttpHandler = "http-handler";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,15 @@ public class HttpHandlerUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
var utility = new AgentUtility
|
||||
{
|
||||
Category = "http",
|
||||
Name = UtilityName.HttpHandler,
|
||||
Functions = [new(HTTP_HANDLER_FN)],
|
||||
Templates = [new($"{HTTP_HANDLER_FN}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = HTTP_HANDLER_FN,
|
||||
TemplateName = $"{HTTP_HANDLER_FN}.fn"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
utilities.Add(utility);
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ namespace BotSharp.Plugin.KnowledgeBase.Enum;
|
|||
|
||||
public class UtilityName
|
||||
{
|
||||
public const string KnowledgeRetrieval = "kg.knowledge-base";
|
||||
public const string KnowledgeRetrieval = "knowledge-base";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,15 @@ public class KnowledgeBaseUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
var utility = new AgentUtility
|
||||
{
|
||||
Category = "knowledge",
|
||||
Name = UtilityName.KnowledgeRetrieval,
|
||||
Functions = [new(KNOWLEDGE_RETRIEVAL_FN)],
|
||||
Templates = [new($"{KNOWLEDGE_RETRIEVAL_FN}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = KNOWLEDGE_RETRIEVAL_FN,
|
||||
TemplateName = $"{KNOWLEDGE_RETRIEVAL_FN}.fn"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
utilities.Add(utility);
|
||||
|
|
|
|||
|
|
@ -5,19 +5,26 @@ namespace BotSharp.Plugin.MongoStorage.Models;
|
|||
[BsonIgnoreExtraElements(Inherited = true)]
|
||||
public class AgentUtilityMongoElement
|
||||
{
|
||||
public string Category { get; set; } = default!;
|
||||
public string Name { get; set; } = default!;
|
||||
public bool Disabled { get; set; }
|
||||
public List<UtilityFunctionMongoElement> Functions { get; set; } = [];
|
||||
public List<UtilityTemplateMongoElement> Templates { get; set; } = [];
|
||||
public string? VisibilityExpression { get; set; }
|
||||
public List<AgentUtilityItemMongoElement> Items { get; set; } = [];
|
||||
|
||||
public static AgentUtilityMongoElement ToMongoElement(AgentUtility utility)
|
||||
{
|
||||
return new AgentUtilityMongoElement
|
||||
{
|
||||
Category = utility.Category,
|
||||
Name = utility.Name,
|
||||
Disabled = utility.Disabled,
|
||||
Functions = utility.Functions?.Select(x => new UtilityFunctionMongoElement(x.Name))?.ToList() ?? [],
|
||||
Templates = utility.Templates?.Select(x => new UtilityTemplateMongoElement(x.Name))?.ToList() ?? []
|
||||
VisibilityExpression = utility.VisibilityExpression,
|
||||
Items = utility.Items?.Select(x => new AgentUtilityItemMongoElement
|
||||
{
|
||||
FunctionName = x.FunctionName,
|
||||
TemplateName = x.TemplateName,
|
||||
VisibilityExpression = x.VisibilityExpression
|
||||
})?.ToList() ?? []
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -25,20 +32,23 @@ public class AgentUtilityMongoElement
|
|||
{
|
||||
return new AgentUtility
|
||||
{
|
||||
Category = utility.Category,
|
||||
Name = utility.Name,
|
||||
Disabled = utility.Disabled,
|
||||
Functions = utility.Functions?.Select(x => new UtilityFunction(x.Name))?.ToList() ?? [],
|
||||
Templates = utility.Templates?.Select(x => new UtilityTemplate(x.Name))?.ToList() ?? []
|
||||
VisibilityExpression = utility.VisibilityExpression,
|
||||
Items = utility.Items?.Select(x => new UtilityItem
|
||||
{
|
||||
FunctionName = x.FunctionName,
|
||||
TemplateName = x.TemplateName,
|
||||
VisibilityExpression = x.VisibilityExpression
|
||||
})?.ToList() ?? [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class UtilityFunctionMongoElement(string name)
|
||||
public class AgentUtilityItemMongoElement
|
||||
{
|
||||
public string Name { get; set; } = name;
|
||||
}
|
||||
|
||||
public class UtilityTemplateMongoElement(string name)
|
||||
{
|
||||
public string Name { get; set; } = name;
|
||||
public string? FunctionName { get; set; }
|
||||
public string? TemplateName { get; set; }
|
||||
public string? VisibilityExpression { get; set; }
|
||||
}
|
||||
|
|
@ -2,5 +2,5 @@ namespace BotSharp.Plugin.Planner.Enums;
|
|||
|
||||
public class UtilityName
|
||||
{
|
||||
public const string TwoStagePlanner = "planner.two-stage-planner";
|
||||
public const string TwoStagePlanner = "two-stage-planner";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,16 +10,24 @@ public class TwoStagingPlannerUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
var utility = new AgentUtility
|
||||
{
|
||||
Category = "planner",
|
||||
Name = UtilityName.TwoStagePlanner,
|
||||
Functions = [
|
||||
new(PRIMARY_STAGE_FN),
|
||||
new(SECONDARY_STAGE_FN),
|
||||
new(SUMMARY_FN)
|
||||
],
|
||||
Templates = [
|
||||
new($"{PRIMARY_STAGE_FN}.fn"),
|
||||
new($"{SECONDARY_STAGE_FN}.fn"),
|
||||
new($"{SUMMARY_FN}.fn")
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = PRIMARY_STAGE_FN,
|
||||
TemplateName = $"{PRIMARY_STAGE_FN}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = SECONDARY_STAGE_FN,
|
||||
TemplateName = $"{SECONDARY_STAGE_FN}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = SUMMARY_FN,
|
||||
TemplateName = $"{SUMMARY_FN}.fn"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,15 @@ public class InterpreterUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
var utility = new AgentUtility()
|
||||
{
|
||||
Category = "coding",
|
||||
Name = UtilityName.PythonInterpreter,
|
||||
Functions = [new(FUNCTION_NAME)],
|
||||
Templates = [new($"{FUNCTION_NAME}.fn")]
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = FUNCTION_NAME,
|
||||
TemplateName = $"{FUNCTION_NAME}.fn"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
utilities.Add(utility);
|
||||
|
|
|
|||
|
|
@ -14,18 +14,24 @@ public class SqlUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
new AgentUtility
|
||||
{
|
||||
Name = "db.tools",
|
||||
Functions =
|
||||
[
|
||||
new(SQL_TABLE_DEFINITION_FN),
|
||||
new(VERIFY_DICTIONARY_TERM_FN),
|
||||
new(SQL_SELECT_FN),
|
||||
],
|
||||
Templates =
|
||||
[
|
||||
new($"{VERIFY_DICTIONARY_TERM_FN}.fn"),
|
||||
new($"{SQL_TABLE_DEFINITION_FN}.fn"),
|
||||
new($"{SQL_EXECUTOR_FN}.fn")
|
||||
Category = "database",
|
||||
Name = "sql.tools",
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = SQL_TABLE_DEFINITION_FN,
|
||||
TemplateName = $"{SQL_TABLE_DEFINITION_FN}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = VERIFY_DICTIONARY_TERM_FN,
|
||||
TemplateName = $"{VERIFY_DICTIONARY_TERM_FN}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = SQL_SELECT_FN,
|
||||
TemplateName = $"{SQL_EXECUTOR_FN}.fn"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ namespace BotSharp.Plugin.Twilio.OutboundPhoneCallHandler.Enums
|
|||
{
|
||||
public class UtilityName
|
||||
{
|
||||
public const string OutboundPhoneCall = "phone.twilio-phone-call";
|
||||
public const string OutboundPhoneCall = "twilio-phone-call";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using BotSharp.Abstraction.Files;
|
||||
using BotSharp.Abstraction.Files.Models;
|
||||
using BotSharp.Abstraction.Infrastructures.Enums;
|
||||
using BotSharp.Abstraction.Options;
|
||||
using BotSharp.Abstraction.Routing;
|
||||
|
|
|
|||
|
|
@ -16,17 +16,29 @@ public class OutboundPhoneCallHandlerUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
var utility = new AgentUtility
|
||||
{
|
||||
Category = "phone",
|
||||
Name = UtilityName.OutboundPhoneCall,
|
||||
Functions =
|
||||
[
|
||||
new($"{OUTBOUND_PHONE_CALL_FN}"),
|
||||
new($"{TRANSFER_PHONE_CALL_FN}"),
|
||||
new($"{HANGUP_PHONE_CALL_FN}"),
|
||||
new($"{TEXT_MESSAGE_FN}"),
|
||||
new($"{LEAVE_VOICEMAIL_FN}")
|
||||
],
|
||||
Templates =
|
||||
[
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = OUTBOUND_PHONE_CALL_FN
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = TRANSFER_PHONE_CALL_FN
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = HANGUP_PHONE_CALL_FN
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = TEXT_MESSAGE_FN
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = LEAVE_VOICEMAIL_FN
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,18 +14,27 @@ public class WebUtilityHook : IAgentUtilityHook
|
|||
{
|
||||
new AgentUtility
|
||||
{
|
||||
Name = "web.tools",
|
||||
Functions =
|
||||
[
|
||||
new(CLOSE_BROWSER_FN),
|
||||
new(GO_TO_PAGE_FN),
|
||||
new(LOCATE_ELEMENT_FN),
|
||||
new(ACTION_ON_ELEMENT_FN)
|
||||
],
|
||||
Templates =
|
||||
[
|
||||
new($"{GO_TO_PAGE_FN}.fn"),
|
||||
new($"{ACTION_ON_ELEMENT_FN}.fn")
|
||||
Category = "web",
|
||||
Name = "browser.tools",
|
||||
Items = [
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = GO_TO_PAGE_FN,
|
||||
TemplateName = $"{GO_TO_PAGE_FN}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = ACTION_ON_ELEMENT_FN,
|
||||
TemplateName = $"{ACTION_ON_ELEMENT_FN}.fn"
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = LOCATE_ELEMENT_FN
|
||||
},
|
||||
new UtilityItem
|
||||
{
|
||||
FunctionName = CLOSE_BROWSER_FN
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using BotSharp.Abstraction.Models;
|
|||
using BotSharp.Abstraction.Plugins.Models;
|
||||
using BotSharp.Abstraction.Repositories.Filters;
|
||||
using BotSharp.Abstraction.Utilities;
|
||||
using NetTopologySuite.Algorithm;
|
||||
|
||||
namespace BotSharp.Plugin.Google.Core
|
||||
{
|
||||
|
|
@ -61,6 +62,11 @@ namespace BotSharp.Plugin.Google.Core
|
|||
return def.Parameters;
|
||||
}
|
||||
|
||||
public bool RenderVisibility(string? visibilityExpression, Dictionary<string, object> dict)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Task<Agent> GetAgent(string id)
|
||||
{
|
||||
return Task.FromResult(new Agent());
|
||||
|
|
|
|||
Loading…
Reference in a new issue