configuration: added AIConfig class
This commit is contained in:
parent
7f612bfc17
commit
d93598a74f
@ -7,7 +7,15 @@ OpenAIConfigInst = TypeVar('OpenAIConfigInst', bound='OpenAIConfig')
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@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.
|
The OpenAI section of the configuration file.
|
||||||
"""
|
"""
|
||||||
@ -25,6 +33,7 @@ class OpenAIConfig():
|
|||||||
Create OpenAIConfig from a dict.
|
Create OpenAIConfig from a dict.
|
||||||
"""
|
"""
|
||||||
return cls(
|
return cls(
|
||||||
|
name='OpenAI',
|
||||||
api_key=str(source['api_key']),
|
api_key=str(source['api_key']),
|
||||||
model=str(source['model']),
|
model=str(source['model']),
|
||||||
max_tokens=int(source['max_tokens']),
|
max_tokens=int(source['max_tokens']),
|
||||||
@ -36,7 +45,7 @@ class OpenAIConfig():
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Config():
|
class Config:
|
||||||
"""
|
"""
|
||||||
The configuration file structure.
|
The configuration file structure.
|
||||||
"""
|
"""
|
||||||
@ -47,7 +56,7 @@ class Config():
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls: Type[ConfigInst], source: dict[str, Any]) -> ConfigInst:
|
def from_dict(cls: Type[ConfigInst], source: dict[str, Any]) -> ConfigInst:
|
||||||
"""
|
"""
|
||||||
Create OpenAIConfig from a dict.
|
Create Config from a dict.
|
||||||
"""
|
"""
|
||||||
return cls(
|
return cls(
|
||||||
system=str(source['system']),
|
system=str(source['system']),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user