lots of fixes

This commit is contained in:
2026-04-14 04:56:45 -05:00
parent ddd240d865
commit dffb3f3c85
4 changed files with 247 additions and 161 deletions
+12 -14
View File
@@ -2,24 +2,21 @@
Automatically tag your Obsidian notes, add slugs, and add SEO metadata using a local LLM.
The script requires 5 frontmatter fields named as such:
The script requires these frontmatter fields:
- title (used as the basis for the SEO title)
- tags
- seo-title
- seo-description
- seo-keywords
- slug
**Note:** The script sends only the first 20,000 characters of the note to the LLM. This should be more than sufficient for most notes, however if you have extremely long notes then you can increase this amount by editing the following line in `tag-notes.py`:
```py
llm_response = call_llm(None, body[:20000], taxonomy) # Limit content to first 20000 chars
```
**Note:** The script sends only the first 20,000 characters of the note to the LLM. This should be more than sufficient for most notes, however if you have extremely long notes then you can increase this by editing the `CONTENT_CHAR_LIMIT` constant in `tag-notes.py`.
## Setup
1. **Install dependencies:**
```bash
pip install pyyaml requests
pip install pyyaml ruamel.yaml requests
```
2. **Make sure LM Studio is running** on with the preferred model loaded
3. **Place these files in a directory:**
@@ -39,24 +36,25 @@ Simply run the script:
./tag-notes.py
```
It will automatically process all markdown files in the 'NOTES_FOLDER'.
It will recursively process all markdown files under `NOTES_FOLDER`.
## What it does
The script will:
- ✓ Add tags (1-5) using your taxonomy + 1-2 new suggestions
- ✓ Add SEO title (clean, non-clickbaity)
- ✓ Add SEO description (150-160 chars, factual)
- ✓ Add SEO title in the format `{title}: {short descriptor}`, built from the note's `title:` frontmatter field
- ✓ Add SEO description (strictly 150-160 chars, factual — re-asks the LLM once if the first response is out of range)
- ✓ Add SEO keywords (generous, 10-15 keywords)
- ✓ Add slug based off of filename
- ✓ Add slug derived from the filename (lowercased, punctuation stripped, spaces/hyphens collapsed)
- ✓ **Only updates empty fields** - preserves existing values
- ✓ Updates files directly (no confirmation needed)
-**Only touches**: `tags`, `seo-title`, `seo-description`, `seo-keywords`
-**Preserves everything else** in your frontmatter
- ✓ **Preserves existing frontmatter formatting** via round-trip YAML
At the end of a run, if the LLM proposed any genuinely new tags, the script lists them and prompts you to append them to `tag-taxonomy.yaml` automatically.
## Managing the taxonomy
Edit `tag-taxonomy.yaml` to add new tags that the LLM suggests and you like.
At the end of each run, the script will prompt you to add any newly suggested tags to `tag-taxonomy.yaml` automatically. You can also edit the file by hand at any time.
The LLM will:
- Prefer existing taxonomy tags