Skip to content

Commit 9fb6d9f

Browse files
authored
Merge pull request #1151 from iceljc/master
allow sending indication
2 parents 7fda8d2 + 4af97e9 commit 9fb6d9f

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

src/Plugins/BotSharp.Plugin.ChartHandler/Functions/PlotChartFn.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public async Task<bool> Execute(RoleDialogModel message)
8282
MessageId = message.MessageId,
8383
CurrentAgentId = message.CurrentAgentId,
8484
Content = obj.ReportSummary,
85+
Indication = "Summarizing",
8586
FunctionName = message.FunctionName,
8687
FunctionArgs = message.FunctionArgs,
8788
CreatedAt = DateTime.UtcNow

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ public override async Task OnResponseGenerated(RoleDialogModel message)
9595

9696
var conv = _services.GetRequiredService<IConversationService>();
9797
var state = _services.GetRequiredService<IConversationStateService>();
98+
99+
var sender = new UserDto
100+
{
101+
FirstName = "AI",
102+
LastName = "Assistant",
103+
Role = AgentRole.Assistant
104+
};
105+
98106
var data = new ChatResponseDto()
99107
{
100108
ConversationId = conv.ConversationId,
@@ -105,12 +113,7 @@ public override async Task OnResponseGenerated(RoleDialogModel message)
105113
Data = message.Data,
106114
States = state.GetStates(),
107115
IsStreaming = message.IsStreaming,
108-
Sender = new()
109-
{
110-
FirstName = "AI",
111-
LastName = "Assistant",
112-
Role = AgentRole.Assistant
113-
}
116+
Sender = sender
114117
};
115118

116119
// Send type-off to client
@@ -130,6 +133,18 @@ public override async Task OnResponseGenerated(RoleDialogModel message)
130133

131134
foreach (var item in wrapper.Messages)
132135
{
136+
if (!string.IsNullOrWhiteSpace(item.Indication))
137+
{
138+
data = new ChatResponseDto
139+
{
140+
ConversationId = conv.ConversationId,
141+
MessageId = item.MessageId,
142+
Indication = item.Indication,
143+
Sender = sender
144+
};
145+
await SendEvent(ChatEvent.OnIndicationReceived, conv.ConversationId, data);
146+
}
147+
133148
await Task.Delay(wrapper.SendingInterval);
134149

135150
data = new ChatResponseDto
@@ -142,12 +157,7 @@ public override async Task OnResponseGenerated(RoleDialogModel message)
142157
Data = item.Data,
143158
States = state.GetStates(),
144159
IsAppend = true,
145-
Sender = new()
146-
{
147-
FirstName = "AI",
148-
LastName = "Assistant",
149-
Role = AgentRole.Assistant
150-
}
160+
Sender = sender
151161
};
152162
await SendEvent(ChatEvent.OnMessageReceivedFromAssistant, conv.ConversationId, data);
153163
}

0 commit comments

Comments
 (0)