swarmauri-core 0.6.0.dev119__tar.gz → 0.6.0.dev121__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.dev119 → swarmauri_core-0.6.0.dev121}/PKG-INFO +1 -1
  2. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/pyproject.toml +1 -1
  3. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/ComponentBase.py +19 -65
  4. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/README.md +0 -0
  5. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/README.md +0 -0
  6. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/__init__.py +0 -0
  7. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agent_apis/IAgentCommands.py +0 -0
  8. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agent_apis/IAgentRouterCRUD.py +0 -0
  9. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agent_apis/__init__.py +0 -0
  10. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agent_factories/IExportConf.py +0 -0
  11. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agent_factories/__init__.py +0 -0
  12. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agents/IAgent.py +0 -0
  13. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agents/IAgentConversation.py +0 -0
  14. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agents/IAgentParser.py +0 -0
  15. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agents/IAgentRetrieve.py +0 -0
  16. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agents/IAgentSystemContext.py +0 -0
  17. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agents/IAgentToolkit.py +0 -0
  18. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agents/IAgentVectorStore.py +0 -0
  19. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/agents/__init__.py +0 -0
  20. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chains/ICallableChain.py +0 -0
  21. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chains/IChain.py +0 -0
  22. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chains/IChainContext.py +0 -0
  23. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chains/IChainContextLoader.py +0 -0
  24. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chains/IChainDependencyResolver.py +0 -0
  25. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chains/IChainFactory.py +0 -0
  26. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chains/IChainStep.py +0 -0
  27. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chains/__init__.py +0 -0
  28. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chunkers/IChunker.py +0 -0
  29. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/chunkers/__init__.py +0 -0
  30. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/control_panels/IControlPanel.py +0 -0
  31. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/control_panels/__init__.py +0 -0
  32. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/conversations/IConversation.py +0 -0
  33. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/conversations/IMaxSize.py +0 -0
  34. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/conversations/ISystemContext.py +0 -0
  35. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/conversations/__init__.py +0 -0
  36. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/dataconnectors/IDataConnector.py +0 -0
  37. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/dataconnectors/__init__.py +0 -0
  38. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/distances/IDistanceSimilarity.py +0 -0
  39. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/distances/__init__.py +0 -0
  40. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/document_stores/IDocumentRetrieve.py +0 -0
  41. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/document_stores/IDocumentStore.py +0 -0
  42. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/document_stores/__init__.py +0 -0
  43. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/documents/IDocument.py +0 -0
  44. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/documents/IExperimentDocument.py +0 -0
  45. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/documents/__init__.py +0 -0
  46. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/embeddings/IFeature.py +0 -0
  47. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/embeddings/ISaveModel.py +0 -0
  48. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/embeddings/IVectorize.py +0 -0
  49. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/embeddings/__init__.py +0 -0
  50. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/experiment_stores/IExperimentStore.py +0 -0
  51. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/experiment_stores/__init__.py +0 -0
  52. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/factories/IFactory.py +0 -0
  53. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/factories/__init__.py +0 -0
  54. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/image_gens/IGenImage.py +0 -0
  55. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/image_gens/__init__.py +0 -0
  56. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/llms/IFit.py +0 -0
  57. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/llms/IPredict.py +0 -0
  58. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/llms/__init__.py +0 -0
  59. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/measurements/IMeasurement.py +0 -0
  60. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/measurements/IMeasurementAggregate.py +0 -0
  61. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/measurements/IMeasurementCalculate.py +0 -0
  62. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/measurements/IThreshold.py +0 -0
  63. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/measurements/__init__.py +0 -0
  64. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/messages/IMessage.py +0 -0
  65. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/messages/__init__.py +0 -0
  66. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/parsers/IParser.py +0 -0
  67. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/parsers/__init__.py +0 -0
  68. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/pipelines/IPipeline.py +0 -0
  69. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/pipelines/__init__.py +0 -0
  70. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/prompts/IPrompt.py +0 -0
  71. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/prompts/IPromptMatrix.py +0 -0
  72. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/prompts/ITemplate.py +0 -0
  73. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/prompts/__init__.py +0 -0
  74. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/schema_converters/ISchemaConvert.py +0 -0
  75. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/schema_converters/__init__.py +0 -0
  76. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/service_registries/IServiceRegistry.py +0 -0
  77. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/service_registries/__init__.py +0 -0
  78. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/state/IState.py +0 -0
  79. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/swarm_apis/IAgentRegistrationAPI.py +0 -0
  80. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/swarm_apis/ISwarmAPI.py +0 -0
  81. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/swarm_apis/__init__.py +0 -0
  82. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/swarms/ISwarm.py +0 -0
  83. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/swarms/__init__.py +0 -0
  84. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/task_mgmt_strategies/ITaskMgmtStrategy.py +0 -0
  85. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/task_mgmt_strategies/__init__.py +0 -0
  86. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/toolkits/IToolkit.py +0 -0
  87. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/toolkits/__init__.py +0 -0
  88. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/tools/IParameter.py +0 -0
  89. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/tools/ITool.py +0 -0
  90. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/tools/__init__.py +0 -0
  91. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/tracing/IChainTracer.py +0 -0
  92. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/tracing/ITraceContext.py +0 -0
  93. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/tracing/ITracer.py +0 -0
  94. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/tracing/__init__.py +0 -0
  95. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/transports/ITransport.py +0 -0
  96. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/transports/__init__.py +0 -0
  97. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/utils/ITransactional.py +0 -0
  98. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/utils/__init__.py +0 -0
  99. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vcms/IPredictVision.py +0 -0
  100. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vcms/__init__.py +0 -0
  101. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vector_stores/ICloudVectorStore.py +0 -0
  102. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vector_stores/IPersistentVectorStore.py +0 -0
  103. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vector_stores/ISimilarity.py +0 -0
  104. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vector_stores/IVectorNorm.py +0 -0
  105. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vector_stores/IVectorStore.py +0 -0
  106. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vector_stores/IVectorStoreRetrieve.py +0 -0
  107. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vector_stores/IVectorStoreSaveLoad.py +0 -0
  108. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vector_stores/__init__.py +0 -0
  109. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vectors/IVector.py +0 -0
  110. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vectors/IVectorMeta.py +0 -0
  111. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vectors/IVectorProduct.py +0 -0
  112. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/swarmauri_core/vectors/IVectorTransform.py +0 -0
  113. {swarmauri_core-0.6.0.dev119 → swarmauri_core-0.6.0.dev121}/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.dev119
