Skip to content

A programming framework for agentic AI

fix model_config SQLModel (#3457)

HRUSHIKESH DOKALAca1a89cb6b5e
diff --git a/samples/apps/autogen-studio/autogenstudio/datamodel.py b/samples/apps/autogen-studio/autogenstudio/datamodel.py
index 6c6dc567a..92d60cf5c 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