commit
cad920097e
|
|
@ -4,10 +4,16 @@ public class ConversationStateLogModel
|
|||
{
|
||||
[JsonPropertyName("conversation_id")]
|
||||
public string ConversationId { get; set; }
|
||||
|
||||
[JsonPropertyName("agent_id")]
|
||||
public string AgentId { get; set; }
|
||||
|
||||
[JsonPropertyName("message_id")]
|
||||
public string MessageId { get; set; }
|
||||
|
||||
[JsonPropertyName("states")]
|
||||
public Dictionary<string, string> States { get; set; }
|
||||
|
||||
[JsonPropertyName("created_at")]
|
||||
public DateTime CreateTime { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,8 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR
|
|||
if (string.IsNullOrEmpty(conversationId)) return;
|
||||
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
await SendStateLog(conv.ConversationId, _state.GetStates(), message);
|
||||
var routingCtx = _services.GetRequiredService<IRoutingContext>();
|
||||
await SendStateLog(conv.ConversationId, routingCtx.EntryAgentId, _state.GetStates(), message);
|
||||
|
||||
if (message.Role == AgentRole.Assistant)
|
||||
{
|
||||
|
|
@ -438,9 +439,9 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR
|
|||
await _chatHub.Clients.User(_user.Id).SendAsync(CONTENT_LOG_GENERATED, BuildContentLog(input));
|
||||
}
|
||||
|
||||
private async Task SendStateLog(string conversationId, Dictionary<string, string> states, RoleDialogModel message)
|
||||
private async Task SendStateLog(string conversationId, string agentId, Dictionary<string, string> states, RoleDialogModel message)
|
||||
{
|
||||
await _chatHub.Clients.User(_user.Id).SendAsync(STATE_LOG_GENERATED, BuildStateLog(conversationId, states, message));
|
||||
await _chatHub.Clients.User(_user.Id).SendAsync(STATE_LOG_GENERATED, BuildStateLog(conversationId, agentId, states, message));
|
||||
}
|
||||
|
||||
private async Task SendAgentQueueLog(string conversationId, string log)
|
||||
|
|
@ -479,11 +480,12 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR
|
|||
return json;
|
||||
}
|
||||
|
||||
private string BuildStateLog(string conversationId, Dictionary<string, string> states, RoleDialogModel message)
|
||||
private string BuildStateLog(string conversationId, string agentId, Dictionary<string, string> states, RoleDialogModel message)
|
||||
{
|
||||
var log = new ConversationStateLogModel
|
||||
{
|
||||
ConversationId = conversationId,
|
||||
AgentId = agentId,
|
||||
MessageId = message.MessageId,
|
||||
States = states,
|
||||
CreateTime = DateTime.UtcNow
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@ namespace BotSharp.Plugin.MongoStorage.Collections;
|
|||
public class ConversationDialogDocument : MongoBase
|
||||
{
|
||||
public string ConversationId { get; set; }
|
||||
public string AgentId { get; set; }
|
||||
public List<DialogMongoElement> Dialogs { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ namespace BotSharp.Plugin.MongoStorage.Collections;
|
|||
public class ConversationStateDocument : MongoBase
|
||||
{
|
||||
public string ConversationId { get; set; }
|
||||
public string AgentId { get; set; }
|
||||
public List<StateMongoElement> States { get; set; } = new List<StateMongoElement>();
|
||||
public List<BreakpointMongoElement> Breakpoints { get; set; } = new List<BreakpointMongoElement>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ namespace BotSharp.Plugin.MongoStorage.Collections;
|
|||
public class ConversationStateLogDocument : MongoBase
|
||||
{
|
||||
public string ConversationId { get; set; }
|
||||
public string AgentId { get; set; }
|
||||
public string MessageId { get; set; }
|
||||
public Dictionary<string, string> States { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public partial class MongoRepository
|
|||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ConversationId = convDoc.Id,
|
||||
AgentId = conversation.AgentId,
|
||||
Dialogs = new List<DialogMongoElement>()
|
||||
};
|
||||
|
||||
|
|
@ -36,6 +37,7 @@ public partial class MongoRepository
|
|||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ConversationId = convDoc.Id,
|
||||
AgentId = conversation.AgentId,
|
||||
States = new List<StateMongoElement>(),
|
||||
Breakpoints = new List<BreakpointMongoElement>()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ public partial class MongoRepository
|
|||
var logDoc = new ConversationStateLogDocument
|
||||
{
|
||||
ConversationId = log.ConversationId,
|
||||
AgentId= log.AgentId,
|
||||
MessageId = log.MessageId,
|
||||
States = log.States,
|
||||
CreateTime = log.CreateTime
|
||||
|
|
@ -129,6 +130,7 @@ public partial class MongoRepository
|
|||
.Select(x => new ConversationStateLogModel
|
||||
{
|
||||
ConversationId = x.ConversationId,
|
||||
AgentId = x.AgentId,
|
||||
MessageId = x.MessageId,
|
||||
States = x.States,
|
||||
CreateTime = x.CreateTime
|
||||
|
|
|
|||
Loading…
Reference in a new issue