commit
e28b8a70a8
|
|
@ -1,3 +1,4 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace BotSharp.Abstraction.Utilities;
|
||||
|
|
@ -27,4 +28,16 @@ public static class StringExtensions
|
|||
{
|
||||
return str1.Equals(str2, option);
|
||||
}
|
||||
|
||||
public static string JsonContent(this string text)
|
||||
{
|
||||
var m = Regex.Match(text, @"\{(?:[^{}]|(?<open>\{)|(?<-open>\}))+(?(open)(?!))\}");
|
||||
return m.Success ? m.Value : "{}";
|
||||
}
|
||||
|
||||
public static T? JsonContent<T>(this string text)
|
||||
{
|
||||
text = JsonContent(text);
|
||||
return JsonSerializer.Deserialize<T>(text);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,18 +4,14 @@ namespace BotSharp.Core.Agents.Services;
|
|||
|
||||
public partial class AgentService
|
||||
{
|
||||
#if !DEBUG
|
||||
[MemoryCache(10 * 60)]
|
||||
#endif
|
||||
[MemoryCache(10 * 60, PerInstanceCache = true)]
|
||||
public async Task<List<Agent>> GetAgents(bool? allowRouting = null)
|
||||
{
|
||||
var agents = _db.GetAgents(allowRouting: allowRouting);
|
||||
return await Task.FromResult(agents);
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
[MemoryCache(10 * 60)]
|
||||
#endif
|
||||
[MemoryCache(10 * 60, PerInstanceCache = true)]
|
||||
public async Task<Agent> GetAgent(string id)
|
||||
{
|
||||
var profile = _db.GetAgent(id);
|
||||
|
|
|
|||
|
|
@ -486,9 +486,6 @@ public class FileRepository : IBotSharpRepository
|
|||
return responses;
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
[MemoryCache(10 * 60)]
|
||||
#endif
|
||||
public Agent? GetAgent(string agentId)
|
||||
{
|
||||
var agentDir = Path.Combine(_dbSettings.FileRepository, _agentSettings.DataDir);
|
||||
|
|
|
|||
|
|
@ -82,9 +82,7 @@ public partial class RoutingService
|
|||
new RoleDialogModel(AgentRole.User, content)
|
||||
});
|
||||
|
||||
var pattern = @"\{(?:[^{}]|(?<open>\{)|(?<-open>\}))+(?(open)(?!))\}";
|
||||
response.Content = Regex.Match(response.Content, pattern).Value;
|
||||
args = JsonSerializer.Deserialize<FunctionCallFromLlm>(response.Content);
|
||||
args = response.Content.JsonContent<FunctionCallFromLlm>();
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
What is the next step based on the CONVERSATION? Response must be in appropriate JSON format. Route to the latest agent as much as possible.
|
||||
What is the next step based on the CONVERSATION? Response must be in appropriate JSON format.
|
||||
Loading…
Reference in a new issue