feat: implement YAML-based plugin system with metadata

This commit is contained in:
Gigi
2025-04-01 15:41:05 +01:00
parent e1f0a6f467
commit 4deed4e12a
4 changed files with 78 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
name: action_items_todo
description: Extract action items and todos from the transcript
model: llama2 # Optional, falls back to OLLAMA_MODEL from .env
type: or # or, and, all
prompt: |
Extract action items and todos from the following transcript.
Format each item as a markdown checkbox.
If there are no action items or todos, output "No action items or todos found."
Transcript:
{transcript}

10
plugins/summary.all.yaml Normal file
View File

@@ -0,0 +1,10 @@
name: summary
description: Generate a concise summary of the transcript
model: llama2 # Optional, falls back to OLLAMA_MODEL from .env
type: all # or, and, all
prompt: |
Please provide a concise summary of the following transcript.
Focus on the main points and key takeaways.
Transcript:
{transcript}

View File

@@ -4,6 +4,7 @@ python-dotenv>=1.0.0
ollama>=0.1.17
watchdog>=3.0.0
inflect>=7.5.0
pyyaml>=6.0.1
# Development dependencies
pytest>=7.4.0

56
src/plugin_manager.py Normal file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/env python3
from pathlib import Path
import yaml
from typing import Dict, Optional
from dataclasses import dataclass
@dataclass
class Plugin:
name: str
description: str
model: Optional[str]
type: str # or, and, all
prompt: str
class PluginManager:
def __init__(self, plugin_dir: Path):
self.plugin_dir = plugin_dir
self.plugins: Dict[str, Plugin] = {}
self.load_plugins()
def load_plugins(self) -> None:
"""Load all YAML plugins from the plugin directory."""
for plugin_file in self.plugin_dir.glob("*.yaml"):
with open(plugin_file, 'r', encoding='utf-8') as f:
data = yaml.safe_load(f)
# Validate required fields
required_fields = ['name', 'description', 'type', 'prompt']
for field in required_fields:
if field not in data:
raise ValueError(f"Plugin {plugin_file} is missing required field: {field}")
# Create Plugin instance
plugin = Plugin(
name=data['name'],
description=data['description'],
model=data.get('model'), # Optional
type=data['type'],
prompt=data['prompt']
)
self.plugins[plugin.name] = plugin
def get_plugin(self, name: str) -> Optional[Plugin]:
"""Get a plugin by name."""
return self.plugins.get(name)
def get_all_plugins(self) -> Dict[str, Plugin]:
"""Get all loaded plugins."""
return self.plugins
def get_plugins_by_type(self, plugin_type: str) -> Dict[str, Plugin]:
"""Get all plugins of a specific type."""
return {name: plugin for name, plugin in self.plugins.items()
if plugin.type == plugin_type}