Skip to content

Commit 4bfd3b9

Browse files
author
Haiping Chen
committed
Add routing stream log.
1 parent 5e1f5c0 commit 4bfd3b9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
using BotSharp.Abstraction.Loggers.Models;
21
using BotSharp.Abstraction.Messaging;
32
using BotSharp.Abstraction.Messaging.Enums;
43
using BotSharp.Abstraction.Messaging.JsonConverters;
54
using BotSharp.Abstraction.Messaging.Models.RichContent;
6-
using BotSharp.Abstraction.Repositories;
75
using Microsoft.AspNetCore.SignalR;
86

97
namespace BotSharp.Plugin.ChatHub.Hooks;

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
using BotSharp.Abstraction.Agents;
21
using BotSharp.Abstraction.Agents.Models;
3-
using BotSharp.Abstraction.Conversations.Models;
2+
using BotSharp.Abstraction.Functions.Models;
43
using BotSharp.Abstraction.Loggers;
54
using BotSharp.Abstraction.Loggers.Models;
6-
using BotSharp.Abstraction.Messaging.Models.RichContent;
7-
using BotSharp.Abstraction.Messaging;
85
using BotSharp.Abstraction.Repositories;
9-
using BotSharp.Core.Agents.Services;
6+
using BotSharp.Abstraction.Repositories.Filters;
7+
using BotSharp.Abstraction.Routing.Settings;
108
using Microsoft.AspNetCore.SignalR;
11-
using Microsoft.VisualBasic;
129

1310
namespace BotSharp.Plugin.ChatHub.Hooks;
1411

@@ -83,6 +80,17 @@ public async Task AfterGenerated(RoleDialogModel message, TokenStatsModel tokenS
8380
var agent = await agentService.LoadAgent(message.CurrentAgentId);
8481

8582
await _chatHub.Clients.User(_user.Id).SendAsync("OnConversationContentLogGenerated", BuildContentLog(conversationId, agent?.Name, tokenStats.Prompt, message));
83+
84+
// Log routing output
85+
try
86+
{
87+
var inst = message.Content.JsonContent<FunctionCallFromLlm>();
88+
await _chatHub.Clients.User(_user.Id).SendAsync("OnConversationContentLogGenerated", BuildContentLog(conversationId, agent?.Name, message.Content, message));
89+
}
90+
catch
91+
{
92+
// ignore
93+
}
8694
}
8795

8896
/// <summary>

0 commit comments

Comments
 (0)