refine content log after call bot

This commit is contained in:
Jicheng Lu 2024-02-21 10:56:13 -06:00
parent 5e1f5c0843
commit 41ff234d53

View file

@ -82,7 +82,18 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook
var conversationId = _state.GetConversationId();
var agent = await agentService.LoadAgent(message.CurrentAgentId);
await _chatHub.Clients.User(_user.Id).SendAsync("OnConversationContentLogGenerated", BuildContentLog(conversationId, agent?.Name, tokenStats.Prompt, message));
string log;
if (message.Role == AgentRole.Function)
{
log = $"[{agent?.Name}]: {message.FunctionName}({message.FunctionArgs}) => {message.Content}";
log += $"\r\n<== MessageId: {message.MessageId}";
}
else
{
log = tokenStats.Prompt;
}
await _chatHub.Clients.User(_user.Id).SendAsync("OnConversationContentLogGenerated", BuildContentLog(conversationId, agent?.Name, log, message));
}
/// <summary>