From f60bcda89699c5dcb1b8e0cad11a2d07e53de1e6 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 5 Mar 2025 17:32:02 -0600 Subject: [PATCH] relocate --- .../Controllers/LoggerController.cs | 3 +- .../Instructs/InstructionLogViewModel.cs | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/Infrastructure/BotSharp.OpenAPI/ViewModels/Instructs/InstructionLogViewModel.cs diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/LoggerController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/LoggerController.cs index e7ba7fd7..2c46b5b4 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/LoggerController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/LoggerController.cs @@ -1,8 +1,7 @@ using BotSharp.Abstraction.Instructs.Models; using BotSharp.Abstraction.Loggers.Models; using BotSharp.Abstraction.Repositories; -using BotSharp.OpenAPI.ViewModels.Logs; -using EntityFrameworkCore.BootKit; +using BotSharp.OpenAPI.ViewModels.Instructs; using Microsoft.AspNetCore.Hosting; namespace BotSharp.OpenAPI.Controllers; diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Instructs/InstructionLogViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Instructs/InstructionLogViewModel.cs new file mode 100644 index 00000000..88fc27e2 --- /dev/null +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Instructs/InstructionLogViewModel.cs @@ -0,0 +1,67 @@ +using BotSharp.Abstraction.Loggers.Models; +using System.Text.Json.Serialization; + +namespace BotSharp.OpenAPI.ViewModels.Instructs; + +public class InstructionLogViewModel +{ + [JsonPropertyName("id")] + public string Id { get; set; } = default!; + + [JsonPropertyName("agent_id")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? AgentId { get; set; } + + [JsonPropertyName("agent_name")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? AgentName { get; set; } + + [JsonPropertyName("provider")] + public string Provider { get; set; } = default!; + + [JsonPropertyName("model")] + public string Model { get; set; } = default!; + + [JsonPropertyName("template_name")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? TemplateName { get; set; } + + [JsonPropertyName("user_message")] + public string UserMessage { get; set; } = string.Empty; + + [JsonPropertyName("system_instruction")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? SystemInstruction { get; set; } + + [JsonPropertyName("completion_text")] + public string CompletionText { get; set; } = string.Empty; + + [JsonPropertyName("user_id")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? UserId { get; set; } + + [JsonPropertyName("states")] + public Dictionary States { get; set; } = []; + + [JsonPropertyName("created_time")] + public DateTime CreatedTime { get; set; } = DateTime.UtcNow; + + public static InstructionLogViewModel From(InstructionLogModel log) + { + return new InstructionLogViewModel + { + Id = log.Id, + AgentId = log.AgentId, + AgentName = log.AgentName, + Provider = log.Provider, + Model = log.Model, + TemplateName = log.TemplateName, + UserMessage = log.UserMessage, + SystemInstruction = log.SystemInstruction, + CompletionText = log.CompletionText, + UserId = log.UserId, + States = log.States, + CreatedTime = log.CreatedTime + }; + } +}