fix(ai): request structured JSON for queued strategies
This commit is contained in:
@@ -95,6 +95,7 @@ Candidate master CV:
|
||||
var generation = await summarizer.GenerateSectionWithMetadataAsync(
|
||||
instruction,
|
||||
context,
|
||||
AiGenerationOutputMode.StructuredJson,
|
||||
900,
|
||||
120,
|
||||
cancellationToken);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user