diff --git a/README.md b/README.md index a919a81..0903e85 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ paperless-gpt’s flexible **prompt templates** let you shape how AI responds: 1. **`title_prompt.tmpl`**: For document titles. 2. **`tag_prompt.tmpl`**: For tagging logic. 3. **`ocr_prompt.tmpl`**: For LLM OCR. +4. **`correspondent_prompt.tmpl`**: For correspondent identification. Mount them into your container via: @@ -195,6 +196,34 @@ Mount them into your container via: Then tweak at will—**paperless-gpt** reloads them automatically on startup! +#### Template Variables + +Each template has access to specific variables: + +**title_prompt.tmpl**: +- `{{.Language}}` - Target language (e.g., "English") +- `{{.Content}}` - Document content text +- `{{.Title}}` - Original document title + +**tag_prompt.tmpl**: +- `{{.Language}}` - Target language +- `{{.AvailableTags}}` - List of existing tags in paperless-ngx +- `{{.OriginalTags}}` - Document's current tags +- `{{.Title}}` - Document title +- `{{.Content}}` - Document content text + +**ocr_prompt.tmpl**: +- `{{.Language}}` - Target language + +**correspondent_prompt.tmpl**: +- `{{.Language}}` - Target language +- `{{.AvailableCorrespondents}}` - List of existing correspondents +- `{{.BlackList}}` - List of blacklisted correspondent names +- `{{.Title}}` - Document title +- `{{.Content}}` - Document content text + +The templates use Go's text/template syntax. paperless-gpt automatically reloads template changes on startup. + --- ## Usage diff --git a/app_llm.go b/app_llm.go index aeaf0e4..8a56b6d 100644 --- a/app_llm.go +++ b/app_llm.go @@ -252,6 +252,7 @@ func (app *App) getSuggestedTitle(ctx context.Context, content string, originalT var promptBuffer bytes.Buffer templateData["Content"] = truncatedContent err = titleTemplate.Execute(&promptBuffer, templateData) + if err != nil { return "", fmt.Errorf("error executing title template: %v", err) }