swarmauri-core 0.6.0.dev128__tar.gz → 0.6.0.dev129__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/PKG-INFO +1 -1
  2. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/pyproject.toml +1 -1
  3. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/ComponentBase.py +46 -17
  4. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/README.md +0 -0
  5. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/README.md +0 -0
  6. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/__init__.py +0 -0
  7. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agent_apis/IAgentCommands.py +0 -0
  8. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agent_apis/IAgentRouterCRUD.py +0 -0
  9. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agent_apis/__init__.py +0 -0
  10. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agent_factories/IExportConf.py +0 -0
  11. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agent_factories/__init__.py +0 -0
  12. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agents/IAgent.py +0 -0
  13. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agents/IAgentConversation.py +0 -0
  14. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agents/IAgentParser.py +0 -0
  15. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agents/IAgentRetrieve.py +0 -0
  16. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agents/IAgentSystemContext.py +0 -0
  17. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agents/IAgentToolkit.py +0 -0
  18. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agents/IAgentVectorStore.py +0 -0
  19. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/agents/__init__.py +0 -0
  20. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chains/ICallableChain.py +0 -0
  21. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chains/IChain.py +0 -0
  22. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chains/IChainContext.py +0 -0
  23. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chains/IChainContextLoader.py +0 -0
  24. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chains/IChainDependencyResolver.py +0 -0
  25. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chains/IChainFactory.py +0 -0
  26. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chains/IChainStep.py +0 -0
  27. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chains/__init__.py +0 -0
  28. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chunkers/IChunker.py +0 -0
  29. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/chunkers/__init__.py +0 -0
  30. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/control_panels/IControlPanel.py +0 -0
  31. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/control_panels/__init__.py +0 -0
  32. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/conversations/IConversation.py +0 -0
  33. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/conversations/IMaxSize.py +0 -0
  34. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/conversations/ISystemContext.py +0 -0
  35. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/conversations/__init__.py +0 -0
  36. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/dataconnectors/IDataConnector.py +0 -0
  37. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/dataconnectors/__init__.py +0 -0
  38. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/distances/IDistanceSimilarity.py +0 -0
  39. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/distances/__init__.py +0 -0
  40. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/document_stores/IDocumentRetrieve.py +0 -0
  41. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/document_stores/IDocumentStore.py +0 -0
  42. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/document_stores/__init__.py +0 -0
  43. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/documents/IDocument.py +0 -0
  44. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/documents/IExperimentDocument.py +0 -0
  45. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/documents/__init__.py +0 -0
  46. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/embeddings/IFeature.py +0 -0
  47. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/embeddings/ISaveModel.py +0 -0
  48. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/embeddings/IVectorize.py +0 -0
  49. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/embeddings/__init__.py +0 -0
  50. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/experiment_stores/IExperimentStore.py +0 -0
  51. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/experiment_stores/__init__.py +0 -0
  52. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/factories/IFactory.py +0 -0
  53. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/factories/__init__.py +0 -0
  54. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/image_gens/IGenImage.py +0 -0
  55. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/image_gens/__init__.py +0 -0
  56. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/llms/IFit.py +0 -0
  57. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/llms/IPredict.py +0 -0
  58. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/llms/__init__.py +0 -0
  59. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/measurements/IMeasurement.py +0 -0
  60. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/measurements/IMeasurementAggregate.py +0 -0
  61. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/measurements/IMeasurementCalculate.py +0 -0
  62. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/measurements/IThreshold.py +0 -0
  63. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/measurements/__init__.py +0 -0
  64. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/messages/IMessage.py +0 -0
  65. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/messages/__init__.py +0 -0
  66. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/parsers/IParser.py +0 -0
  67. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/parsers/__init__.py +0 -0
  68. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/pipelines/IPipeline.py +0 -0
  69. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/pipelines/__init__.py +0 -0
  70. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/prompts/IPrompt.py +0 -0
  71. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/prompts/IPromptMatrix.py +0 -0
  72. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/prompts/ITemplate.py +0 -0
  73. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/prompts/__init__.py +0 -0
  74. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/schema_converters/ISchemaConvert.py +0 -0
  75. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/schema_converters/__init__.py +0 -0
  76. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/service_registries/IServiceRegistry.py +0 -0
  77. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/service_registries/__init__.py +0 -0
  78. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/state/IState.py +0 -0
  79. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/swarm_apis/IAgentRegistrationAPI.py +0 -0
  80. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/swarm_apis/ISwarmAPI.py +0 -0
  81. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/swarm_apis/__init__.py +0 -0
  82. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/swarms/ISwarm.py +0 -0
  83. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/swarms/__init__.py +0 -0
  84. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/task_mgmt_strategies/ITaskMgmtStrategy.py +0 -0
  85. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/task_mgmt_strategies/__init__.py +0 -0
  86. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/toolkits/IToolkit.py +0 -0
  87. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/toolkits/__init__.py +0 -0
  88. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/tools/IParameter.py +0 -0
  89. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/tools/ITool.py +0 -0
  90. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/tools/__init__.py +0 -0
  91. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/tracing/IChainTracer.py +0 -0
  92. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/tracing/ITraceContext.py +0 -0
  93. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/tracing/ITracer.py +0 -0
  94. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/tracing/__init__.py +0 -0
  95. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/transports/ITransport.py +0 -0
  96. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/transports/__init__.py +0 -0
  97. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/utils/ITransactional.py +0 -0
  98. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/utils/__init__.py +0 -0
  99. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vcms/IPredictVision.py +0 -0
  100. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vcms/__init__.py +0 -0
  101. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vector_stores/ICloudVectorStore.py +0 -0
  102. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vector_stores/IPersistentVectorStore.py +0 -0
  103. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vector_stores/ISimilarity.py +0 -0
  104. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vector_stores/IVectorNorm.py +0 -0
  105. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vector_stores/IVectorStore.py +0 -0
  106. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vector_stores/IVectorStoreRetrieve.py +0 -0
  107. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vector_stores/IVectorStoreSaveLoad.py +0 -0
  108. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vector_stores/__init__.py +0 -0
  109. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vectors/IVector.py +0 -0
  110. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vectors/IVectorMeta.py +0 -0
  111. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vectors/IVectorProduct.py +0 -0
  112. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vectors/IVectorTransform.py +0 -0
  113. {swarmauri_core-0.6.0.dev128 → swarmauri_core-0.6.0.dev129}/swarmauri_core/vectors/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: swarmauri-core
