Skip to content

Commit 106b891

Browse files
authored
Merge pull request #1084 from iceljc/features/init-reactive-x
Features/init reactive x
2 parents 0317368 + ffd9823 commit 106b891

File tree

40 files changed

+802
-149
lines changed

40 files changed

+802
-149
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.0.0" />
2727
<PackageVersion Include="System.Memory.Data" Version="8.0.0" />
2828
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
29+
<PackageVersion Include="System.Reactive" Version="6.0.1" />
2930
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
3031
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.0" />
3132
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />

src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<PackageReference Include="System.IdentityModel.Tokens.Jwt" />
3737
<PackageReference Include="System.Memory.Data" />
3838
<PackageReference Include="System.Text.Json" />
39+
<PackageReference Include="System.Reactive" />
3940
<PackageReference Include="Serilog.Sinks.Console" />
4041
<PackageReference Include="Serilog.Sinks.File" />
4142
<PackageReference Include="Rougamo.Fody" />

src/Infrastructure/BotSharp.Abstraction/Conversations/Dtos/ChatResponseDto.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public class ChatResponseDto : InstructResult
3535
[JsonPropertyName("has_message_files")]
3636
public bool HasMessageFiles { get; set; }
3737

38+
[JsonPropertyName("is_streaming")]
39+
public bool IsStreaming { get; set; }
40+
3841
[JsonPropertyName("created_at")]
3942
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
4043
}

src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public interface IConversationService
3636
/// <param name="onResponseReceived">Received the response from AI Agent</param>
3737
/// <returns></returns>
3838
Task<bool> SendMessage(string agentId,
39-
RoleDialogModel lastDialog,
39+
RoleDialogModel message,
4040
PostbackMessageModel? replyMessage,
4141
Func<RoleDialogModel, Task> onResponseReceived);
4242

src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ public class RoleDialogModel : ITrackableMessage
117117
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
118118
public string RenderedInstruction { get; set; } = string.Empty;
119119

120+
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
121+
public bool IsStreaming { get; set; }
122+
120123
private RoleDialogModel()
121124
{
122125
}
@@ -159,7 +162,8 @@ public static RoleDialogModel From(RoleDialogModel source,
159162
Payload = source.Payload,
160163
StopCompletion = source.StopCompletion,
161164
Instruction = source.Instruction,
162-
Data = source.Data
165+
Data = source.Data,
166+
IsStreaming = source.IsStreaming
163167
};
164168
}
165169
}

src/Infrastructure/BotSharp.Abstraction/MLTasks/IChatCompletion.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Task<bool> GetChatCompletionsAsync(Agent agent,
2323
Func<RoleDialogModel, Task> onMessageReceived,
2424
Func<RoleDialogModel, Task> onFunctionExecuting);
2525

26-
Task<bool> GetChatCompletionsStreamingAsync(Agent agent,
27-
List<RoleDialogModel> conversations,
28-
Func<RoleDialogModel, Task> onMessageReceived);
26+
Task<RoleDialogModel> GetChatCompletionsStreamingAsync(Agent agent,
27+
List<RoleDialogModel> conversations);
2928
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace BotSharp.Abstraction.Observables.Models;
2+
3+
public class HubObserveData : ObserveDataBase
4+
{
5+
public string EventName { get; set; } = null!;
6+
public RoleDialogModel Data { get; set; } = null!;
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace BotSharp.Abstraction.Observables.Models;
2+
3+
public abstract class ObserveDataBase
4+
{
5+
public IServiceProvider ServiceProvider { get; set; } = null!;
6+
}

src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ public interface IRoutingService
2626
/// <returns></returns>
2727
RoutingRule[] GetRulesByAgentId(string id);
2828

29-
//void ResetRecursiveCounter();
30-
//int GetRecursiveCounter();
31-
//void SetRecursiveCounter(int counter);
32-
33-
Task<bool> InvokeAgent(string agentId, List<RoleDialogModel> dialogs, string from = InvokeSource.Manual);
29+
Task<bool> InvokeAgent(string agentId, List<RoleDialogModel> dialogs, string from = InvokeSource.Manual, bool useStream = false);
3430
Task<bool> InvokeFunction(string name, RoleDialogModel messages, string from = InvokeSource.Manual);
3531
Task<RoleDialogModel> InstructLoop(Agent agent, RoleDialogModel message, List<RoleDialogModel> dialogs);
3632

src/Infrastructure/BotSharp.Core/Conversations/ConversationPlugin.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
using BotSharp.Core.Routing.Reasoning;
1111
using BotSharp.Core.Templating;
1212
using BotSharp.Core.Translation;
13+
using BotSharp.Core.Observables.Queues;
1314
using Microsoft.Extensions.Configuration;
15+
using BotSharp.Abstraction.Observables.Models;
1416

1517
namespace BotSharp.Core.Conversations;
1618

@@ -41,6 +43,8 @@ public void RegisterDI(IServiceCollection services, IConfiguration config)
4143
return settingService.Bind<GoogleApiSettings>("GoogleApi");
4244
});
4345

46+
services.AddSingleton<MessageHub<HubObserveData>>();
47+
4448
services.AddScoped<IConversationStorage, ConversationStorage>();
4549
services.AddScoped<IConversationService, ConversationService>();
4650
services.AddScoped<IConversationProgressService, ConversationProgressService>();

0 commit comments

Comments
 (0)