configuration: added AIConfig class

This commit is contained in:
juk0de 2023-09-01 09:07:58 +02:00 committed by Oleksandr Kozachuk
parent 6737fa98c7
commit 33565d351d

View File

@ -7,7 +7,15 @@ OpenAIConfigInst = TypeVar('OpenAIConfigInst', bound='OpenAIConfig')
@dataclass
class OpenAIConfig():
class AIConfig:
"""
The base class of all AI configurations.
"""
name: str
@dataclass
class OpenAIConfig(AIConfig):
"""
The OpenAI section of the configuration file.
"""
@ -25,6 +33,7 @@ class OpenAIConfig():
Create OpenAIConfig from a dict.
"""
return cls(
name='OpenAI',
api_key=str(source['api_key']),
model=str(source['model']),
max_tokens=int(source['max_tokens']),
@ -36,7 +45,7 @@ class OpenAIConfig():
@dataclass
class Config():
class Config:
"""
The configuration file structure.
"""
@ -47,7 +56,7 @@ class Config():
@classmethod
def from_dict(cls: Type[ConfigInst], source: dict[str, Any]) -> ConfigInst:
"""
Create OpenAIConfig from a dict.
Create Config from a dict.
"""
return cls(
system=str(source['system']),