3
- Version: 0.6.0.dev128
3
+ Version: 0.6.0.dev129
4
4
  Summary: This repository includes core interfaces for the Swarmauri framework.
5
5
  Home-page: http://github.com/swarmauri/swarmauri-sdk
6
6
  License: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "swarmauri-core"
3
- version = "0.6.0.dev128"
3
+ version = "0.6.0.dev129"
4
4
  description = "This repository includes core interfaces for the Swarmauri framework."
5
5
  authors = ["Jacob Stewart <jacob@swarmauri.com>"]
6
6
  license = "Apache-2.0"
@@ -28,7 +28,7 @@ from typing import (
28
28
  logger = logging.getLogger(__name__)
29
29
  T = TypeVar("T", bound="ComponentBase")
30
30
 
31
- class SubclassUnion(Generic[T], type):
31
+ class SubclassUnion(type):
32
32
  """
33
33
  A generic class to create discriminated unions based on resource types.
34
34
  """
@@ -99,7 +99,7 @@ class ComponentBase(BaseModel):
99
99
  # Class-level registry mapping resource types to their type mappings
100
100
  TYPE_REGISTRY: ClassVar[Dict[Type['ComponentBase'], Dict[str, Type['ComponentBase']]]] = {}
101
101
  # Model registry mapping models to their resource types
102
- MODEL_REGISTRY: ClassVar[Dict[Type[BaseModel], Type['ComponentBase']]] = {}
102
+ MODEL_REGISTRY: ClassVar[Dict[Type[BaseModel], List[Type['ComponentBase']]]] = {}
103
103
  _lock: ClassVar[Lock] = Lock()
104
104
 
105
105
  name: Optional[str] = None
@@ -194,9 +194,9 @@ class ComponentBase(BaseModel):
194
194
  if model_cls not in cls.MODEL_REGISTRY:
195
195
  cls.MODEL_REGISTRY[model_cls] = []
196
196
 
197
- # Inspect all fields to find SubclassUnion annotations
197
+ # Inspect all fields to find SubclassUnion annotations, including inherited fields
198
198
  for field_name, field in model_cls.__fields__.items():
199
- field_annotation = model_cls.__annotations__.get(field_name)
199
+ field_annotation = cls.get_field_annotation(model_cls, field_name)
200
200
  if not field_annotation:
201
201
  continue
202
202
 
@@ -208,10 +208,29 @@ class ComponentBase(BaseModel):
208
208
  if resource_type not in cls.MODEL_REGISTRY[model_cls]:
209
209
  cls.MODEL_REGISTRY[model_cls].append(resource_type)
210
210
  logger.info(f"Registered model '{model_cls.__name__}' for resource '{resource_type.__name__}'")
211
- cls.recreate_models()
212
211
  return model_cls
213
212
  return decorator
214
213
 
214
+ @classmethod
215
+ def get_field_annotation(cls, model_cls: Type[BaseModel], field_name: str):
216
+ """
217
+ Retrieve the field annotation for a given field, including inherited fields.
218
+
219
+ Parameters:
220
+ - model_cls: The Pydantic model class.
221
+ - field_name: The name of the field.
222
+
223
+ Returns:
224
+ - The type annotation of the field, or None if not found.
225
+ """
226
+ for base in inspect.getmro(model_cls):
227
+ if base == object:
228
+ continue
229
+ annotations = getattr(base, '__annotations__', {})
230
+ if field_name in annotations:
231
+ return annotations[field_name]
232
+ return None
233
+
215
234
  @classmethod
216
235
  def get_class_by_type(cls, resource_type: Type[T], type_name: str) -> Type['ComponentBase']:
217
236
  """
@@ -248,7 +267,6 @@ class ComponentBase(BaseModel):
248
267
  return any(cls.field_contains_subclass_union(arg) for arg in args)
249
268
  return False
250
269
 
251
-
252
270
  @classmethod
253
271
  def extract_resource_types_from_field(cls, field_annotation) -> List[Type['ComponentBase']]:
254
272
  """
@@ -292,7 +310,6 @@ class ComponentBase(BaseModel):
292
310
 
293
311
  return resource_types
294
312
 
295
-
296
313
  @classmethod
297
314
  def determine_new_type(cls, field_annotation, resource_type):
298
315
  """
@@ -367,20 +384,28 @@ class ComponentBase(BaseModel):
367
384
 
368
385
  return new_type
369
386
 
370
-
371
387
  @classmethod
372
388
  def generate_models_with_fields(cls) -> Dict[Type[BaseModel], Dict[str, Any]]:
373
389
  """
374
- Automatically generate the models_with_fields dictionary based on registered models.
375
-
390
+ Automatically generate the models_with_fields dictionary based on registered models,
391
+ including subclasses that inherit fields using SubclassUnion.
392
+
376
393
  Returns:
377
394
  - A dictionary mapping model classes to their fields and corresponding resource types.
378
395
  """
379
396
  models_with_fields = {}
380
- for model_cls, resource_types in cls.MODEL_REGISTRY.items():
397
+
398
+ # Collect all models, including subclasses of registered models
399
+ all_models = set(cls.MODEL_REGISTRY.keys())
400
+ for model_cls in list(all_models):
401
+ for subclass in model_cls.__subclasses__():
402
+ if issubclass(subclass, BaseModel):
403
+ all_models.add(subclass)
404
+
405
+ for model_cls in all_models:
381
406
  models_with_fields[model_cls] = {}
382
- for field_name, field in model_cls.__fields__.items():
383
- field_annotation = model_cls.__annotations__.get(field_name)
407
+ for field_name in model_cls.__fields__:
408
+ field_annotation = cls.get_field_annotation(model_cls, field_name)
384
409
  if not field_annotation:
385
410
  continue
386
411
 
@@ -396,6 +421,7 @@ class ComponentBase(BaseModel):
396
421
 
397
422
  return models_with_fields
398
423
 
424
+
399
425
  @classmethod
400
426
  def recreate_models(cls):
401
427
  """
@@ -409,8 +435,11 @@ class ComponentBase(BaseModel):
409
435
  model_class.model_fields[field_name].annotation = new_type
410
436
  else:
411
437
  raise ValueError(f"Field '{field_name}' does not exist in model '{model_class.__name__}'")
412
- if model_class.model_rebuild(force=True):
438
+ try:
439
+ model_class.model_rebuild(force=True)
413
440
  logger.debug(f"'{model_class}' has been successfully recreated.")
414
- else:
415
- logger.debug(f"'{model_class}' recreation has failed.")
416
- logger.info("All models have been successfully recreated.")
441
+ except ValidationError as ve:
442
+ logger.error(f"Validation error while rebuilding model '{model_class.__name__}': {ve}")
443
+ except Exception as e:
444
+ logger.error(f"Error while rebuilding model '{model_class.__name__}': {e}")
445
+ logger.info("All models have been successfully recreated.")