File size: 609 Bytes
9041389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from __future__ import annotations
from typing import List, Protocol, Type, Dict
import enum


class DefaultEnumMeta(enum.EnumMeta):

    def __call__(cls, value=None, *args, **kwargs) -> DefaultEnumMeta:
        if value is None:
            return next(iter(cls))
        return super().__call__(value, *args, **kwargs)  # type: ignore


class LLMInterface(Protocol):

    def get_chat_completion(self, messages: List, model: enum.Enum, temperature: float,
                            **kwargs) -> str:
        ...

    def get_text_embedding(self, input: str, model: enum.Enum) -> List[float]:
        ...