@@ -21,21 +21,17 @@ public sealed class RagController : ControllerBase
|
||||
[HttpPost("documents")]
|
||||
[RequestSizeLimit(10 * 1024 * 1024)]
|
||||
public async Task<ActionResult<IndexDocumentResponse>> IndexDocument(
|
||||
[FromForm] IFormFile? file,
|
||||
[FromForm] string? text,
|
||||
[FromForm] string? documentType,
|
||||
[FromForm] string? title,
|
||||
[FromForm] string? sourceUrl,
|
||||
[FromForm] IndexDocumentUploadRequest request,
|
||||
CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Index document request received. HasFile={HasFile}, DocumentType={DocumentType}, Title={Title}, SourceUrl={SourceUrl}",
|
||||
file is not null, documentType, title, sourceUrl);
|
||||
request.File is not null, request.DocumentType, request.Title, request.SourceUrl);
|
||||
|
||||
if (file is not null)
|
||||
if (request.File is not null)
|
||||
{
|
||||
var result = await _ragService.IndexPdfAsync(file, documentType, title, sourceUrl, ct);
|
||||
var result = await _ragService.IndexPdfAsync(request.File, request.DocumentType, request.Title, request.SourceUrl, ct);
|
||||
_logger.LogInformation("Indexed PDF document. DocumentId={DocumentId}, DocumentType={DocumentType}, Chunks={Chunks}, Cached={Cached}",
|
||||
result.DocumentId, result.DocumentType, result.Chunks, result.Cached);
|
||||
return Ok(result);
|
||||
@@ -43,10 +39,10 @@ public sealed class RagController : ControllerBase
|
||||
|
||||
var textResult = await _ragService.IndexTextAsync(new IndexDocumentRequest
|
||||
{
|
||||
Text = text,
|
||||
DocumentType = documentType,
|
||||
Title = title,
|
||||
SourceUrl = sourceUrl
|
||||
Text = request.Text,
|
||||
DocumentType = request.DocumentType,
|
||||
Title = request.Title,
|
||||
SourceUrl = request.SourceUrl
|
||||
}, ct);
|
||||
_logger.LogInformation("Indexed text document. DocumentId={DocumentId}, DocumentType={DocumentType}, Chunks={Chunks}, Cached={Cached}",
|
||||
textResult.DocumentId, textResult.DocumentType, textResult.Chunks, textResult.Cached);
|
||||
|
||||
Reference in New Issue
Block a user