From ccd7c23da986b0b31902555cd541f839084e6961 Mon Sep 17 00:00:00 2001 From: chait Date: Thu, 13 Feb 2025 11:42:16 +0800 Subject: [PATCH] [update] Non empty code style constraint (default value constraint), change CreateTime to CreatedTime. --- .../Loggers/Models/AgentQueueChangedLogModel.cs | 6 +++--- .../Loggers/Models/ContentLogOutputModel.cs | 12 ++++++------ .../Loggers/Models/ConversationStateLogModel.cs | 13 +++++-------- .../FileRepository/FileRepository.Conversation.cs | 4 ++-- .../Repository/FileRepository/FileRepository.Log.cs | 4 ++-- .../Hooks/StreamingLogHook.cs | 6 +++--- .../Repository/MongoRepository.Log.cs | 12 ++++++------ 7 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/AgentQueueChangedLogModel.cs b/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/AgentQueueChangedLogModel.cs index 0fca0764..f9cee1aa 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/AgentQueueChangedLogModel.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/AgentQueueChangedLogModel.cs @@ -3,11 +3,11 @@ namespace BotSharp.Abstraction.Loggers.Models; public class AgentQueueChangedLogModel { [JsonPropertyName("conversation_id")] - public string ConversationId { get; set; } + public string ConversationId { get; set; } = default!; [JsonPropertyName("log")] - public string Log { get; set; } + public string Log { get; set; } = default!; [JsonPropertyName("created_at")] - public DateTime CreateTime { get; set; } + public DateTime CreatedTime { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ContentLogOutputModel.cs b/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ContentLogOutputModel.cs index fc2ed794..84ce9fbb 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ContentLogOutputModel.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ContentLogOutputModel.cs @@ -3,10 +3,10 @@ namespace BotSharp.Abstraction.Loggers.Models; public class ContentLogOutputModel { [JsonPropertyName("conversation_id")] - public string ConversationId { get; set; } + public string ConversationId { get; set; } = default!; [JsonPropertyName("message_id")] - public string MessageId { get; set; } + public string MessageId { get; set; } = default!; [JsonPropertyName("name")] public string? Name { get; set; } @@ -15,14 +15,14 @@ public class ContentLogOutputModel public string? AgentId { get; set; } [JsonPropertyName("role")] - public string Role { get; set; } + public string Role { get; set; } = default!; [JsonPropertyName("source")] - public string Source { get; set; } + public string Source { get; set; } = default!; [JsonPropertyName("content")] - public string Content { get; set; } + public string Content { get; set; } = default!; [JsonPropertyName("created_at")] - public DateTime CreateTime { get; set; } = DateTime.UtcNow; + public DateTime CreatedTime { get; set; } = DateTime.UtcNow; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ConversationStateLogModel.cs b/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ConversationStateLogModel.cs index 7033d73b..c8fcdd59 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ConversationStateLogModel.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Loggers/Models/ConversationStateLogModel.cs @@ -2,18 +2,15 @@ namespace BotSharp.Abstraction.Loggers.Models; public class ConversationStateLogModel { - [JsonPropertyName("conversation_id")] - public string ConversationId { get; set; } + [JsonPropertyName("conversation_id")] public string ConversationId { get; set; } = default!; - [JsonPropertyName("agent_id")] - public string AgentId { get; set; } + [JsonPropertyName("agent_id")] public string AgentId { get; set; } = default!; - [JsonPropertyName("message_id")] - public string MessageId { get; set; } + [JsonPropertyName("message_id")] public string MessageId { get; set; } = default!; [JsonPropertyName("states")] - public Dictionary States { get; set; } + public Dictionary States { get; set; } = []; [JsonPropertyName("created_at")] - public DateTime CreateTime { get; set; } = DateTime.UtcNow; + public DateTime CreatedTime { get; set; } = DateTime.UtcNow; } diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs index 8afcdc5d..b1837ee6 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs @@ -759,7 +759,7 @@ public partial class FileRepository var log = JsonSerializer.Deserialize(text); if (log == null) continue; - if (log.CreateTime >= refTime) + if (log.CreatedTime >= refTime) { File.Delete(file); } @@ -774,7 +774,7 @@ public partial class FileRepository var log = JsonSerializer.Deserialize(text); if (log == null) continue; - if (log.CreateTime >= refTime) + if (log.CreatedTime >= refTime) { File.Delete(file); } diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Log.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Log.cs index e09800ed..08898864 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Log.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Log.cs @@ -103,7 +103,7 @@ namespace BotSharp.Core.Repository logs.Add(log); } - return logs.OrderBy(x => x.CreateTime).ToList(); + return logs.OrderBy(x => x.CreatedTime).ToList(); } #endregion @@ -148,7 +148,7 @@ namespace BotSharp.Core.Repository logs.Add(log); } - return logs.OrderBy(x => x.CreateTime).ToList(); + return logs.OrderBy(x => x.CreatedTime).ToList(); } #endregion diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs index 410589e7..f895bfca 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs +++ b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs @@ -465,7 +465,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR Role = input.Message.Role, Content = input.Log, Source = input.Source, - CreateTime = DateTime.UtcNow + CreatedTime = DateTime.UtcNow }; var json = JsonSerializer.Serialize(output, _options.JsonSerializerOptions); @@ -488,7 +488,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR AgentId = agentId, MessageId = message.MessageId, States = states, - CreateTime = DateTime.UtcNow + CreatedTime = DateTime.UtcNow }; var convSettings = _services.GetRequiredService(); @@ -527,7 +527,7 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR { ConversationId = conversationId, Log = log, - CreateTime = DateTime.UtcNow + CreatedTime = DateTime.UtcNow }; return JsonSerializer.Serialize(model, _options.JsonSerializerOptions); diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Log.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Log.cs index 88f6ed30..ca13fa3b 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Log.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Log.cs @@ -74,7 +74,7 @@ public partial class MongoRepository Role = log.Role, Source = log.Source, Content = log.Content, - CreatedTime = log.CreateTime + CreatedTime = log.CreatedTime }; _dc.ContentLogs.InsertOne(logDoc); @@ -94,9 +94,9 @@ public partial class MongoRepository Role = x.Role, Source = x.Source, Content = x.Content, - CreateTime = x.CreatedTime + CreatedTime = x.CreatedTime }) - .OrderBy(x => x.CreateTime) + .OrderBy(x => x.CreatedTime) .ToList(); return logs; } @@ -116,7 +116,7 @@ public partial class MongoRepository AgentId= log.AgentId, MessageId = log.MessageId, States = log.States, - CreatedTime = log.CreateTime + CreatedTime = log.CreatedTime }; _dc.StateLogs.InsertOne(logDoc); @@ -133,9 +133,9 @@ public partial class MongoRepository AgentId = x.AgentId, MessageId = x.MessageId, States = x.States, - CreateTime = x.CreatedTime + CreatedTime = x.CreatedTime }) - .OrderBy(x => x.CreateTime) + .OrderBy(x => x.CreatedTime) .ToList(); return logs; }