MCPcopy Create free account
hub / github.com/MiniMax-AI/Mini-Agent / LLMClientBase

Class LLMClientBase

mini_agent/llm/base.py:10–84  ·  view source on GitHub ↗

Abstract base class for LLM clients. This class defines the interface that all LLM clients must implement, regardless of the underlying API protocol (Anthropic, OpenAI, etc.).

Source from the content-addressed store, hash-verified

8
9
10class LLMClientBase(ABC):
11 """Abstract base class for LLM clients.
12
13 This class defines the interface that all LLM clients must implement,
14 regardless of the underlying API protocol (Anthropic, OpenAI, etc.).
15 """
16
17 def __init__(
18 self,
19 api_key: str,
20 api_base: str,
21 model: str,
22 retry_config: RetryConfig | None = None,
23 ):
24 """Initialize the LLM client.
25
26 Args:
27 api_key: API key for authentication
28 api_base: Base URL for the API
29 model: Model name to use
30 retry_config: Optional retry configuration
31 """
32 self.api_key = api_key
33 self.api_base = api_base
34 self.model = model
35 self.retry_config = retry_config or RetryConfig()
36
37 # Callback for tracking retry count
38 self.retry_callback = None
39
40 @abstractmethod
41 async def generate(
42 self,
43 messages: list[Message],
44 tools: list[Any] | None = None,
45 ) -> LLMResponse:
46 """Generate response from LLM.
47
48 Args:
49 messages: List of conversation messages
50 tools: Optional list of Tool objects or dicts
51
52 Returns:
53 LLMResponse containing the generated content, thinking, and tool calls
54 """
55 pass
56
57 @abstractmethod
58 def _prepare_request(
59 self,
60 messages: list[Message],
61 tools: list[Any] | None = None,
62 ) -> dict[str, Any]:
63 """Prepare the request payload for the API.
64
65 Args:
66 messages: List of conversation messages
67 tools: Optional list of available tools

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected