swarmauri-core 0.5.2__tar.gz → 0.6.0.dev4__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 (121) hide show
  1. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/PKG-INFO +2 -3
  2. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/pyproject.toml +7 -5
  3. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/ComponentBase.py +74 -11
  4. swarmauri_core-0.6.0.dev4/swarmauri_core/control_panels/IControlPanel.py +57 -0
  5. swarmauri_core-0.6.0.dev4/swarmauri_core/dataconnectors/IDataConnector.py +70 -0
  6. swarmauri_core-0.6.0.dev4/swarmauri_core/factories/IFactory.py +18 -0
  7. swarmauri_core-0.6.0.dev4/swarmauri_core/image_gens/IGenImage.py +35 -0
  8. swarmauri_core-0.6.0.dev4/swarmauri_core/pipelines/IPipeline.py +57 -0
  9. swarmauri_core-0.6.0.dev4/swarmauri_core/service_registries/IServiceRegistry.py +43 -0
  10. swarmauri_core-0.6.0.dev4/swarmauri_core/state/IState.py +28 -0
  11. swarmauri_core-0.6.0.dev4/swarmauri_core/swarms/ISwarm.py +32 -0
  12. swarmauri_core-0.6.0.dev4/swarmauri_core/task_mgt_strategies/ITaskMgtStrategy.py +43 -0
  13. swarmauri_core-0.6.0.dev4/swarmauri_core/toolkits/__init__.py +0 -0
  14. swarmauri_core-0.6.0.dev4/swarmauri_core/tools/__init__.py +0 -0
  15. swarmauri_core-0.6.0.dev4/swarmauri_core/tracing/__init__.py +0 -0
  16. swarmauri_core-0.6.0.dev4/swarmauri_core/transports/ITransport.py +29 -0
  17. swarmauri_core-0.6.0.dev4/swarmauri_core/transports/__init__.py +0 -0
  18. swarmauri_core-0.6.0.dev4/swarmauri_core/utils/__init__.py +0 -0
  19. swarmauri_core-0.6.0.dev4/swarmauri_core/vcms/__init__.py +0 -0
  20. swarmauri_core-0.6.0.dev4/swarmauri_core/vector_stores/__init__.py +0 -0
  21. swarmauri_core-0.6.0.dev4/swarmauri_core/vectors/__init__.py +0 -0
  22. swarmauri_core-0.5.2/swarmauri_core/agent_factories/IAgentFactory.py +0 -79
  23. swarmauri_core-0.5.2/swarmauri_core/swarms/ISwarm.py +0 -67
  24. swarmauri_core-0.5.2/swarmauri_core/swarms/ISwarmAgentRegistration.py +0 -73
  25. swarmauri_core-0.5.2/swarmauri_core/swarms/ISwarmChainCRUD.py +0 -62
  26. swarmauri_core-0.5.2/swarmauri_core/swarms/ISwarmComponent.py +0 -13
  27. swarmauri_core-0.5.2/swarmauri_core/swarms/ISwarmConfigurationExporter.py +0 -33
  28. swarmauri_core-0.5.2/swarmauri_core/swarms/ISwarmFactory.py +0 -120
  29. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/README.md +0 -0
  30. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/README.md +0 -0
  31. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/__init__.py +0 -0
  32. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agent_apis/IAgentCommands.py +0 -0
  33. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agent_apis/IAgentRouterCRUD.py +0 -0
  34. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agent_apis/__init__.py +0 -0
  35. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agent_factories/IExportConf.py +0 -0
  36. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agent_factories/__init__.py +0 -0
  37. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agents/IAgent.py +0 -0
  38. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agents/IAgentConversation.py +0 -0
  39. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agents/IAgentParser.py +0 -0
  40. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agents/IAgentRetrieve.py +0 -0
  41. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agents/IAgentSystemContext.py +0 -0
  42. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agents/IAgentToolkit.py +0 -0
  43. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agents/IAgentVectorStore.py +0 -0
  44. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/agents/__init__.py +0 -0
  45. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chains/ICallableChain.py +0 -0
  46. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chains/IChain.py +0 -0
  47. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chains/IChainContext.py +0 -0
  48. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chains/IChainContextLoader.py +0 -0
  49. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chains/IChainDependencyResolver.py +0 -0
  50. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chains/IChainFactory.py +0 -0
  51. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chains/IChainStep.py +0 -0
  52. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chains/__init__.py +0 -0
  53. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chunkers/IChunker.py +0 -0
  54. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/chunkers/__init__.py +0 -0
  55. {swarmauri_core-0.5.2/swarmauri_core/conversations → swarmauri_core-0.6.0.dev4/swarmauri_core/control_panels}/__init__.py +0 -0
  56. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/conversations/IConversation.py +0 -0
  57. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/conversations/IMaxSize.py +0 -0
  58. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/conversations/ISystemContext.py +0 -0
  59. {swarmauri_core-0.5.2/swarmauri_core/distances → swarmauri_core-0.6.0.dev4/swarmauri_core/conversations}/__init__.py +0 -0
  60. {swarmauri_core-0.5.2/swarmauri_core/document_stores → swarmauri_core-0.6.0.dev4/swarmauri_core/dataconnectors}/__init__.py +0 -0
  61. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/distances/IDistanceSimilarity.py +0 -0
  62. {swarmauri_core-0.5.2/swarmauri_core/documents → swarmauri_core-0.6.0.dev4/swarmauri_core/distances}/__init__.py +0 -0
  63. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/document_stores/IDocumentRetrieve.py +0 -0
  64. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/document_stores/IDocumentStore.py +0 -0
  65. {swarmauri_core-0.5.2/swarmauri_core/llms → swarmauri_core-0.6.0.dev4/swarmauri_core/document_stores}/__init__.py +0 -0
  66. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/documents/IDocument.py +0 -0
  67. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/documents/IExperimentDocument.py +0 -0
  68. {swarmauri_core-0.5.2/swarmauri_core/measurements → swarmauri_core-0.6.0.dev4/swarmauri_core/documents}/__init__.py +0 -0
  69. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/embeddings/IFeature.py +0 -0
  70. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/embeddings/ISaveModel.py +0 -0
  71. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/embeddings/IVectorize.py +0 -0
  72. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/embeddings/__init__.py +0 -0
  73. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/experiment_stores/IExperimentStore.py +0 -0
  74. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/experiment_stores/__init__.py +0 -0
  75. {swarmauri_core-0.5.2/swarmauri_core/parsers → swarmauri_core-0.6.0.dev4/swarmauri_core/factories}/__init__.py +0 -0
  76. {swarmauri_core-0.5.2/swarmauri_core/prompts → swarmauri_core-0.6.0.dev4/swarmauri_core/image_gens}/__init__.py +0 -0
  77. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/llms/IFit.py +0 -0
  78. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/llms/IPredict.py +0 -0
  79. {swarmauri_core-0.5.2/swarmauri_core/schema_converters → swarmauri_core-0.6.0.dev4/swarmauri_core/llms}/__init__.py +0 -0
  80. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/measurements/IMeasurement.py +0 -0
  81. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/measurements/IMeasurementAggregate.py +0 -0
  82. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/measurements/IMeasurementCalculate.py +0 -0
  83. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/measurements/IThreshold.py +0 -0
  84. {swarmauri_core-0.5.2/swarmauri_core/swarm_apis → swarmauri_core-0.6.0.dev4/swarmauri_core/measurements}/__init__.py +0 -0
  85. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/messages/IMessage.py +0 -0
  86. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/messages/__init__.py +0 -0
  87. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/parsers/IParser.py +0 -0
  88. {swarmauri_core-0.5.2/swarmauri_core/swarms → swarmauri_core-0.6.0.dev4/swarmauri_core/parsers}/__init__.py +0 -0
  89. {swarmauri_core-0.5.2/swarmauri_core/toolkits → swarmauri_core-0.6.0.dev4/swarmauri_core/pipelines}/__init__.py +0 -0
  90. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/prompts/IPrompt.py +0 -0
  91. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/prompts/IPromptMatrix.py +0 -0
  92. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/prompts/ITemplate.py +0 -0
  93. {swarmauri_core-0.5.2/swarmauri_core/tools → swarmauri_core-0.6.0.dev4/swarmauri_core/prompts}/__init__.py +0 -0
  94. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/schema_converters/ISchemaConvert.py +0 -0
  95. {swarmauri_core-0.5.2/swarmauri_core/tracing → swarmauri_core-0.6.0.dev4/swarmauri_core/schema_converters}/__init__.py +0 -0
  96. {swarmauri_core-0.5.2/swarmauri_core/utils → swarmauri_core-0.6.0.dev4/swarmauri_core/service_registries}/__init__.py +0 -0
  97. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/swarm_apis/IAgentRegistrationAPI.py +0 -0
  98. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/swarm_apis/ISwarmAPI.py +0 -0
  99. {swarmauri_core-0.5.2/swarmauri_core/vcms → swarmauri_core-0.6.0.dev4/swarmauri_core/swarm_apis}/__init__.py +0 -0
  100. {swarmauri_core-0.5.2/swarmauri_core/vector_stores → swarmauri_core-0.6.0.dev4/swarmauri_core/swarms}/__init__.py +0 -0
  101. {swarmauri_core-0.5.2/swarmauri_core/vectors → swarmauri_core-0.6.0.dev4/swarmauri_core/task_mgt_strategies}/__init__.py +0 -0
  102. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/toolkits/IToolkit.py +0 -0
  103. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/tools/IParameter.py +0 -0
  104. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/tools/ITool.py +0 -0
  105. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/tracing/IChainTracer.py +0 -0
  106. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/tracing/ITraceContext.py +0 -0
  107. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/tracing/ITracer.py +0 -0
  108. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/typing.py +0 -0
  109. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/utils/ITransactional.py +0 -0
  110. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vcms/IPredictVision.py +0 -0
  111. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vector_stores/ICloudVectorStore.py +0 -0
  112. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vector_stores/IPersistentVectorStore.py +0 -0
  113. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vector_stores/ISimilarity.py +0 -0
  114. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vector_stores/IVectorNorm.py +0 -0
  115. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vector_stores/IVectorStore.py +0 -0
  116. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vector_stores/IVectorStoreRetrieve.py +0 -0
  117. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vector_stores/IVectorStoreSaveLoad.py +0 -0
  118. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vectors/IVector.py +0 -0
  119. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vectors/IVectorMeta.py +0 -0
  120. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vectors/IVectorProduct.py +0 -0
  121. {swarmauri_core-0.5.2 → swarmauri_core-0.6.0.dev4}/swarmauri_core/vectors/IVectorTransform.py +0 -0
