fix(ai): request structured JSON for queued strategies

This commit is contained in:
cesnimda
2026-10-29 13:03:57 +01:00
parent 994bf8f8bb
commit caa0c6a2ef
8 changed files with 69 additions and 6 deletions
@@ -95,6 +95,7 @@ Candidate master CV:
var generation = await summarizer.GenerateSectionWithMetadataAsync(
instruction,
context,
AiGenerationOutputMode.StructuredJson,
900,
120,
cancellationToken);
+3 -3
View File
@@ -59,7 +59,7 @@ namespace JobTrackerApi.Services
string? FileName
);
public enum AiGenerationOutputMode { Text, CvBlocksJson }
public enum AiGenerationOutputMode { Text, CvBlocksJson, StructuredJson }
public sealed record AiGenerationResult(
string Text,
@@ -232,7 +232,7 @@ namespace JobTrackerApi.Services
{
if (outputMode == AiGenerationOutputMode.Text)
return GenerateSectionWithMetadataAsync(instruction, text, maxLength, minLength, cancellationToken);
if (outputMode != AiGenerationOutputMode.CvBlocksJson || string.IsNullOrWhiteSpace(instruction) || string.IsNullOrWhiteSpace(text))
if (outputMode is not (AiGenerationOutputMode.CvBlocksJson or AiGenerationOutputMode.StructuredJson) || string.IsNullOrWhiteSpace(instruction) || string.IsNullOrWhiteSpace(text))
return Task.FromResult<AiGenerationResult?>(null);
return RewriteCoreAsync(instruction.Trim(), text.Trim(), maxLength, minLength, cancellationToken, outputMode);
}
@@ -328,7 +328,7 @@ namespace JobTrackerApi.Services
text,
max_length = normalizedMaxLength,
min_length = normalizedMinLength,
output_mode = outputMode == AiGenerationOutputMode.CvBlocksJson ? "cv_blocks_json" : "text",
output_mode = outputMode switch { AiGenerationOutputMode.CvBlocksJson => "cv_blocks_json", AiGenerationOutputMode.StructuredJson => "structured_json", _ => "text" },
});
using var content = new StringContent(payload, Encoding.UTF8, "application/json");
var sw = Stopwatch.StartNew();