Co-authored-by: Mathias <mthbqv@gmail.com>
This commit was merged in pull request #132.
This commit is contained in:
@@ -22,8 +22,18 @@ Each element must have exactly these fields:
|
||||
Wikilinks in content: [[Display Name]] — just the display name, no slug, no pipe separator.
|
||||
Only link to pages listed in the inventory or pages you are creating in this response.`
|
||||
|
||||
// BuildPrompt constructs the user prompt for a single chunk.
|
||||
func BuildPrompt(schema, source, content string, inventory map[wiki.PageType][]wiki.Entry) string {
|
||||
// BuildPrompt constructs the user prompt for a single chunk. existingPage is
|
||||
// the full current content (frontmatter + body) of the source's own wiki page
|
||||
// when one already exists on disk, or "" for a source being ingested for the
|
||||
// first time. When non-empty, the model is asked to revise that page rather
|
||||
// than write a fresh one — see hyperguild#106. The deterministic merge in
|
||||
// wiki.Merge remains the backstop regardless of what the model returns: an
|
||||
// on-disk section the model doesn't touch survives untouched, and a section
|
||||
// it does touch only takes effect where Merge's strategy allows the fresh
|
||||
// side to change anything (bullet union, append) — never for an ordinary
|
||||
// section, so the model proposing a revision is never how a page gets
|
||||
// overwritten.
|
||||
func BuildPrompt(schema, source, content string, inventory map[wiki.PageType][]wiki.Entry, existingPage string) string {
|
||||
var sb strings.Builder
|
||||
|
||||
fmt.Fprintf(&sb, "Today's date is %s.\n\n", time.Now().UTC().Format("2006-01-02"))
|
||||
@@ -49,6 +59,18 @@ func BuildPrompt(schema, source, content string, inventory map[wiki.PageType][]w
|
||||
sb.WriteString("\n")
|
||||
}
|
||||
|
||||
if existingPage != "" {
|
||||
sb.WriteString("## Current page for this source — revise it, don't restart\n\n")
|
||||
sb.WriteString("This source has already been ingested and has the wiki page shown below.\n")
|
||||
sb.WriteString("You are revising that page, not writing a fresh one:\n")
|
||||
sb.WriteString(" - Add sections or claims the source below supports that this page doesn't have yet.\n")
|
||||
sb.WriteString(" - Strengthen a claim where the source gives more detail, evidence, or nuance than what's already there.\n")
|
||||
sb.WriteString(" - Leave unchanged whatever the source doesn't affect — reuse the existing wording verbatim rather than paraphrasing it, so an unchanged claim is recognized as unchanged.\n")
|
||||
sb.WriteString(" - A merge step keeps this page's on-disk content for any section you don't return, so it's fine to omit a section you aren't revising.\n\n")
|
||||
sb.WriteString(existingPage)
|
||||
sb.WriteString("\n\n")
|
||||
}
|
||||
|
||||
sb.WriteString("## Non-negotiable rules\n\n")
|
||||
sb.WriteString("1. Output ONLY a valid JSON array — no prose, no fences.\n")
|
||||
sb.WriteString("2. Fields: title, type, subtype (if applicable), domain (if applicable), content.\n")
|
||||
|
||||
Reference in New Issue
Block a user