39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from abc import ABC, abstractmethod
|
|
from typing import List, Optional, TypeVar, Callable
|
|
|
|
from openai.types.chat import ChatCompletionMessageParam
|
|
from pydantic import BaseModel
|
|
|
|
T = TypeVar('T', bound=BaseModel)
|
|
|
|
class ILLMService(ABC):
|
|
|
|
@abstractmethod
|
|
async def prediction(
|
|
self,
|
|
model: str,
|
|
messages: List,
|
|
fields_to_check: Optional[List[str]],
|
|
temperature: float,
|
|
check_blacklisted: bool = True,
|
|
token_count: int = -1
|
|
):
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def prediction_override(self, **kwargs):
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def pydantic_prediction(
|
|
self,
|
|
messages: List[ChatCompletionMessageParam],
|
|
map_to_model: Callable,
|
|
json_scheme: str,
|
|
*,
|
|
model: Optional[str] = None,
|
|
temperature: Optional[float] = None,
|
|
max_retries: int = 3
|
|
) -> List[T] | T | None:
|
|
pass
|