""" Base provider class for AI providers """ from abc import ABC, abstractmethod from typing import List, Dict, Any, Optional from ..config import Config class BaseProvider(ABC): """Base class for AI providers""" def __init__(self, config: Config): self.config = config @abstractmethod async def chat_completion( self, messages: List[Dict[str, Any]], tools: Optional[List[Dict[str, Any]]] = None, system_prompt: Optional[str] = None ) -> Dict[str, Any]: """ Get chat completion from the provider Args: messages: List of messages in the conversation tools: Optional list of available tools system_prompt: Optional system prompt Returns: Dictionary containing response with 'content' and optional 'tool_calls' """ pass @abstractmethod def parse_tool_calls(self, response: Dict[str, Any]) -> List[Dict[str, Any]]: """ Parse tool calls from provider response Args: response: Provider response Returns: List of tool calls with 'id', 'name', and 'arguments' """ pass @abstractmethod def format_tool_result(self, tool_call_id: str, result: str) -> Dict[str, Any]: """ Format tool result for next request Args: tool_call_id: ID of the tool call result: Result of tool execution Returns: Formatted message for the provider """ pass