"""Service interfaces/protocols for dependency injection and testing""" from typing import Protocol, List, Dict, Any, AsyncGenerator, Optional from abc import ABC, abstractmethod class ILLMClient(Protocol): """LLM client protocol""" async def stream_call( self, model: str, messages: List[Dict], tools: Optional[List[Dict]] = None, **kwargs ) -> AsyncGenerator[str, None]: """Stream call LLM API""" ... class IToolExecutor(Protocol): """Tool executor protocol""" def process_tool_calls( self, tool_calls: List[Dict[str, Any]], context: Dict[str, Any] ) -> List[Dict[str, Any]]: """Process tool calls sequentially""" ... def process_tool_calls_parallel( self, tool_calls: List[Dict[str, Any]], context: Dict[str, Any] ) -> List[Dict[str, Any]]: """Process tool calls in parallel""" ... class IMessageRepository(Protocol): """Message repository protocol""" def get_messages( self, conversation_id: int, order_by: str = "created_at" ) -> List[Any]: """Get messages for a conversation""" ... def save_message( self, conversation_id: int, role: str, content: str, token_count: int = 0, usage: Optional[Dict] = None ) -> Any: """Save a message""" ... class IProviderRepository(Protocol): """LLM provider repository protocol""" def get_by_id(self, provider_id: int) -> Optional[Any]: """Get provider by ID""" ...