Validate AI findings against source invoice reports
This commit is contained in:
1 parent
5b697ee200
commit
6e1187cdd1
5 files changed
+196
-3
No files matched your search
@@ -60,6 +60,28 @@ try
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Schema auf gültige JSON-Syntax prüfen.
|
||||
using var schemaDocument = JsonDocument.Parse(schema);
|
||||
|
||||
// Den ursprünglichen Prüfbericht für den späteren Abgleich einlesen.
|
||||
var reportOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web)
|
||||
{
|
||||
RespectRequiredConstructorParameters = true,
|
||||
RespectNullableAnnotations = true
|
||||
};
|
||||
|
||||
var sourceReport = JsonSerializer.Deserialize<ImportReport>(
|
||||
report, reportOptions);
|
||||
|
||||
if (sourceReport is null ||
|
||||
sourceReport.Rows.Any(row => row is null) ||
|
||||
sourceReport.Status is not ("Completed" or "Rejected"))
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
"Der Eingabebericht enthält keine unterstützte Berichtsstruktur.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var azureClient = new AzureOpenAIClient(
|
||||
endpointUri, new ApiKeyCredential(apiKey));
|
||||
|
||||
@@ -154,7 +176,8 @@ try
|
||||
return 2;
|
||||
}
|
||||
|
||||
var validationErrors = InvoiceAnalysisValidator.Validate(analysis);
|
||||
var validationErrors =
|
||||
InvoiceAnalysisValidator.Validate(analysis, sourceReport);
|
||||
|
||||
if (validationErrors.Count > 0)
|
||||
{
|
||||
@@ -182,7 +205,7 @@ catch (ClientResultException ex)
|
||||
catch (JsonException ex)
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
$"Die JSON-Antwort passt nicht zum erwarteten C#-Datenmodell: {ex.Message}");
|
||||
$"JSON konnte nicht gelesen werden oder passt nicht zum Datenmodell: {ex.Message}");
|
||||
return 2;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
||||
Reference in new issue
Block a user