Spaces:
Build error
Build error
File size: 858 Bytes
01523b5 |
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 40 41 42 43 44 45 46 |
from abc import abstractmethod
from typing import Dict, Any
from pydantic import BaseModel, Field
class LLMResult(BaseModel):
content: str = ""
function_name: str = ""
function_arguments: Any = None
send_tokens: int = 0
recv_tokens: int = 0
total_tokens: int = 0
class BaseModelArgs(BaseModel):
pass
class BaseLLM(BaseModel):
args: BaseModelArgs = Field(default_factory=BaseModelArgs)
max_retry: int = Field(default=3)
@abstractmethod
def get_spend(self) -> float:
"""
Number of USD spent
"""
return -1.0
@abstractmethod
def generate_response(self, **kwargs) -> LLMResult:
pass
@abstractmethod
def agenerate_response(self, **kwargs) -> LLMResult:
pass
class BaseChatModel(BaseLLM):
pass
class BaseCompletionModel(BaseLLM):
pass
|