@@ -1,18 +1,17 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: swarmauri-core
3
- Version: 0.5.2
3
+ Version: 0.6.0.dev4
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
7
7
  Author: Jacob Stewart
8
8
  Author-email: jacob@swarmauri.com
9
- Requires-Python: >=3.10,<4.0
9
+ Requires-Python: >=3.10,<3.13
10
10
  Classifier: License :: OSI Approved :: Apache Software License
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
15
  Requires-Dist: pydantic (>=2.0,<3.0)
17
16
  Project-URL: Repository, http://github.com/swarmauri/swarmauri-sdk
18
17
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "swarmauri-core"
3
- version = "0.5.2"
3
+ version = "0.6.0.dev4"
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"
@@ -14,17 +14,19 @@ classifiers = [
14
14
  ]
15
15
 
16
16
  [tool.poetry.dependencies]
17
- python = ">=3.10,<4.0"
17
+ python = ">=3.10,<3.13"
18
+ pydantic = "^2.0"
19
+
18
20
  #numpy = "==1.26.4"
19
21
  #requests = "^2.0"
20
- pydantic = "^2.0"
21
22
  #pandas = ">2.2"
22
23
 
23
24
  [tool.poetry.dev-dependencies]
24
- flake8 = "^7.0" # Add flake8 as a development dependency
25
- pytest = "^8.0" # Ensure pytest is also added if you run tests
25
+ flake8 = "^7.0"
26
+ pytest = "^8.0"
26
27
  pytest-asyncio = ">=0.24.0"
27
28
  pytest-xdist = "^3.6.1"
29
+ pytest-json-report = "^1.5.0"
28
30
 
29
31
  [build-system]
30
32
  requires = ["poetry-core>=1.0.0"]
@@ -1,12 +1,13 @@
1
+ import json
1
2
  from typing import (
3
+ Any,
4
+ Dict,
2
5
  Optional,
3
6
  List,
4
7
  Literal,
5
8
  TypeVar,
6
9
  Type,
7
10
  Union,
8
- Annotated,
9
- Generic,
10
11
  ClassVar,
11
12
  Set,
12
13
  get_args,
@@ -16,11 +17,14 @@ from uuid import uuid4
16
17
  from enum import Enum
17
18
  import inspect
18
19
  import hashlib
19
- from pydantic import BaseModel, Field, field_validator
20
+ from pydantic import BaseModel, Field, ValidationError, field_validator
20
21
  import logging
21
22
  from swarmauri_core.typing import SubclassUnion
22
23
 
23
24
 
25
+ T = TypeVar("T", bound="ComponentBase")
26
+
27
+
24
28
  class ResourceTypes(Enum):
25
29
  UNIVERSAL_BASE = "ComponentBase"
26
30
  AGENT = "Agent"
@@ -34,6 +38,7 @@ class ResourceTypes(Enum):
34
38
  DOCUMENT = "Document"
35
39
  EMBEDDING = "Embedding"
36
40
  EXCEPTION = "Exception"
41
+ IMAGE_GEN = "ImageGen"
37
42
  LLM = "LLM"
38
43
  MESSAGE = "Message"
39
44
  MEASUREMENT = "Measurement"
@@ -51,12 +56,17 @@ class ResourceTypes(Enum):
51
56
  VECTOR_STORE = "VectorStore"
52
57
  VECTOR = "Vector"
53
58
  VCM = "VCM"
54
-
59
+ DATA_CONNECTOR = "DataConnector"
60
+ TRANSPORT = "Transport"
61
+ FACTORY = "Factory"
62
+ PIPELINE = "Pipeline"
63
+ SERVICE_REGISTRY = "ServiceRegistry"
64
+ CONTROL_PANEL = "ControlPanel"
65
+ TASK_MGT_STRATEGY = "TaskMgtStrategy"
55
66
 
56
67
  def generate_id() -> str:
57
68
  return str(uuid4())
58
69
 
59
-
60
70
  class ComponentBase(BaseModel):
61
71
  name: Optional[str] = None
62
72
  id: str = Field(default_factory=generate_id)
@@ -87,9 +97,6 @@ class ComponentBase(BaseModel):
87
97
  f"Subclass {subclass.__name__} does not have a type annotation"
88
98
  )
