ChatMasterMind Application Refactor and Enhancement #8
@ -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']),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user