3
+ Version: 0.6.0.dev121
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.dev119"
3
+ version = "0.6.0.dev121"
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"
@@ -44,10 +44,10 @@ class SubclassUnion(Generic[T], type):
44
44
  """
45
45
  registered_classes = list(ComponentBase.TYPE_REGISTRY.get(resource_type, {}).values())
46
46
  if not registered_classes:
47
- logger.warning(f"No subclasses registered for resource type '{resource_type.__name__}'. Using 'PlaceholderPlugin' as a placeholder.")
48
- registered_classes = [PlaceholderPlugin]
49
-
50
- union_type = Union[tuple(registered_classes)]
47
+ logger.warning(f"No subclasses registered for resource type '{resource_type.__name__}'. Using 'Any' as a placeholder.")
48
+ union_type = Any
49
+ else:
50
+ union_type = Union[tuple(registered_classes)]
51
51
  return Annotated[union_type, Field(discriminator='type')]
52
52
 
53
53
  class ResourceTypes(Enum):
@@ -117,7 +117,6 @@ class ComponentBase(BaseModel):
117
117
  return cls.__name__
118
118
  return v
119
119
 
120
-
121
120
  # Normative Class Methods
122
121
  def __swm_class_hash__(self):
123
122
  sig_hash = hashlib.sha256()
@@ -153,7 +152,7 @@ class ComponentBase(BaseModel):
153
152
  return True
154
153
  return False
155
154
 
156
- # Experimental properties in support of
155
+ # Experimental properties in support of Remote Execution
157
156
 
158
157
  @property
159
158
  def swm_path(self):
@@ -181,7 +180,7 @@ class ComponentBase(BaseModel):
181
180
  cls.TYPE_REGISTRY[resource_type] = {}
182
181
  cls.TYPE_REGISTRY[resource_type][type_name] = subclass
183
182
  # Automatically recreate models after registering a new type
184
- cls.recreate_models_for_resource(resource_type)
183
+ cls.recreate_models()
185
184
  logger.info(f"Registered type '{type_name}' for resource '{resource_type.__name__}' with subclass '{subclass.__name__}'")
186
185
  return subclass
187
186
  return decorator
@@ -211,11 +210,6 @@ class ComponentBase(BaseModel):
211
210
  if resource_type not in cls.MODEL_REGISTRY[model_cls]:
212
211
  cls.MODEL_REGISTRY[model_cls].append(resource_type)
213
212
  logger.info(f"Registered model '{model_cls.__name__}' for resource '{resource_type.__name__}'")
214
-
215
- # Recreate models for all associated resource types
216
- for resource_type in cls.MODEL_REGISTRY[model_cls]:
217
- cls.recreate_models_for_resource(resource_type)
218
-
219
213
  return model_cls
220
214
  return decorator
221
215
 
@@ -236,13 +230,13 @@ class ComponentBase(BaseModel):
236
230
  @classmethod
237
231
  def field_contains_subclass_union(cls, field_annotation) -> bool:
238
232
  """
239
- Check if the field annotation contains a SubclassUnion or the placeholder PlaceholderPlugin.
233
+ Check if the field annotation contains a SubclassUnion.
240
234
 
