fix(encyclopedia): tighten assign tests and first-paragraph handling
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -150,7 +150,12 @@ public sealed partial class AssignNotesUseCase(ITextModel model, EncyclopediaSet
|
||||
log.LogWarning("Dropping new article {Slug}: empty scope", slug);
|
||||
return null;
|
||||
}
|
||||
return new PlannedArticle(slug, Text(o["titleDe"]) ?? slug, Text(o["titleEn"]) ?? slug, category, scope, []);
|
||||
if (Text(o["titleDe"]) is not { } titleDe || Text(o["titleEn"]) is not { } titleEn)
|
||||
{
|
||||
log.LogWarning("Dropping new article {Slug}: missing title", slug);
|
||||
return null;
|
||||
}
|
||||
return new PlannedArticle(slug, titleDe, titleEn, category, scope, []);
|
||||
}
|
||||
|
||||
private static string? Text(JsonNode? n) =>
|
||||
@@ -177,8 +182,8 @@ public sealed partial class AssignNotesUseCase(ITextModel model, EncyclopediaSet
|
||||
private static string FirstParagraph(string body)
|
||||
{
|
||||
var lines = body.Replace("\r", "").Split('\n')
|
||||
.SkipWhile(l => l.Length == 0 || l.TrimStart().StartsWith('#'))
|
||||
.TakeWhile(l => l.Trim().Length > 0);
|
||||
.SkipWhile(l => string.IsNullOrWhiteSpace(l) || l.TrimStart().StartsWith('#'))
|
||||
.TakeWhile(l => !string.IsNullOrWhiteSpace(l));
|
||||
var text = Flatten(string.Join(' ', lines)).Trim();
|
||||
return text.Length > FirstParagraphChars ? text[..FirstParagraphChars] : text;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace Wiki.Application.Encyclopedia;
|
||||
|
||||
/// <summary>
|
||||
/// Prompt texts of the encyclopedia. <see cref="Version"/> is bumped by hand whenever a prompt changes,
|
||||
/// so that a prompt fix retries earlier rejections and failed plans.
|
||||
/// so that a prompt fix retries earlier rejections and failed batches.
|
||||
/// </summary>
|
||||
public static class Prompts
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user