Merge branch 'master' of https://github.com/SciSharp/BotSharp into features/refine-vector-store
This commit is contained in:
commit
5bb5d69894
|
|
@ -6,8 +6,15 @@ namespace BotSharp.Abstraction.Realtime;
|
|||
|
||||
public interface IRealtimeHook : IHookBase
|
||||
{
|
||||
Task OnModelReady(Agent agent, IRealTimeCompletion completer);
|
||||
string[] OnModelTranscriptPrompt(Agent agent);
|
||||
Task OnTranscribeCompleted(RoleDialogModel message, TranscriptionData data);
|
||||
Task<bool> ShouldReconnect(RealtimeHubConnection conn) => Task.FromResult(false);
|
||||
Task OnModelReady(Agent agent, IRealTimeCompletion completer)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
string[] OnModelTranscriptPrompt(Agent agent)
|
||||
=> [];
|
||||
|
||||
Task OnTranscribeCompleted(RoleDialogModel message, TranscriptionData data)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
Task<bool> ShouldReconnect(RealtimeHubConnection conn, RoleDialogModel message)
|
||||
=> Task.FromResult(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public class ConversationFilter
|
|||
public string? ChannelId { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
public DateTime? StartTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Agent task id
|
||||
|
|
|
|||
|
|
@ -100,6 +100,17 @@ public class RealtimeHub : IRealtimeHub
|
|||
}
|
||||
|
||||
await routing.InvokeFunction(message.FunctionName, message, options: new() { From = InvokeSource.Llm });
|
||||
|
||||
var hooks = _services.GetHooks<IRealtimeHook>(_conn.CurrentAgentId);
|
||||
foreach (var hook in hooks)
|
||||
{
|
||||
if (await hook.ShouldReconnect(_conn, message))
|
||||
{
|
||||
await _completer.Reconnect(_conn);
|
||||
_logger.LogWarning("Reconnecting to model due to function call: {FunctionName}", message.FunctionName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -117,19 +128,6 @@ public class RealtimeHub : IRealtimeHub
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isReconnect = false;
|
||||
var realtimeHooks = _services.GetHooks<IRealtimeHook>(_conn.CurrentAgentId);
|
||||
foreach (var hook in realtimeHooks)
|
||||
{
|
||||
isReconnect = await hook.ShouldReconnect(_conn);
|
||||
if (isReconnect) break;
|
||||
}
|
||||
|
||||
if (isReconnect)
|
||||
{
|
||||
await _completer.Reconnect(_conn);
|
||||
}
|
||||
},
|
||||
onConversationItemCreated: async response =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -393,6 +393,10 @@ public partial class MongoRepository
|
|||
{
|
||||
convFilters.Add(convBuilder.Gte(x => x.CreatedTime, filter.StartTime.Value));
|
||||
}
|
||||
if (filter?.EndTime != null)
|
||||
{
|
||||
convFilters.Add(convBuilder.Lte(x => x.CreatedTime, filter.EndTime.Value));
|
||||
}
|
||||
if (filter?.Tags != null && filter.Tags.Any())
|
||||
{
|
||||
convFilters.Add(convBuilder.AnyIn(x => x.Tags, filter.Tags));
|
||||
|
|
|
|||
Loading…
Reference in a new issue