241
235
  Parameters:
242
236
  - field_annotation: The type annotation of the field.
243
237
 
244
238
  Returns:
245
- - True if SubclassUnion or PlaceholderPlugin is present, False otherwise.
239
+ - True if SubclassUnion is present, False otherwise.
246
240
  """
247
241
  if isinstance(field_annotation, type(SubclassUnion)):
248
242
  return True
@@ -253,15 +247,13 @@ class ComponentBase(BaseModel):
253
247
  elif origin in {list, List, dict, Dict, Union}:
254
248
  args = get_args(field_annotation)
255
249
  return any(cls.field_contains_subclass_union(arg) for arg in args)
256
- elif inspect.isclass(field_annotation) and issubclass(field_annotation, PlaceholderPlugin):
257
- return True
258
250
  return False
259
251
 
260
252
 
261
253
  @classmethod
262
254
  def extract_resource_types_from_field(cls, field_annotation) -> List[Type['ComponentBase']]:
263
255
  """
264
- Extracts all resource types from a field annotation that uses SubclassUnion or PlaceholderPlugin.
256
+ Extracts all resource types from a field annotation that uses SubclassUnion.
265
257
 
266
258
  Parameters:
267
259
  - field_annotation: The type annotation of the field.
@@ -298,9 +290,6 @@ class ComponentBase(BaseModel):
298
290
  # Handle Dict[key_type, SubclassUnion[ResourceType]]
299
291
  value_type = args[1]
300
292
  resource_types.extend(cls.extract_resource_types_from_field(value_type))
301
- elif inspect.isclass(field_annotation) and issubclass(field_annotation, PlaceholderPlugin):
302
- # Placeholder resource type
303
- resource_types.append(field_annotation)
304
293
 
305
294
  return resource_types
306
295
 
@@ -367,10 +356,15 @@ class ComponentBase(BaseModel):
367
356
  # Include None in the Union and maintain the discriminator
368
357
  registered_classes = list(cls.TYPE_REGISTRY.get(resource_type, {}).values())
369
358
  if not registered_classes:
370
- # Use PlaceholderPlugin as a placeholder if no subclasses are registered
371
- registered_classes = [PlaceholderPlugin]
372
- union_with_none = Union[tuple(registered_classes + [type(None)])]
373
- new_type = Annotated[union_with_none, Field(discriminator="type")]
359
+ # Use Any as a placeholder if no subclasses are registered
360
+ union_type = Any
361
+ else:
362
+ union_type = Union[tuple(registered_classes)]
363
+ union_with_none = Union[tuple([union_type, type(None)])]
364
+ new_type = Annotated[
365
+ union_with_none,
366
+ Field(discriminator="type")
367
+ ]
374
368
 
375
369
  return new_type
376
370
 
@@ -417,44 +411,4 @@ class ComponentBase(BaseModel):
417
411
  else:
418
412
  raise ValueError(f"Field '{field_name}' does not exist in model '{model_class.__name__}'")
419
413
  model_class.model_rebuild(force=True)
420
- logger.info("All models have been successfully recreated.")
421
-
422
- @classmethod
423
- def recreate_models_for_resource(cls, resource_type: Type[T]):
424
- """
425
- Recreate only the models associated with the given resource type.
426
- """
427
- with cls._lock:
428
- models_with_fields = {}
429
- for model_cls, res_types in cls.MODEL_REGISTRY.items():
430
- if resource_type in res_types:
431
- models_with_fields[model_cls] = {}
432
- for field_name, field in model_cls.__fields__.items():
433
- field_annotation = model_cls.__annotations__.get(field_name)
434
- if not field_annotation:
435
- continue
436
-
437
- # Check if SubclassUnion is used in the field type
438
- if not cls.field_contains_subclass_union(field_annotation):
439
- continue # Only process fields that use SubclassUnion
440
-
441
- # Determine the new type based on the annotation and resource_type
442
- new_type = cls.determine_new_type(field_annotation, resource_type)
443
-
444
- models_with_fields[model_cls][field_name] = new_type
445
-
446
- for model_class, fields in models_with_fields.items():
447
- for field_name, new_type in fields.items():
448
- if field_name in model_class.model_fields:
449
- model_class.model_fields[field_name].annotation = new_type
450
- else:
451
- raise ValueError(f"Field '{field_name}' does not exist in model '{model_class.__name__}'")
452
- model_class.model_rebuild(force=True)
453
- logger.info(f"Models associated with resource '{resource_type.__name__}' have been successfully recreated.")
454
-
455
-
456
- class PlaceholderPlugin(ComponentBase):
457
- """
458
- Placeholder base class for plugins when no subclasses are registered.
459
- """
460
- pass
414
+ logger.info("All models have been successfully recreated.")