From ca1a89cb6b5ebe7ff5b742692e2ba13d3f080503 Mon Sep 17 00:00:00 2001 From: HRUSHIKESH DOKALA <96101829+Hk669@users.noreply.github.com> Date: Mon, 2 Sep 2024 01:54:27 +0530 Subject: [PATCH] fix model_config SQLModel (#3457) * fix model_config SQLModel * added comment --- .../apps/autogen-studio/autogenstudio/datamodel.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/samples/apps/autogen-studio/autogenstudio/datamodel.py b/samples/apps/autogen-studio/autogenstudio/datamodel.py index 6c6dc567a8..92d60cf5c5 100644 --- a/samples/apps/autogen-studio/autogenstudio/datamodel.py +++ b/samples/apps/autogen-studio/autogenstudio/datamodel.py @@ -16,7 +16,19 @@ from sqlmodel import ( Enum as SqlEnum, ) -SQLModel.model_config["protected_namespaces"] = () +# added for python3.11 and sqlmodel 0.0.22 incompatibility +if hasattr(SQLModel, "model_config"): + SQLModel.model_config["protected_namespaces"] = () +elif hasattr(SQLModel, "Config"): + + class CustomSQLModel(SQLModel): + class Config: + protected_namespaces = () + + SQLModel = CustomSQLModel +else: + print("Warning: Unable to set protected_namespaces.") + # pylint: disable=protected-access