OverviewFilesCommitsIssuesDocsReleasesPeers

ollama_semantic_function_calling / ollamatools-new / ollamatools / plugins / base.py

59 lines · python ref:
"""Base plugin interfaces for the OllamaTools plugin system."""

from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional

class Plugin(ABC):
    """Base class for all plugins."""
    
    @property
    @abstractmethod
    def name(self) -> str:
        """Return the name of the plugin."""
        pass
    
    @property
    @abstractmethod
    def version(self) -> str:
        """Return the version of the plugin."""
        pass
    
    @abstractmethod
    def initialize(self, config: Dict[str, Any]) -> None:
        """Initialize the plugin with the given configuration."""
        pass
    
    @abstractmethod
    def shutdown(self) -> None:
        """Shutdown the plugin and release any resources."""
        pass

class ToolPlugin(Plugin):
    """Base class for tool plugins."""
    
    @abstractmethod
    def get_tools(self) -> List[Dict[str, Any]]:
        """Return the list of tools provided by this plugin."""
        pass

class StandardPlugin(Plugin):
    """Base class for standard plugins."""
    
    @abstractmethod
    def process_message(self, message: Dict[str, Any]) -> Dict[str, Any]:
        """Process a message and return the result."""
        pass

class IntegrationPlugin(Plugin):
    """Base class for integration plugins."""
    
    @abstractmethod
    def connect(self) -> bool:
        """Connect to the external service."""
        pass
    
    @abstractmethod
    def disconnect(self) -> None:
        """Disconnect from the external service."""
        pass