This Python script is a powerful agent designed to automatically organize your Obsidian vault. It leverages the power of Google's Gemini 2.5 Flash model to analyze your notes, generate context-aware tags, and create links between related notes, turning your vault into a dynamic, interconnected knowledge graph.
- Automated Tagging: Analyzes the content of your notes and suggests relevant tags, including both topic tags (e.g.,
#python
,#AI
) and type tags (e.g.,#article
,#project
). - Context-Aware Suggestions: Uses not only the note's content but also data from related notes to provide highly relevant and consistent tags.
- Key Concept Extraction: Identifies and extracts key concepts from your notes to provide better context for tag generation.
- Related Notes Linking: Automatically creates a "Related Notes" section in each note, linking to other relevant notes based on shared tags.
- Flexible Configuration: A simple
config.yaml
file allows you to customize the script's behavior, including your vault path, API keys, and model settings. - Dry Run Mode: Run the script in a "read-only" mode to see what changes it would make without modifying any of your files.
- Python 3.7+
- An Obsidian vault
- A Google AI API key
-
Clone the Repository:
git clone <repository-url> cd <repository-name>
-
Install Dependencies:
pip install pyyaml google-generativeai
-
Configure the Script:
- Rename
config.example.yaml
toconfig.yaml
. - Open
config.yaml
and set the following:obsidian_vault_path
: The full path to your Obsidian vault.dry_run
: Set totrue
for the first run to ensure everything is working as expected.gemini.api_key
: Your Google AI API key. For better security, you can set this as an environment variable and reference it as!env GOOGLE_API_KEY
.
- Rename
Once you've completed the setup, you can run the script from your terminal:
python obsidianTag.py
The script will perform the following steps:
- Analyze Vault: Read all of your notes and parse their content and frontmatter.
- Compute Relationships: Identify relationships between notes based on shared tags.
- Generate Tags & Links: For each note, it will:
- Extract key concepts.
- Generate suggested tags using the Gemini model.
- Create a list of related notes.
- Update Notes: If
dry_run
isfalse
, it will update your notes with the new tags and related notes section.
The script is divided into several key components:
- Configuration Loading: Securely loads your settings, including your API key.
- Vault Analysis: Scans your vault to build a comprehensive understanding of your notes.
- Relationship Mapping: Creates a map of how your notes are connected.
- LLM Interaction: Communicates with the Gemini API to get intelligent tag suggestions.
- Note Modification: Carefully updates your notes while preserving their original content.
This agent is designed to be a smart, automated assistant for your knowledge management, helping you to uncover hidden connections and build a more powerful personal knowledge base.
MIT
- Google's Gemini API for the AI capabilities
- The Obsidian community for inspiration