71 lines
2.1 KiB
C#
71 lines
2.1 KiB
C#
namespace ChatRAG.Models
|
|
{
|
|
/// <summary>
|
|
/// Modelo para saída de dados (READ)
|
|
/// </summary>
|
|
public class DocumentOutput
|
|
{
|
|
public string Id { get; set; } = string.Empty;
|
|
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 double[]? Embedding { get; set; }
|
|
|
|
public TextoComEmbedding ToTextoComEmbedding()
|
|
{
|
|
return new TextoComEmbedding
|
|
{
|
|
Id = Id,
|
|
Titulo = Title,
|
|
Conteudo = Content,
|
|
ProjetoId = ProjectId,
|
|
Embedding = Embedding
|
|
};
|
|
}
|
|
|
|
public static DocumentOutput FromTextoComEmbedding(TextoComEmbedding texto)
|
|
{
|
|
return new DocumentOutput
|
|
{
|
|
Id = texto.Id,
|
|
Title = texto.Titulo,
|
|
Content = texto.Conteudo,
|
|
ProjectId = texto.ProjetoId,
|
|
Embedding = texto.Embedding,
|
|
CreatedAt = DateTime.UtcNow,
|
|
UpdatedAt = DateTime.UtcNow
|
|
};
|
|
}
|
|
|
|
public string GetContentPreview(int maxLength = 200)
|
|
{
|
|
if (string.IsNullOrEmpty(Content))
|
|
return string.Empty;
|
|
|
|
if (Content.Length <= maxLength)
|
|
return Content;
|
|
|
|
return Content.Substring(0, maxLength) + "...";
|
|
}
|
|
|
|
public bool HasEmbedding() => Embedding != null && Embedding.Length > 0;
|
|
|
|
public DocumentInput ToInput()
|
|
{
|
|
return new DocumentInput
|
|
{
|
|
Id = Id,
|
|
Title = Title,
|
|
Content = Content,
|
|
ProjectId = ProjectId,
|
|
Metadata = Metadata,
|
|
CreatedAt = CreatedAt,
|
|
UpdatedAt = UpdatedAt
|
|
};
|
|
}
|
|
}
|
|
}
|