Merge branch 'main' into token-limit

This commit is contained in:
Icereed 2025-01-27 13:55:03 +01:00 committed by GitHub
commit e76eaff4cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 0 deletions

View file

@ -185,6 +185,7 @@ paperless-gpts flexible **prompt templates** let you shape how AI responds:
1. **`title_prompt.tmpl`**: For document titles. 1. **`title_prompt.tmpl`**: For document titles.
2. **`tag_prompt.tmpl`**: For tagging logic. 2. **`tag_prompt.tmpl`**: For tagging logic.
3. **`ocr_prompt.tmpl`**: For LLM OCR. 3. **`ocr_prompt.tmpl`**: For LLM OCR.
4. **`correspondent_prompt.tmpl`**: For correspondent identification.
Mount them into your container via: 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! 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 ## Usage

View file

@ -252,6 +252,7 @@ func (app *App) getSuggestedTitle(ctx context.Context, content string, originalT
var promptBuffer bytes.Buffer var promptBuffer bytes.Buffer
templateData["Content"] = truncatedContent templateData["Content"] = truncatedContent
err = titleTemplate.Execute(&promptBuffer, templateData) err = titleTemplate.Execute(&promptBuffer, templateData)
if err != nil { if err != nil {
return "", fmt.Errorf("error executing title template: %v", err) return "", fmt.Errorf("error executing title template: %v", err)
} }