From d93598a74fa7490f79158b219ac5a22f2310ccb1 Mon Sep 17 00:00:00 2001 From: juk0de Date: Fri, 1 Sep 2023 09:07:58 +0200 Subject: [PATCH] configuration: added AIConfig class --- chatmastermind/configuration.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/chatmastermind/configuration.py b/chatmastermind/configuration.py index 5ae32d6..0780604 100644 --- a/chatmastermind/configuration.py +++ b/chatmastermind/configuration.py @@ -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']),