|
| 1 | +using BotSharp.Abstraction.Loggers.Models; |
| 2 | +using System.Text.Json.Serialization; |
| 3 | + |
| 4 | +namespace BotSharp.OpenAPI.ViewModels.Instructs; |
| 5 | + |
| 6 | +public class InstructionLogViewModel |
| 7 | +{ |
| 8 | + [JsonPropertyName("id")] |
| 9 | + public string Id { get; set; } = default!; |
| 10 | + |
| 11 | + [JsonPropertyName("agent_id")] |
| 12 | + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] |
| 13 | + public string? AgentId { get; set; } |
| 14 | + |
| 15 | + [JsonPropertyName("agent_name")] |
| 16 | + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] |
| 17 | + public string? AgentName { get; set; } |
| 18 | + |
| 19 | + [JsonPropertyName("provider")] |
| 20 | + public string Provider { get; set; } = default!; |
| 21 | + |
| 22 | + [JsonPropertyName("model")] |
| 23 | + public string Model { get; set; } = default!; |
| 24 | + |
| 25 | + [JsonPropertyName("template_name")] |
| 26 | + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] |
| 27 | + public string? TemplateName { get; set; } |
| 28 | + |
| 29 | + [JsonPropertyName("user_message")] |
| 30 | + public string UserMessage { get; set; } = string.Empty; |
| 31 | + |
| 32 | + [JsonPropertyName("system_instruction")] |
| 33 | + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] |
| 34 | + public string? SystemInstruction { get; set; } |
| 35 | + |
| 36 | + [JsonPropertyName("completion_text")] |
| 37 | + public string CompletionText { get; set; } = string.Empty; |
| 38 | + |
| 39 | + [JsonPropertyName("user_id")] |
| 40 | + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] |
| 41 | + public string? UserId { get; set; } |
| 42 | + |
| 43 | + [JsonPropertyName("states")] |
| 44 | + public Dictionary<string, string> States { get; set; } = []; |
| 45 | + |
| 46 | + [JsonPropertyName("created_time")] |
| 47 | + public DateTime CreatedTime { get; set; } = DateTime.UtcNow; |
| 48 | + |
| 49 | + public static InstructionLogViewModel From(InstructionLogModel log) |
| 50 | + { |
| 51 | + return new InstructionLogViewModel |
| 52 | + { |
| 53 | + Id = log.Id, |
| 54 | + AgentId = log.AgentId, |
| 55 | + AgentName = log.AgentName, |
| 56 | + Provider = log.Provider, |
| 57 | + Model = log.Model, |
| 58 | + TemplateName = log.TemplateName, |
| 59 | + UserMessage = log.UserMessage, |
| 60 | + SystemInstruction = log.SystemInstruction, |
| 61 | + CompletionText = log.CompletionText, |
| 62 | + UserId = log.UserId, |
| 63 | + States = log.States, |
| 64 | + CreatedTime = log.CreatedTime |
| 65 | + }; |
| 66 | + } |
| 67 | +} |
0 commit comments