Skip to content

Commit 87c18c4

Browse files
committed
hotfix conflict
2 parents bdaf3cc + 7a301dc commit 87c18c4

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

src/Infrastructure/BotSharp.Abstraction/Crontab/Settings/CrontabSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class CrontabSettings
44
{
55
public CrontabBaseSetting EventSubscriber { get; set; } = new();
66
public CrontabBaseSetting Watcher { get; set; } = new();
7+
public string LockName { get; set; } = "CrontabWatcher:locker";
78
public DebugSetting Debug { get; set; } = new();
89
}
910

src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ public class CrontabWatcher : BackgroundService
1010
{
1111
private readonly ILogger _logger;
1212
private readonly IServiceProvider _services;
13+
private readonly CrontabSettings _cronSettings;
14+
private string DIST_KEY;
1315

14-
public CrontabWatcher(IServiceProvider services, ILogger<CrontabWatcher> logger)
16+
public CrontabWatcher(IServiceProvider services, ILogger<CrontabWatcher> logger, CrontabSettings cronSettings)
1517
{
1618
_logger = logger;
1719
_services = services;
20+
_cronSettings = cronSettings;
21+
DIST_KEY = _cronSettings.LockName;
1822
}
1923

2024
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
@@ -29,7 +33,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2933
{
3034
var delay = Task.Delay(1000, stoppingToken);
3135

32-
await locker.LockAsync("CrontabWatcher:locker", async () =>
36+
await locker.LockAsync(DIST_KEY, async () =>
3337
{
3438
await RunCronChecker(scope.ServiceProvider);
3539
});

src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,11 @@ await conv.SendMessage(agentId, inputMsg,
371371
{
372372
response.Text = !string.IsNullOrEmpty(msg.SecondaryContent) ? msg.SecondaryContent : msg.Content;
373373
response.Function = msg.FunctionName;
374+
response.MessageLabel = msg.MessageLabel;
374375
response.RichContent = msg.SecondaryRichContent ?? msg.RichContent;
375376
response.Instruction = msg.Instruction;
376377
response.Data = msg.Data;
378+
response.AdditionalMessageWrapper = ChatResponseWrapper.From(msg.AdditionalMessageWrapper, conversationId, inputMsg.MessageId);
377379
});
378380

379381
var state = _services.GetRequiredService<IConversationStateService>();
@@ -426,11 +428,13 @@ await conv.SendMessage(agentId, inputMsg,
426428
async msg =>
427429
{
428430
response.Text = !string.IsNullOrEmpty(msg.SecondaryContent) ? msg.SecondaryContent : msg.Content;
431+
response.MessageLabel = msg.MessageLabel;
429432
response.Function = msg.FunctionName;
430433
response.RichContent = msg.SecondaryRichContent ?? msg.RichContent;
431434
response.Instruction = msg.Instruction;
432435
response.Data = msg.Data;
433436
response.States = state.GetStates();
437+
response.AdditionalMessageWrapper = ChatResponseWrapper.From(msg.AdditionalMessageWrapper, conversationId, inputMsg.MessageId);
434438

435439
await OnChunkReceived(Response, response);
436440
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
11
using BotSharp.Abstraction.Conversations.Dtos;
2+
using System.Text.Json.Serialization;
23

34
namespace BotSharp.OpenAPI.ViewModels.Conversations;
45

56
public class ChatResponseModel : ChatResponseDto
67
{
8+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
9+
[JsonPropertyName("additional_message_wrapper")]
10+
public ChatResponseWrapper? AdditionalMessageWrapper { get; set; }
711
}
12+
13+
public class ChatResponseWrapper
14+
{
15+
[JsonPropertyName("sending_interval")]
16+
public int SendingInterval { get; set; }
17+
18+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
19+
[JsonPropertyName("messages")]
20+
public List<ChatResponseModel>? Messages { get; set; }
21+
22+
public static ChatResponseWrapper? From(ChatMessageWrapper? wrapper, string conversationId, string? messageId = null)
23+
{
24+
if (wrapper == null)
25+
{
26+
return null;
27+
}
28+
29+
return new ChatResponseWrapper
30+
{
31+
SendingInterval = wrapper.SendingInterval,
32+
Messages = wrapper?.Messages?.Select(x => new ChatResponseModel
33+
{
34+
ConversationId = conversationId,
35+
MessageId = messageId ?? x.MessageId,
36+
Text = !string.IsNullOrEmpty(x.SecondaryContent) ? x.SecondaryContent : x.Content,
37+
MessageLabel = x.MessageLabel,
38+
Function = x.FunctionName,
39+
RichContent = x.SecondaryRichContent ?? x.RichContent,
40+
Instruction = x.Instruction,
41+
Data = x.Data,
42+
IsAppend = true
43+
})?.ToList()
44+
};
45+
}
46+
}

src/Plugins/BotSharp.Plugin.ChatHub/Hooks/ChatHubConversationHook.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public override async Task OnResponseGenerated(RoleDialogModel message)
153153
{
154154
ConversationId = conv.ConversationId,
155155
MessageId = item.MessageId,
156+
MessageLabel = item.MessageLabel,
156157
Text = !string.IsNullOrEmpty(item.SecondaryContent) ? item.SecondaryContent : item.Content,
157158
Function = item.FunctionName,
158159
RichContent = item.SecondaryRichContent ?? item.RichContent,

0 commit comments

Comments
 (0)