89
99
 
90
- # [subclass.__swm_reset_class__() for subclass in cls.__swm_subclasses__
91
- # if hasattr(subclass, '__swm_reset_class__')]
92
-
93
100
  @classmethod
94
101
  def __swm_reset_class__(cls):
95
102
  logging.debug("__swm_reset_class__ executed\n")
@@ -122,9 +129,6 @@ class ComponentBase(BaseModel):
122
129
  cls.__annotations__[each] = sc
123
130
  cls.__fields__[each].annotation = sc
124
131
 
125
- # This is not necessary as the model_rebuild address forward_refs
126
- # https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_post_init
127
- # cls.update_forward_refs()
128
132
  cls.model_rebuild(force=True)
129
133
 
130
134
  @field_validator("type")
@@ -178,3 +182,62 @@ class ComponentBase(BaseModel):
178
182
  @property
179
183
  def swm_isremote(self):
180
184
  return bool(self.host)
185
+
186
+ @classmethod
187
+ def model_validate_json(
188
+ cls: Type[T], json_payload: Union[str, Dict[str, Any]], strict: bool = False
189
+ ) -> T:
190
+ # Ensure we're working with a dictionary
191
+ if isinstance(json_payload, str):
192
+ try:
193
+ payload_dict = json.loads(json_payload)
194
+ except json.JSONDecodeError:
195
+ raise ValueError("Invalid JSON payload")
196
+ else:
197
+ payload_dict = json_payload
198
+
199
+ # Try to determine the specific component type
200
+ component_type = payload_dict.get("type", "ComponentBase")
201
+
202
+ # Attempt to find the correct subclass
203
+ target_cls = cls.get_subclass_by_type(component_type)
204
+
205
+ # Fallback logic
206
+ if target_cls is None:
207
+ if strict:
208
+ raise ValueError(f"Cannot resolve component type: {component_type}")
209
+ target_cls = cls
210
+ logging.warning(
211
+ f"Falling back to base ComponentBase for type: {component_type}"
212
+ )
213
+
214
+ # Validate using the determined class
215
+ try:
216
+ return target_cls.model_validate(payload_dict)
217
+ except ValidationError as e:
218
+ logging.error(f"Validation failed for {component_type}: {e}")
219
+ raise
220
+
221
+ @classmethod
222
+ def get_subclass_by_type(cls, type_name: str) -> Optional[Type["ComponentBase"]]:
223
+ # First, check for exact match in registered subclasses
224
+ for subclass in cls.__swm_subclasses__:
225
+ if (
226
+ subclass.__name__ == type_name
227
+ or getattr(subclass, "type", None) == type_name
228
+ ):
229
+ return subclass
230
+
231
+ # If no exact match, try case-insensitive search
232
+ for subclass in cls.__swm_subclasses__:
233
+ if (
234
+ subclass.__name__.lower() == type_name.lower()
235
+ or str(getattr(subclass, "type", "")).lower() == type_name.lower()
236
+ ):
237
+ return subclass
238
+
239
+ return None
240
+
241
+ @classmethod
242
+ def from_dict(cls, data: Dict[str, Any]) -> "ComponentBase":
243
+ return cls.model_validate(data)
@@ -0,0 +1,57 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, List
3
+
4
+
5
+ class IControlPlane(ABC):
6
+ """
7
+ Abstract base class for ControlPlane.
8
+ """
9
+
10
+ @abstractmethod
11
+ def create_agent(self, name: str, role: str) -> Any:
12
+ """
13
+ Create an agent with the given name and role.
14
+ """
15
+ pass
16
+
17
+ @abstractmethod
18
+ def remove_agent(self, name: str) -> None:
19
+ """
20
+ Remove the agent with the specified name.
21
+ """
22
+ pass
23
+
24
+ @abstractmethod
25
+ def list_active_agents(self) -> List[str]:
26
+ """
27
+ List all active agent names.
28
+ """
29
+ pass
30
+
31
+ @abstractmethod
32
+ def submit_tasks(self, tasks: List[Any]) -> None:
33
+ """
34
+ Submit one or more tasks to the task management strategy for processing.
35
+ """
36
+ pass
37
+
38
+ @abstractmethod
39
+ def process_tasks(self) -> None:
40
+ """
41
+ Process and assign tasks from the queue, then transport them to their assigned services.
42
+ """
43
+ pass
44
+
45
+ @abstractmethod
46
+ def distribute_tasks(self, task: Any) -> None:
47
+ """
48
+ Distribute tasks using the task strategy.
49
+ """
50
+ pass
51
+
52
+ @abstractmethod
53
+ def orchestrate_agents(self, task: Any) -> None:
54
+ """
55
+ Orchestrate agents for task distribution.
56
+ """
57
+ pass
@@ -0,0 +1,70 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+
4
+ class IDataConnector(ABC):
5
+ """
6
+ Abstract base class for data connectors.
7
+ Defines the interface for all concrete data connector implementations.
8
+ """
9
+
10
+ @abstractmethod
11
+ def authenticate(self, **kwargs):
12
+ """
13
+ Authenticate with the data source.
14
+ This method should handle any required authentication process.
15
+
16
+ :param kwargs: Authentication parameters such as API keys, tokens, etc.
17
+ """
18
+ pass
19
+
20
+ @abstractmethod
21
+ def fetch_data(self, query: str, **kwargs):
22
+ """
23
+ Fetch data from the data source based on a query.
24
+
25
+ :param query: Query string or parameters to fetch specific data.
26
+ :param kwargs: Additional parameters for fetching data.
27
+ :return: Data fetched from the source.
28
+ """
29
+ pass
30
+
31
+ @abstractmethod
32
+ def insert_data(self, data, **kwargs):
33
+ """
34
+ Insert data into the data source.
35
+
36
+ :param data: Data to be inserted.
37
+ :param kwargs: Additional parameters for inserting data.
38
+ """
39
+ pass
40
+
41
+ @abstractmethod
42
+ def update_data(self, identifier, data, **kwargs):
43
+ """
44
+ Update existing data in the data source.
45
+
46
+ :param identifier: Unique identifier of the data to update.
47
+ :param data: Updated data.
48
+ :param kwargs: Additional parameters for updating data.
49
+ """
50
+ pass
51
+
52
+ @abstractmethod
53
+ def delete_data(self, identifier, **kwargs):
54
+ """
55
+ Delete data from the data source.
56
+
57
+ :param identifier: Unique identifier of the data to delete.
58
+ :param kwargs: Additional parameters for deleting data.
59
+ """
60
+ pass
61
+
62
+ @abstractmethod
63
+ def test_connection(self, **kwargs):
64
+ """
65
+ Test the connection to the data source.
66
+
67
+ :param kwargs: Connection parameters.
68
+ :return: Boolean indicating whether the connection is successful.
69
+ """
70
+ pass
@@ -0,0 +1,18 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Callable
3
+
4
+
5
+ class IFactory(ABC):
6
+ """
7
+ Interface defining core methods for factories.
8
+ """
9
+
10
+ @abstractmethod
11
+ def create(self, type: str, *args: Any, **kwargs: Any) -> Any:
12
+ """Create and return an instance."""
13
+ pass
14
+
15
+ @abstractmethod
16
+ def register(self, type: str, resource_class: Callable) -> None:
17
+ """Register a class with the factory."""
18
+ pass
@@ -0,0 +1,35 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+
4
+ class IGenImage(ABC):
5
+ """
6
+ Interface focusing on the basic properties and settings essential for defining image generating models.
7
+ """
8
+
9
+ @abstractmethod
10
+ def generate_image(self, *args, **kwargs) -> any:
11
+ """
12
+ Generate images based on the input data provided to the model.
13
+ """
14
+ pass
15
+
16
+ @abstractmethod
17
+ async def agenerate_image(self, *args, **kwargs) -> any:
18
+ """
19
+ Generate images based on the input data provided to the model.
20
+ """
21
+ pass
22
+
23
+ @abstractmethod
24
+ def batch_generate(self, *args, **kwargs) -> any:
25
+ """
26
+ Generate images based on the input data provided to the model.
27
+ """
28
+ pass
29
+
30
+ @abstractmethod
31
+ async def abatch_generate(self, *args, **kwargs) -> any:
32
+ """
33
+ Generate images based on the input data provided to the model.
34
+ """
35
+ pass
@@ -0,0 +1,57 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Callable, List
3
+ from enum import Enum
4
+
5
+
6
+ class PipelineStatus(Enum):
7
+ """
8
+ Enum representing the status of a pipeline execution.
9
+ """
10
+
11
+ PENDING = "pending"
12
+ RUNNING = "running"
13
+ COMPLETED = "completed"
14
+ FAILED = "failed"
15
+ STOPPED = "stopped"
16
+
17
+
18
+ class IPipeline(ABC):
19
+ """
20
+ Interface defining core methods for pipeline execution and management.
21
+ """
22
+
23
+ @abstractmethod
24
+ def add_task(self, task: Callable, *args: Any, **kwargs: Any) -> None:
25
+ """
26
+ Add a task to the pipeline.
27
+
28
+ :param task: Callable task to be executed
29
+ :param args: Positional arguments for the task
30
+ :param kwargs: Keyword arguments for the task
31
+ """
32
+ pass
33
+
34
+ @abstractmethod
35
+ def execute(self, *args: Any, **kwargs: Any) -> List[Any]:
36
+ """
37
+ Execute the entire pipeline.
38
+
39
+ :return: List of results from pipeline execution
40
+ """
41
+ pass
42
+
43
+ @abstractmethod
44
+ def get_status(self) -> PipelineStatus:
45
+ """
46
+ Get the current status of the pipeline.
47
+
48
+ :return: Current pipeline status
49
+ """
50
+ pass
51
+
52
+ @abstractmethod
53
+ def reset(self) -> None:
54
+ """
55
+ Reset the pipeline to its initial state.
56
+ """
57
+ pass
@@ -0,0 +1,43 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Dict, Any, List, Optional
3
+
4
+
5
+ class IServiceRegistry(ABC):
6
+ """
7
+ Abstract base class for service registries.
8
+ """
9
+
10
+ @abstractmethod
11
+ def register_service(self, name: str, details: Dict[str, Any]) -> None:
12
+ """
13
+ Register a new service with the given name and details.
14
+ """
15
+ pass
16
+
17
+ @abstractmethod
18
+ def get_service(self, name: str) -> Optional[Dict[str, Any]]:
19
+ """
20
+ Retrieve a service by its name.
21
+ """
22
+ pass
23
+
24
+ @abstractmethod
25
+ def get_services_by_roles(self, roles: List[str]) -> List[str]:
26
+ """
27
+ Get services filtered by their roles.
28
+ """
29
+ pass
30
+
31
+ @abstractmethod
32
+ def unregister_service(self, name: str) -> None:
33
+ """
34
+ unregister the service with the given name.
35
+ """
36
+ pass
37
+
38
+ @abstractmethod
39
+ def update_service(self, name: str, details: Dict[str, Any]) -> None:
40
+ """
41
+ Update the details of the service with the given name.
42
+ """
43
+ pass
@@ -0,0 +1,28 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Dict, Any
3
+
4
+
5
+ class IState(ABC):
6
+ @abstractmethod
7
+ def read(self) -> Dict[str, Any]:
8
+ """
9
+ Reads and returns the current state as a dictionary.
10
+ """
11
+
12
+ @abstractmethod
13
+ def write(self, data: Dict[str, Any]) -> None:
14
+ """
15
+ Replaces the current state with the given data.
16
+ """
17
+
18
+ @abstractmethod
19
+ def update(self, data: Dict[str, Any]) -> None:
20
+ """
21
+ Updates the state with the given data.
22
+ """
23
+
24
+ @abstractmethod
25
+ def reset(self) -> None:
26
+ """
27
+ Resets the state to its initial state.
28
+ """
@@ -0,0 +1,32 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Dict, List, Optional, Union
3
+
4
+
5
+ class ISwarm(ABC):
6
+ """Abstract base class for swarm implementations"""
7
+
8
+ @abstractmethod
9
+ async def exec(
10
+ self,
11
+ input_data: Union[str, List[str]],
12
+ **kwargs: Dict[str, Any],
13
+ ) -> Any:
14
+ """Execute swarm tasks with given input"""
15
+ pass
16
+
17
+ @abstractmethod
18
+ def get_swarm_status(self) -> Dict[int, Any]:
19
+ """Get status of all agents in the swarm"""
20
+ pass
21
+
22
+ @property
23
+ @abstractmethod
24
+ def agents(self) -> List[Any]:
25
+ """Get list of agents in the swarm"""
26
+ pass
27
+
28
+ @property
29
+ @abstractmethod
30
+ def queue_size(self) -> int:
31
+ """Get size of task queue"""
32
+ pass
@@ -0,0 +1,43 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Callable, Dict
3
+
4
+
5
+ class ITaskMgtStrategy(ABC):
6
+ """Abstract base class for TaskStrategy."""
7
+
8
+ @abstractmethod
9
+ def assign_task(
10
+ self, task: Dict[str, Any], agent_factory: Callable, service_registry: Callable
11
+ ) -> str:
12
+ """
13
+ Abstract method to assign a task to a service.
14
+ """
15
+ pass
16
+
17
+ @abstractmethod
18
+ def add_task(self, task: Dict[str, Any]) -> None:
19
+ """
20
+ Abstract method to add a task to the task queue.
21
+ """
22
+ pass
23
+
24
+ @abstractmethod
25
+ def remove_task(self, task_id: str) -> None:
26
+ """
27
+ Abstract method to remove a task from the task queue.
28
+ """
29
+ pass
30
+
31
+ @abstractmethod
32
+ def get_task(self, task_id: str) -> Dict[str, Any]:
33
+ """
34
+ Abstract method to get a task from the task queue.
35
+ """
36
+ pass
37
+
38
+ @abstractmethod
39
+ def process_tasks(self, task: Dict[str, Any]) -> None:
40
+ """
41
+ Abstract method to process a task.
42
+ """
43
+ pass
@@ -0,0 +1,29 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, List
3
+
4
+
5
+ class ITransport(ABC):
6
+ """
7
+ Interface defining standard transportation methods for agent interactions
8
+ """
9
+
10
+ @abstractmethod
11
+ def send(self, sender: str, recipient: str, message: Any) -> None:
12
+ """
13
+ Send a message to a specific recipient
14
+ """
15
+ pass
16
+
17
+ @abstractmethod
18
+ def broadcast(self, sender: str, message: Any) -> None:
19
+ """
20
+ Broadcast a message to all agents
21
+ """
22
+ pass
23
+
24
+ @abstractmethod
25
+ def multicast(self, sender: str, recipients: List[str], message: Any) -> None:
26
+ """
27
+ Send a message to multiple specific recipients
28
+ """
29
+ pass