This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
namespace Rag.Models
|
||||
{
|
||||
public sealed class DocumentClassification
|
||||
{
|
||||
public required string DocumentType { get; init; }
|
||||
public double Confidence { get; init; }
|
||||
public required string Title { get; init; }
|
||||
public Dictionary<string, string> Metadata { get; init; } = new Dictionary<string, string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Rag.Models
|
||||
{
|
||||
public sealed class RagChunkRecord
|
||||
{
|
||||
public required string Id { get; init; }
|
||||
public required string DocumentId { get; init; }
|
||||
public int ChunkIndex { get; init; }
|
||||
public required string Text { get; init; }
|
||||
public required float[] Embedding { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Rag.Models
|
||||
{
|
||||
public sealed class RagDocumentRecord
|
||||
{
|
||||
public required string Id { get; init; }
|
||||
public required string DocumentType { get; init; }
|
||||
public required string Title { get; init; }
|
||||
public string? SourceUrl { get; init; }
|
||||
public required string Text { get; init; }
|
||||
public required string TextHash { get; init; }
|
||||
public double TypeConfidence { get; init; }
|
||||
public string MetadataJson { get; init; } = "{}";
|
||||
public DateTimeOffset CreatedAt { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Rag.Models.Requests
|
||||
{
|
||||
public class IndexDocumentRequest
|
||||
{
|
||||
public string? Text { get; set; }
|
||||
public string? SourceUrl { get; set; }
|
||||
public string? DocumentType { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public Dictionary<string, string>? Metadata { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Rag.Models.Requests
|
||||
{
|
||||
public sealed class IndexDocumentUploadRequest: IndexDocumentRequest
|
||||
{
|
||||
public IFormFile? File { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Rag.Models.Requests
|
||||
{
|
||||
public sealed class SearchRequest
|
||||
{
|
||||
public required string QueryText { get; init; }
|
||||
public IReadOnlyList<string>? TargetDocumentTypes { get; init; }
|
||||
public int? TopK { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Rag.Models.Responses
|
||||
{
|
||||
public sealed class IndexDocumentResponse
|
||||
{
|
||||
public required string DocumentId { get; init; }
|
||||
public required string TextHash { get; init; }
|
||||
public required string DocumentType { get; init; }
|
||||
public double DocumentTypeConfidence { get; init; }
|
||||
public required string Title { get; init; }
|
||||
public int Chunks { get; init; }
|
||||
public int Characters { get; init; }
|
||||
public bool Cached { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Rag.Models.Responses
|
||||
{
|
||||
public sealed class RagDocumentDetailsResponse
|
||||
{
|
||||
public required string Id { get; init; }
|
||||
public required string DocumentType { get; init; }
|
||||
public required string Title { get; init; }
|
||||
public string? SourceUrl { get; init; }
|
||||
public required string Text { get; init; }
|
||||
public required string TextHash { get; init; }
|
||||
public DateTimeOffset CreatedAt { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Rag.Models.Responses
|
||||
{
|
||||
public sealed class SearchResponse
|
||||
{
|
||||
public IReadOnlyList<SearchDocumentResult> Results { get; init; } = System.Array.Empty<SearchDocumentResult>();
|
||||
}
|
||||
|
||||
public sealed class SearchDocumentResult
|
||||
{
|
||||
public required string DocumentId { get; init; }
|
||||
public required string DocumentType { get; init; }
|
||||
public required string Title { get; init; }
|
||||
public string? SourceUrl { get; init; }
|
||||
public double Score { get; init; }
|
||||
public IReadOnlyList<SearchChunkResult> MatchedChunks { get; init; } = System.Array.Empty<SearchChunkResult>();
|
||||
}
|
||||
|
||||
public sealed class SearchChunkResult
|
||||
{
|
||||
public required string ChunkId { get; init; }
|
||||
public int ChunkIndex { get; init; }
|
||||
public required string Text { get; init; }
|
||||
public double Score { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Rag.Models
|
||||
{
|
||||
public sealed class SearchCandidateChunk
|
||||
{
|
||||
public required RagDocumentRecord Document { get; init; }
|
||||
public required RagChunkRecord Chunk { get; init; }
|
||||
public double Score { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Rag.Models.Settings;
|
||||
|
||||
public sealed class AiSettings
|
||||
{
|
||||
public string Provider { get; set; } = "OpenAI";
|
||||
public OpenAiSettings OpenAI { get; set; } = new();
|
||||
public OllamaSettings Ollama { get; set; } = new();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Rag.Models.Settings;
|
||||
|
||||
public sealed class OllamaSettings : Shared.Models.Settings.OllamaSettings
|
||||
{
|
||||
public string EmbeddingModel { get; set; } = "nomic-embed-text";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Rag.Models.Settings;
|
||||
|
||||
public sealed class OpenAiSettings: Shared.Models.Settings.OpenAiSettings
|
||||
{
|
||||
public string EmbeddingModel { get; set; } = "text-embedding-3-small";
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Rag.Models.Settings;
|
||||
|
||||
public sealed class RagSettings
|
||||
{
|
||||
public int MaxFileSizeMb { get; set; } = 8;
|
||||
public int ChunkSize { get; set; } = 900;
|
||||
public int ChunkOverlap { get; set; } = 150;
|
||||
public int MaxTextChars { get; set; } = 60000;
|
||||
public int DefaultTopK { get; set; } = 20;
|
||||
public int MaxTopK { get; set; } = 50;
|
||||
public bool ClassifyWithAi { get; set; } = false;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>Rag.Models</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\shared-models\shared-models.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user