diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs index 6a8af2d6..6bc82f81 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs @@ -120,7 +120,7 @@ public class RoleDialogModel : ITrackableMessage [JsonIgnore(Condition = JsonIgnoreCondition.Always)] public bool IsStreaming { get; set; } - private RoleDialogModel() + public RoleDialogModel() { } diff --git a/src/Infrastructure/BotSharp.Abstraction/MessageHub/Models/HubObserveData.cs b/src/Infrastructure/BotSharp.Abstraction/MessageHub/Models/HubObserveData.cs index 403adbc6..277893ad 100644 --- a/src/Infrastructure/BotSharp.Abstraction/MessageHub/Models/HubObserveData.cs +++ b/src/Infrastructure/BotSharp.Abstraction/MessageHub/Models/HubObserveData.cs @@ -1,7 +1,7 @@ namespace BotSharp.Abstraction.MessageHub.Models; -public class HubObserveData : ObserveDataBase +public class HubObserveData : ObserveDataBase where TData : class, new() { public string EventName { get; set; } = null!; - public RoleDialogModel Data { get; set; } = null!; + public TData Data { get; set; } = null!; } diff --git a/src/Infrastructure/BotSharp.Core/Conversations/ConversationPlugin.cs b/src/Infrastructure/BotSharp.Core/Conversations/ConversationPlugin.cs index cef32cad..1a36875c 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/ConversationPlugin.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/ConversationPlugin.cs @@ -44,7 +44,7 @@ public class ConversationPlugin : IBotSharpPlugin, IBotSharpAppPlugin return settingService.Bind("GoogleApi"); }); - services.AddSingleton>(); + services.AddSingleton>>(); services.AddScoped(); services.AddScoped(); @@ -72,8 +72,8 @@ public class ConversationPlugin : IBotSharpPlugin, IBotSharpAppPlugin public void Configure(IApplicationBuilder app) { var services = app.ApplicationServices; - var queue = services.GetRequiredService>(); - var logger = services.GetRequiredService>>(); + var queue = services.GetRequiredService>>(); + var logger = services.GetRequiredService>>>(); queue.Events.Subscribe(new ConversationObserver(logger)); } } diff --git a/src/Infrastructure/BotSharp.Core/Demo/Functions/GetWeatherFn.cs b/src/Infrastructure/BotSharp.Core/Demo/Functions/GetWeatherFn.cs index b8bb0f39..a22f5cec 100644 --- a/src/Infrastructure/BotSharp.Core/Demo/Functions/GetWeatherFn.cs +++ b/src/Infrastructure/BotSharp.Core/Demo/Functions/GetWeatherFn.cs @@ -18,7 +18,7 @@ public class GetWeatherFn : IFunctionCallback public async Task Execute(RoleDialogModel message) { var conv = _services.GetRequiredService(); - var messageHub = _services.GetRequiredService>(); + var messageHub = _services.GetRequiredService>>(); await Task.Delay(1000); diff --git a/src/Infrastructure/BotSharp.Core/MessageHub/MessageHub.cs b/src/Infrastructure/BotSharp.Core/MessageHub/MessageHub.cs index a104f4f6..8e99f898 100644 --- a/src/Infrastructure/BotSharp.Core/MessageHub/MessageHub.cs +++ b/src/Infrastructure/BotSharp.Core/MessageHub/MessageHub.cs @@ -2,7 +2,7 @@ using System.Reactive.Subjects; namespace BotSharp.Core.MessageHub; -public class MessageHub where T : class +public class MessageHub where T : class, new() { private readonly ILogger> _logger; private readonly ISubject _observable = Subject.Synchronize(new Subject()); diff --git a/src/Infrastructure/BotSharp.Core/MessageHub/Observers/ConversationObserver.cs b/src/Infrastructure/BotSharp.Core/MessageHub/Observers/ConversationObserver.cs index dd4b528c..cad778b4 100644 --- a/src/Infrastructure/BotSharp.Core/MessageHub/Observers/ConversationObserver.cs +++ b/src/Infrastructure/BotSharp.Core/MessageHub/Observers/ConversationObserver.cs @@ -1,6 +1,6 @@ namespace BotSharp.Core.MessageHub.Observers; -public class ConversationObserver : IObserver +public class ConversationObserver : IObserver> { private readonly ILogger _logger; private IServiceProvider _services; @@ -20,11 +20,11 @@ public class ConversationObserver : IObserver _logger.LogError(error, $"{nameof(ConversationObserver)} receives error notification: {error.Message}"); } - public void OnNext(HubObserveData value) + public void OnNext(HubObserveData value) { _services = value.ServiceProvider; - var progress = _services.GetRequiredService(); + if (value.EventName == ChatEvent.OnIndicationReceived && progress.OnFunctionExecuting != null) { diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs index 3660f61f..f693f4dd 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs @@ -25,7 +25,7 @@ public partial class RoutingService clonedMessage.FunctionName = name; clonedMessage.Indication = await funcExecutor.GetIndicatorAsync(message); - var messageHub = _services.GetRequiredService>(); + var messageHub = _services.GetRequiredService>>(); messageHub.Push(new() { EventName = ChatEvent.OnIndicationReceived, diff --git a/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs index d3c6e14a..b19bdaef 100644 --- a/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs @@ -212,7 +212,7 @@ public class ChatCompletionProvider : IChatCompletion var chatClient = client.GetChatClient(_model); var (prompt, messages, options) = PrepareOptions(agent, conversations); - var hub = _services.GetRequiredService>(); + var hub = _services.GetRequiredService>>(); var messageId = conversations.LastOrDefault()?.MessageId ?? string.Empty; var contentHooks = _services.GetHooks(agent.Id); diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/ChatHubPlugin.cs b/src/Plugins/BotSharp.Plugin.ChatHub/ChatHubPlugin.cs index d771d0a2..38bd936c 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/ChatHubPlugin.cs +++ b/src/Plugins/BotSharp.Plugin.ChatHub/ChatHubPlugin.cs @@ -36,8 +36,8 @@ public class ChatHubPlugin : IBotSharpPlugin, IBotSharpAppPlugin public void Configure(IApplicationBuilder app) { var services = app.ApplicationServices; - var queue = services.GetRequiredService>(); - var logger = services.GetRequiredService>>(); + var queue = services.GetRequiredService>>(); + var logger = services.GetRequiredService>>>(); queue.Events.Subscribe(new ChatHubObserver(logger)); } } diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/Observers/ChatHubObserver.cs b/src/Plugins/BotSharp.Plugin.ChatHub/Observers/ChatHubObserver.cs index 8f467908..75aa0cd3 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/Observers/ChatHubObserver.cs +++ b/src/Plugins/BotSharp.Plugin.ChatHub/Observers/ChatHubObserver.cs @@ -6,7 +6,7 @@ using System.Runtime.CompilerServices; namespace BotSharp.Plugin.ChatHub.Observers; -public class ChatHubObserver : IObserver +public class ChatHubObserver : IObserver> { private readonly ILogger _logger; private IServiceProvider _services; @@ -26,7 +26,7 @@ public class ChatHubObserver : IObserver _logger.LogError(error, $"{nameof(ChatHubObserver)} receives error notification: {error.Message}"); } - public void OnNext(HubObserveData value) + public void OnNext(HubObserveData value) { _services = value.ServiceProvider; diff --git a/src/Plugins/BotSharp.Plugin.DeepSeekAI/Providers/Chat/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.DeepSeekAI/Providers/Chat/ChatCompletionProvider.cs index 36a5126e..a404aef1 100644 --- a/src/Plugins/BotSharp.Plugin.DeepSeekAI/Providers/Chat/ChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.DeepSeekAI/Providers/Chat/ChatCompletionProvider.cs @@ -179,7 +179,7 @@ public class ChatCompletionProvider : IChatCompletion var chatClient = client.GetChatClient(_model); var (prompt, messages, options) = PrepareOptions(agent, conversations); - var hub = _services.GetRequiredService>(); + var hub = _services.GetRequiredService>>(); var messageId = conversations.LastOrDefault()?.MessageId ?? string.Empty; var contentHooks = _services.GetHooks(agent.Id); diff --git a/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/ChatCompletionProvider.cs index edeb7f58..a4f18d31 100644 --- a/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/ChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.LLamaSharp/Providers/ChatCompletionProvider.cs @@ -183,7 +183,7 @@ public class ChatCompletionProvider : IChatCompletion _logger.LogInformation(agent.Instruction); } - var hub = _services.GetRequiredService>(); + var hub = _services.GetRequiredService>>(); var messageId = conversations.LastOrDefault()?.MessageId ?? string.Empty; hub.Push(new() diff --git a/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs index e4567cfb..86447dca 100644 --- a/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs @@ -188,7 +188,7 @@ public class ChatCompletionProvider : IChatCompletion var chatClient = client.GetChatClient(_model); var (prompt, messages, options) = PrepareOptions(agent, conversations); - var hub = _services.GetRequiredService>(); + var hub = _services.GetRequiredService>>(); var messageId = conversations.LastOrDefault()?.MessageId ?? string.Empty; var contentHooks = _services.GetHooks(agent.Id); diff --git a/src/Plugins/BotSharp.Plugin.SparkDesk/Providers/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.SparkDesk/Providers/ChatCompletionProvider.cs index 6e4a58f2..c2e10def 100644 --- a/src/Plugins/BotSharp.Plugin.SparkDesk/Providers/ChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.SparkDesk/Providers/ChatCompletionProvider.cs @@ -152,7 +152,7 @@ public class ChatCompletionProvider : IChatCompletion var client = new SparkDeskClient(appId: _settings.AppId, apiKey: _settings.ApiKey, apiSecret: _settings.ApiSecret); var (prompt, messages, funcall) = PrepareOptions(agent, conversations); var messageId = conversations.LastOrDefault()?.MessageId ?? string.Empty; - var hub = _services.GetRequiredService>(); + var hub = _services.GetRequiredService>>(); hub.Push(new() {