Tools for using an obsidian vault as a data store with crewai
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| vault | ||
| vault_1 | ||
| vault_2 | ||
| vault_ops | ||
| .pre-commit-config.yaml | ||
| GEMINI.md | ||
| multi_vault_crew.py | ||
| README.md | ||
| requirements.txt | ||
| sample_crew.py | ||
| USAGE.md | ||
Vault-Ops CrewAI Tool
A comprehensive toolkit for integrating Obsidian vaults with CrewAI agents, providing advanced RAG (Retrieval-Augmented Generation) capabilities along with full CRUD operations and vault maintenance features.
Features
- RAG Q&A: Query your Obsidian vault using semantic search and retrieval-augmented generation
- CRUD Operations: Create, read, update, and delete vault files programmatically
- Vault Maintenance: Automated maintenance tasks including cleaning empty notes, fixing dangling links, managing orphaned attachments, and generating backlinks
- Multi-Vault Support: Work with multiple vaults simultaneously using separate agents
- Vector Indexing: FAISS-powered vector indexing for efficient similarity search
- Secure File Access: Path validation to ensure all operations stay within the vault directory
Installation
- Clone the repository:
git clone ssh://git@forgejo.tail018ac4.ts.net/Mark/crewai_vault_ops_tool.git
cd vault_ops_project
- Install the required dependencies:
pip install -r requirements.txt
Configuration
The tool can be configured with a custom vault path:
from vault_ops.vault_ops_tool import VaultOpsTool
# Use default vault path (./vault)
vault_tool = VaultOpsTool()
# Or specify a custom vault path
vault_tool = VaultOpsTool(vault_path="./my_custom_vault")
Usage
Basic Usage Example
The sample_crew.py file demonstrates basic usage:
from crewai import Agent, Task, Crew
from vault_ops.vault_ops_tool import VaultOpsTool
# Instantiate the tool
vault_tool = VaultOpsTool()
# Define the agent
researcher = Agent(
role='Obsidian Vault Researcher',
goal='Use the vault to answer questions',
backstory='You are an expert in navigating and understanding the content of an Obsidian vault.',
tools=[vault_tool],
verbose=True,
allow_delegation=False
)
# Define the task
task = Task(
description='What is CrewAI?',
agent=researcher
)
# Create and run the crew
crew = Crew(
agents=[researcher],
tasks=[task],
verbose=2
)
result = crew.kickoff()
print("\n\n########################")
print("## Here is the result")
print("########################\n")
print(result)
Multi-Vault Usage
The multi_vault_crew.py file demonstrates how to work with multiple vaults:
from crewai import Agent, Task, Crew
from vault_ops.vault_ops_tool import VaultOpsTool
# Create two instances of the VaultOpsTool, each with a different vault
vault_1_tool = VaultOpsTool(vault_path="./vault_1")
vault_2_tool = VaultOpsTool(vault_path="./vault_2")
# Define two agents, each with a different vault tool
vault_1_researcher = Agent(
role='Vault 1 Researcher',
goal='Use vault 1 to answer questions',
backstory='You are an expert in navigating and understanding the content of vault 1.',
tools=[vault_1_tool],
verbose=True,
allow_delegation=False
)
vault_2_researcher = Agent(
role='Vault 2 Researcher',
goal='Use vault 2 to answer questions',
backstory='You are an expert in navigating and understanding the content of vault 2.',
tools=[vault_2_tool],
verbose=True,
allow_delegation=False
)
# Define two tasks, one for each agent
task_1 = Task(
description='What is in this vault?',
agent=vault_1_researcher
)
task_2 = Task(
description='What is in this vault?',
agent=vault_2_researcher
)
# Create and run the crew
crew = Crew(
agents=[vault_1_researcher, vault_2_researcher],
tasks=[task_1, task_2],
verbose=2
)
result = crew.kickoff()
print("\n\n########################")
print("## Here is the result")
print("########################\n")
print(result)
Available Actions
The VaultOpsTool supports the following actions:
ask: Perform semantic search and Q&A on the vault contentcreate: Create new files in the vaultread: Read content from existing filesupdate: Update content in existing filesdelete: Delete files from the vaultmaintenance: Run various maintenance tasks on the vault
Maintenance Tasks
The tool provides several maintenance capabilities:
empty: Remove empty notesdangling: Find dangling linksorphans: Remove orphaned attachmentsbacklinks: Generate backlinks section in notesindex: Create an index file linking all notes
Dependencies
- crewai
- sentence-transformers
- faiss-cpu
- watchfiles
- pyyaml
- mistune
Project Structure
vault_ops_project/
├── multi_vault_crew.py # Example of multi-vault usage
├── sample_crew.py # Basic usage example
├── requirements.txt # Project dependencies
├── README.md # This file
├── vault/ # Default vault directory
├── vault_1/, vault_2/ # Example vault directories
└── vault_ops/ # Main module
├── vault_ops_tool.py # Core VaultOpsTool implementation
├── embedder.py # Vector embedding utilities
└── maintenance.py # Vault maintenance utilities
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.