mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-07 08:14:25 +01:00
Fix Config.plugins_config - call model_post_init explicitly until pydantic 2.0 (#4858)
As per https://github.com/pydantic/pydantic/issues/1729#issuecomment-1300576214, the implementation of `model_post_init()` is postponed until Pydantic v2. As a result, the initialization of PluginConfig is being skipped. This fix calls `plugin.model_post_init()` explicitly. The recency of the Pydantic v2 release means that some of the other extensions we use do not support it yet. Specifically, extensions such as spacy and openapi-python-client are currently limited to Pydantic versions that are less than 2.0. There may be other extensions that have the same limitation as well. --------- Co-authored-by: Reinier van der Leer <github@pwuts.nl>
This commit is contained in:
@@ -83,6 +83,13 @@ class Config(SystemSettings):
|
||||
plugins: list[str]
|
||||
authorise_key: str
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
# Hotfix: Call model_post_init explictly as it doesn't seem to be called for pydantic<2.0.0
|
||||
# https://github.com/pydantic/pydantic/issues/1729#issuecomment-1300576214
|
||||
self.model_post_init(**kwargs)
|
||||
|
||||
# Executed immediately after init by Pydantic
|
||||
def model_post_init(self, **kwargs) -> None:
|
||||
if not self.plugins_config.plugins:
|
||||
|
||||
Reference in New Issue
Block a user