@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Api.Services.Contracts;
|
||||
using Rag.Models.Requests;
|
||||
using Rag.Models.Responses;
|
||||
|
||||
namespace Api.Controllers;
|
||||
|
||||
@@ -19,7 +20,7 @@ public sealed class RagController : ControllerBase
|
||||
|
||||
[HttpPost("documents")]
|
||||
[RequestSizeLimit(10 * 1024 * 1024)]
|
||||
public async Task<IActionResult> IndexDocument(
|
||||
public async Task<ActionResult<IndexDocumentResponse>> IndexDocument(
|
||||
[FromForm] IFormFile? file,
|
||||
[FromForm] string? text,
|
||||
[FromForm] string? documentType,
|
||||
@@ -59,7 +60,7 @@ public sealed class RagController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPost("documents/json")]
|
||||
public async Task<IActionResult> IndexJsonDocument([FromBody] IndexDocumentRequest request, CancellationToken ct)
|
||||
public async Task<ActionResult<IndexDocumentResponse>> IndexJsonDocument([FromBody] IndexDocumentRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -78,7 +79,7 @@ public sealed class RagController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPost("search")]
|
||||
public async Task<IActionResult> Search([FromBody] SearchRequest request, CancellationToken ct)
|
||||
public async Task<ActionResult<SearchResponse>> Search([FromBody] SearchRequest request, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -96,7 +97,7 @@ public sealed class RagController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpGet("documents/{id}")]
|
||||
public async Task<IActionResult> GetDocument(string id, CancellationToken ct)
|
||||
public async Task<ActionResult<RagDocumentDetailsResponse>> GetDocument(string id, CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Get document request received. DocumentId={DocumentId}", id);
|
||||
var document = await _ragService.GetDocumentAsync(id, ct);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Rag.Models;
|
||||
using Rag.Models.Requests;
|
||||
using Rag.Models.Responses;
|
||||
|
||||
@@ -9,5 +8,5 @@ public interface IRagService
|
||||
Task<IndexDocumentResponse> IndexTextAsync(IndexDocumentRequest request, CancellationToken ct);
|
||||
Task<IndexDocumentResponse> IndexPdfAsync(IFormFile file, string? documentType, string? title, string? sourceUrl, CancellationToken ct);
|
||||
Task<SearchResponse> SearchAsync(SearchRequest request, CancellationToken ct);
|
||||
Task<RagDocumentDetails?> GetDocumentAsync(string documentId, CancellationToken ct);
|
||||
Task<RagDocumentDetailsResponse?> GetDocumentAsync(string documentId, CancellationToken ct);
|
||||
}
|
||||
|
||||
@@ -97,10 +97,10 @@ public sealed class RagService : IRagService
|
||||
return new SearchResponse { Results = results };
|
||||
}
|
||||
|
||||
public async Task<RagDocumentDetails?> GetDocumentAsync(string documentId, CancellationToken ct)
|
||||
public async Task<RagDocumentDetailsResponse?> GetDocumentAsync(string documentId, CancellationToken ct)
|
||||
{
|
||||
var document = await _repository.GetDocumentByIdAsync(documentId, ct);
|
||||
return document is null ? null : new RagDocumentDetails
|
||||
return document is null ? null : new RagDocumentDetailsResponse
|
||||
{
|
||||
Id = document.Id,
|
||||
DocumentType = document.DocumentType,
|
||||
|
||||
Reference in New Issue
Block a user