OverviewFilesCommitsIssuesDocsReleasesPeers

ollama_semantic_function_calling / ollamatools-new / ollamatools / plugins / standard / function_calling.py

39 lines · python ref:
"""Plugin for semantic function calling."""

from typing import Any, Dict, List, Optional

from ollamatools.plugins.base import StandardPlugin

class FunctionCallingPlugin(StandardPlugin):
    """Plugin for semantic function calling."""
    
    @property
    def name(self) -> str:
        return "function_calling"
    
    @property
    def version(self) -> str:
        return "0.1.0"
    
    def initialize(self, config: Dict[str, Any]) -> None:
        """Initialize the plugin with the given configuration."""
        self.config = config
        self.functions = {}
    
    def shutdown(self) -> None:
        """Shutdown the plugin and release any resources."""
        pass
    
    def register_function(self, name: str, function: callable, description: str, parameters: Dict[str, Any]) -> None:
        """Register a function that can be called semantically."""
        self.functions[name] = {
            "function": function,
            "description": description,
            "parameters": parameters,
        }
    
    def process_message(self, message: Dict[str, Any]) -> Dict[str, Any]:
        """Process a message and extract function calls."""
        # Implementation
        return message