Skip to content

Commit dd48166

Browse files
author
Haiping Chen
committed
Fix image data issue.
1 parent 6c676da commit dd48166

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
using BotSharp.Abstraction.Conversations.Models;
44
using BotSharp.Abstraction.Loggers;
55
using BotSharp.Abstraction.Loggers.Models;
6+
using BotSharp.Abstraction.Messaging.Models.RichContent;
7+
using BotSharp.Abstraction.Messaging;
68
using BotSharp.Abstraction.Repositories;
79
using BotSharp.Core.Agents.Services;
810
using Microsoft.AspNetCore.SignalR;
11+
using Microsoft.VisualBasic;
912

1013
namespace BotSharp.Plugin.ChatHub.Hooks;
1114

@@ -99,9 +102,10 @@ public override async Task OnResponseGenerated(RoleDialogModel message)
99102
var agentService = _services.GetRequiredService<IAgentService>();
100103
var agent = await agentService.LoadAgent(message.CurrentAgentId);
101104
var log = $"[{agent?.Name}]: {message.Content}";
102-
if (message.RichContent != null)
105+
if (message.RichContent != null && message.RichContent.Message.RichType != "text")
103106
{
104-
log += $"\r\n{message.RichContent}";
107+
var richContent = JsonSerializer.Serialize(message.RichContent, _serializerOptions);
108+
log += $"\r\n{richContent}";
105109
}
106110
log += $"\r\n<== MessageId: {message.MessageId}";
107111
await _chatHub.Clients.User(_user.Id).SendAsync("OnConversationContentLogGenerated", BuildContentLog(conv.ConversationId, agent?.Name, log, message));

src/Plugins/BotSharp.Plugin.WebDriver/Hooks/WebDriverConversationHook.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ public override async Task OnDialogRecordLoaded(RoleDialogModel dialog)
1717
// load screenshot
1818
if (dialog.Role == AgentRole.Assistant)
1919
{
20-
dialog.Data = "data:image/png;base64," + webDriverService.GetScreenshotBase64(dialog.MessageId);
20+
var image64 = webDriverService.GetScreenshotBase64(dialog.MessageId);
21+
if (image64 != null)
22+
{
23+
dialog.Data = $"data:image/png;base64,{image64}";
24+
}
2125
}
2226

2327
await base.OnDialogRecordLoaded(dialog);

0 commit comments

Comments
 (0)