ChatRAG/Models/DocumentInput.cs
2025-06-15 21:34:47 -03:00

44 lines
1.4 KiB
C#

namespace ChatRAG.Models
{
/// <summary>
/// Modelo para entrada de dados (CREATE/UPDATE)
/// </summary>
public class DocumentInput
{
public string? Id { get; set; }
public string Title { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public string ProjectId { get; set; } = string.Empty;
public Dictionary<string, object>? Metadata { get; set; }
public DateTime? CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public static DocumentInput FromTextoComEmbedding(TextoComEmbedding texto)
{
return new DocumentInput
{
Id = texto.Id,
Title = texto.Titulo,
Content = texto.Conteudo,
ProjectId = texto.ProjetoId,
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow
};
}
public DocumentInput WithMetadata(string key, object value)
{
Metadata ??= new Dictionary<string, object>();
Metadata[key] = value;
return this;
}
public bool IsValid()
{
return !string.IsNullOrWhiteSpace(Title) &&
!string.IsNullOrWhiteSpace(Content) &&
!string.IsNullOrWhiteSpace(ProjectId);
}
}
}