Harden CV rewrite diagnostics and preview PDFs
This commit is contained in:
@@ -113,6 +113,7 @@ public sealed class ProfileCvController : ControllerBase
|
||||
public sealed record ParseCvRequest(string? Text);
|
||||
public sealed record CvTemplateDescriptor(string Id, string Title, string Tone, string AccentColor, string PreviewTagline, string PreviewSummary, List<string> PreviewBullets);
|
||||
public sealed record ProfileCvPreviewDto(string TemplateId, string Html, string SuggestedFileName, string FullText, string RewrittenText, string? SectionName, StructuredCvProfile StructuredCv, TailoredCvDocument Document, string? TargetRole, int? JobApplicationId);
|
||||
public sealed record CvRewriteFailureDto(string Code, string Message, string? Detail = null, string? LastAiError = null);
|
||||
|
||||
private sealed record ExtractionPipelineResult(string RawText, string NormalizedText, StructuredCvProfile StructuredCv);
|
||||
private sealed record ClassifiedCvBlock(int Index, string OriginalBlock, string SectionName, string Content, CvBlockClassificationResult? Classification);
|
||||
@@ -337,9 +338,23 @@ public sealed class ProfileCvController : ControllerBase
|
||||
|
||||
if (string.IsNullOrWhiteSpace(rewritten))
|
||||
{
|
||||
_logger.LogWarning("CV rewrite returned empty output. Section={SectionName} Template={TemplateId} TargetRole={TargetRole} JobApplicationId={JobApplicationId} HasSourceText={HasSourceText} StructuredSections={StructuredSectionCount}",
|
||||
sectionName ?? "<whole-cv>", templateId, effectiveTargetRole ?? "<none>", jobApplicationId, !string.IsNullOrWhiteSpace(sourceText), structuredCv.Sections.Count);
|
||||
return StatusCode(StatusCodes.Status502BadGateway, "The AI service could not rewrite your CV right now.");
|
||||
var metrics = await _aiService.GetMetricsAsync(HttpContext.RequestAborted);
|
||||
var detail = metrics.Healthy
|
||||
? "The rewrite request reached the AI service, but it returned no usable text."
|
||||
: "The AI rewrite service is unavailable or not ready.";
|
||||
var failureCode = metrics.Healthy ? "rewrite-empty" : "ai-service-unavailable";
|
||||
var message = metrics.Healthy
|
||||
? "The AI service returned an empty CV rewrite."
|
||||
: "The AI service could not rewrite your CV right now.";
|
||||
|
||||
_logger.LogWarning("CV rewrite returned empty output. Section={SectionName} Template={TemplateId} TargetRole={TargetRole} JobApplicationId={JobApplicationId} HasSourceText={HasSourceText} StructuredSections={StructuredSectionCount} AiHealthy={AiHealthy} AiLastError={AiLastError}",
|
||||
sectionName ?? "<whole-cv>", templateId, effectiveTargetRole ?? "<none>", jobApplicationId, !string.IsNullOrWhiteSpace(sourceText), structuredCv.Sections.Count, metrics.Healthy, metrics.LastError ?? "<none>");
|
||||
|
||||
return StatusCode(StatusCodes.Status502BadGateway, new CvRewriteFailureDto(
|
||||
failureCode,
|
||||
message,
|
||||
detail,
|
||||
metrics.LastError));
|
||||
}
|
||||
|
||||
return Ok(new
|
||||
|
||||
Reference in New Issue
Block a user