File size: 1,329 Bytes
9c84f9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from abc import ABC, abstractmethod
from typing import Any


class BaseProvider(ABC):
    @abstractmethod
    async def chat_completion(
        self,
        messages: list[dict[str, str]],
        model: str,
        temperature: float = 0.0,
        max_tokens: int = 8000,
        reasoning_effort: str | None = None,
        response_format: dict[str, Any] | None = None,
        tools: list[dict[str, Any]] | None = None,
        tool_choice: str | dict[str, Any] | None = None,
    ) -> dict[str, Any]:
        """Call LLM and return {content, usage, finish_reason, tool_calls}.

        `tools`/`tool_choice` follow the OpenAI function-calling shape
        (`tools=[{"type": "function", "function": {...}}]`). When the model
        responds with tool calls instead of (or alongside) content, the
        returned dict's `tool_calls` key carries them in the same shape
        OpenAI/Upstage return them in (`[{"id", "type": "function",
        "function": {"name", "arguments"}}]`) — empty list when none.
        """
        ...

    @abstractmethod
    async def chat_completion_json(
        self,
        messages: list[dict[str, str]],
        model: str,
        temperature: float = 0.0,
        max_tokens: int = 8000,
    ) -> dict[str, Any]:
        """Call LLM and parse JSON from response."""
        ...