fix(ai): request structured JSON for queued strategies
This commit is contained in:
@@ -71,6 +71,22 @@ public sealed class CvAiEvaluationTests
|
||||
Assert.Null(await service.GenerateSectionWithMetadataAsync("Improve", "Source", AiGenerationOutputMode.CvBlocksJson));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Structured_generation_has_an_explicit_mode_and_cannot_reuse_text_cache()
|
||||
{
|
||||
var handler = new CaptureHandler();
|
||||
var factory = new Mock<IHttpClientFactory>();
|
||||
factory.Setup(value => value.CreateClient("ai-service")).Returns(new HttpClient(handler) { BaseAddress = new Uri("http://localhost") });
|
||||
using var cache = new MemoryCache(new MemoryCacheOptions());
|
||||
var service = new SummarizerService(factory.Object, cache);
|
||||
await service.GenerateSectionWithMetadataAsync("Return JSON.", "Fictional source.");
|
||||
Assert.NotNull(await service.GenerateSectionWithMetadataAsync("Return JSON.", "Fictional source.", AiGenerationOutputMode.StructuredJson));
|
||||
Assert.Equal(2, handler.RequestCount);
|
||||
using var body = JsonDocument.Parse(handler.Body!);
|
||||
Assert.Equal("structured_json", body.RootElement.GetProperty("output_mode").GetString());
|
||||
Assert.Null(await ((ISummarizerService)new OlderSummarizer()).GenerateSectionWithMetadataAsync("Return JSON.", "Source", AiGenerationOutputMode.StructuredJson));
|
||||
}
|
||||
|
||||
private sealed class CaptureHandler : HttpMessageHandler
|
||||
{
|
||||
public string? Path { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user