feat(wiki): PR-6 skeleton — DTOs for structured eager output

This commit is contained in:
matevip 2026-04-25 09:56:19 +08:00
parent ec0aaf7da6
commit 9c59092d9c
3 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package vip.mate.wiki.dto;
import java.util.List;
/**
* RFC-051 PR-6 (skeleton): structured create/merge output.
* <p>
* Replaces the legacy {@code ---FILE---} block protocol used by
* {@code WikiBatchCreateParser}. {@code evidenceChunkIds} is optional and
* intended for the on-demand compile path so per-page citations bind to
* the chunks the prompt actually consumed.
* <p>
* Fields are ordered to mirror the existing prompt template so the
* follow-up Spring-AI {@code BeanOutputConverter} swap is a one-shot
* replace of the parser, not a prompt rewrite.
*/
public record GeneratedPage(
String slug,
String title,
String summary,
String pageType,
String content,
List<Long> evidenceChunkIds
) {
public GeneratedPage {
if (evidenceChunkIds == null) evidenceChunkIds = List.of();
}
}

View File

@ -0,0 +1,30 @@
package vip.mate.wiki.dto;
import java.util.List;
/**
* RFC-051 PR-6 (skeleton): structured route-phase output.
* <p>
* Today {@code processChunkTwoPhase} parses the route LLM's free-form JSON
* with a hand-rolled extractor, which fails on weak models that emit
* trailing commentary or mismatched braces. The follow-up wiring will use
* Spring AI {@code BeanOutputConverter<RouteResult>} so the prompt and the
* parser share one schema.
* <p>
* Defining the type up-front (PR-6 partial) lets the prompt rewrite, parser
* swap, and call-site change land in one cohesive PR without renames.
*
* @param create new pages the router proposes (slug + title + summary)
* @param update slugs of existing pages that should absorb this chunk
*/
public record RouteResult(List<RoutedPageMeta> create, List<String> update) {
public RouteResult {
if (create == null) create = List.of();
if (update == null) update = List.of();
}
public boolean isEmpty() {
return create.isEmpty() && update.isEmpty();
}
}

View File

@ -0,0 +1,14 @@
package vip.mate.wiki.dto;
/**
* RFC-051 PR-6 (skeleton): one entry of {@link RouteResult#create()}.
* <p>
* {@code purposeHint} is optional; when populated by the router it feeds
* the create-page prompt's framing.
*/
public record RoutedPageMeta(String slug, String title, String summary, String purposeHint) {
public RoutedPageMeta(String slug, String title, String summary) {
this(slug, title, summary, null);
}
}