swarmauri-core 0.5.3.dev3__tar.gz → 0.6.0.dev1__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 (122) hide show
  1. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/PKG-INFO +2 -3
  2. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/pyproject.toml +7 -5
  3. swarmauri_core-0.6.0.dev1/swarmauri_core/ComponentBase.py +427 -0
  4. swarmauri_core-0.6.0.dev1/swarmauri_core/control_panels/IControlPanel.py +57 -0
  5. swarmauri_core-0.6.0.dev1/swarmauri_core/dataconnectors/IDataConnector.py +70 -0
  6. swarmauri_core-0.6.0.dev1/swarmauri_core/factories/IFactory.py +18 -0
  7. swarmauri_core-0.6.0.dev1/swarmauri_core/pipelines/IPipeline.py +57 -0
  8. swarmauri_core-0.6.0.dev1/swarmauri_core/service_registries/IServiceRegistry.py +43 -0
  9. swarmauri_core-0.6.0.dev1/swarmauri_core/state/IState.py +28 -0
  10. swarmauri_core-0.6.0.dev1/swarmauri_core/swarms/ISwarm.py +32 -0
  11. swarmauri_core-0.6.0.dev1/swarmauri_core/task_mgmt_strategies/ITaskMgmtStrategy.py +43 -0
  12. swarmauri_core-0.6.0.dev1/swarmauri_core/tools/__init__.py +0 -0
  13. swarmauri_core-0.6.0.dev1/swarmauri_core/tracing/__init__.py +0 -0
  14. swarmauri_core-0.6.0.dev1/swarmauri_core/transports/ITransport.py +29 -0
  15. swarmauri_core-0.6.0.dev1/swarmauri_core/transports/__init__.py +0 -0
  16. swarmauri_core-0.6.0.dev1/swarmauri_core/utils/__init__.py +0 -0
  17. swarmauri_core-0.6.0.dev1/swarmauri_core/vcms/__init__.py +0 -0
  18. swarmauri_core-0.6.0.dev1/swarmauri_core/vector_stores/__init__.py +0 -0
  19. swarmauri_core-0.6.0.dev1/swarmauri_core/vectors/__init__.py +0 -0
  20. swarmauri_core-0.5.3.dev3/swarmauri_core/ComponentBase.py +0 -181
  21. swarmauri_core-0.5.3.dev3/swarmauri_core/agent_factories/IAgentFactory.py +0 -79
  22. swarmauri_core-0.5.3.dev3/swarmauri_core/swarms/ISwarm.py +0 -67
  23. swarmauri_core-0.5.3.dev3/swarmauri_core/swarms/ISwarmAgentRegistration.py +0 -73
  24. swarmauri_core-0.5.3.dev3/swarmauri_core/swarms/ISwarmChainCRUD.py +0 -62
  25. swarmauri_core-0.5.3.dev3/swarmauri_core/swarms/ISwarmComponent.py +0 -13
  26. swarmauri_core-0.5.3.dev3/swarmauri_core/swarms/ISwarmConfigurationExporter.py +0 -33
  27. swarmauri_core-0.5.3.dev3/swarmauri_core/swarms/ISwarmFactory.py +0 -120
  28. swarmauri_core-0.5.3.dev3/swarmauri_core/typing.py +0 -50
  29. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/README.md +0 -0
  30. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/README.md +0 -0
  31. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/__init__.py +0 -0
  32. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agent_apis/IAgentCommands.py +0 -0
  33. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agent_apis/IAgentRouterCRUD.py +0 -0
  34. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agent_apis/__init__.py +0 -0
  35. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agent_factories/IExportConf.py +0 -0
  36. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agent_factories/__init__.py +0 -0
  37. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agents/IAgent.py +0 -0
  38. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agents/IAgentConversation.py +0 -0
  39. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agents/IAgentParser.py +0 -0
  40. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agents/IAgentRetrieve.py +0 -0
  41. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agents/IAgentSystemContext.py +0 -0
  42. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agents/IAgentToolkit.py +0 -0
  43. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agents/IAgentVectorStore.py +0 -0
  44. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/agents/__init__.py +0 -0
  45. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chains/ICallableChain.py +0 -0
  46. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chains/IChain.py +0 -0
  47. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chains/IChainContext.py +0 -0
  48. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chains/IChainContextLoader.py +0 -0
  49. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chains/IChainDependencyResolver.py +0 -0
  50. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chains/IChainFactory.py +0 -0
  51. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chains/IChainStep.py +0 -0
  52. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chains/__init__.py +0 -0
  53. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chunkers/IChunker.py +0 -0
  54. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/chunkers/__init__.py +0 -0
  55. {swarmauri_core-0.5.3.dev3/swarmauri_core/conversations → swarmauri_core-0.6.0.dev1/swarmauri_core/control_panels}/__init__.py +0 -0
  56. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/conversations/IConversation.py +0 -0
  57. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/conversations/IMaxSize.py +0 -0
  58. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/conversations/ISystemContext.py +0 -0
  59. {swarmauri_core-0.5.3.dev3/swarmauri_core/distances → swarmauri_core-0.6.0.dev1/swarmauri_core/conversations}/__init__.py +0 -0
  60. {swarmauri_core-0.5.3.dev3/swarmauri_core/document_stores → swarmauri_core-0.6.0.dev1/swarmauri_core/dataconnectors}/__init__.py +0 -0
  61. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/distances/IDistanceSimilarity.py +0 -0
  62. {swarmauri_core-0.5.3.dev3/swarmauri_core/documents → swarmauri_core-0.6.0.dev1/swarmauri_core/distances}/__init__.py +0 -0
  63. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/document_stores/IDocumentRetrieve.py +0 -0
  64. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/document_stores/IDocumentStore.py +0 -0
  65. {swarmauri_core-0.5.3.dev3/swarmauri_core/image_gens → swarmauri_core-0.6.0.dev1/swarmauri_core/document_stores}/__init__.py +0 -0
  66. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/documents/IDocument.py +0 -0
  67. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/documents/IExperimentDocument.py +0 -0
  68. {swarmauri_core-0.5.3.dev3/swarmauri_core/llms → swarmauri_core-0.6.0.dev1/swarmauri_core/documents}/__init__.py +0 -0
  69. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/embeddings/IFeature.py +0 -0
  70. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/embeddings/ISaveModel.py +0 -0
  71. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/embeddings/IVectorize.py +0 -0
  72. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/embeddings/__init__.py +0 -0
  73. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/experiment_stores/IExperimentStore.py +0 -0
  74. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/experiment_stores/__init__.py +0 -0
  75. {swarmauri_core-0.5.3.dev3/swarmauri_core/measurements → swarmauri_core-0.6.0.dev1/swarmauri_core/factories}/__init__.py +0 -0
  76. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/image_gens/IGenImage.py +0 -0
  77. {swarmauri_core-0.5.3.dev3/swarmauri_core/parsers → swarmauri_core-0.6.0.dev1/swarmauri_core/image_gens}/__init__.py +0 -0
  78. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/llms/IFit.py +0 -0
  79. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/llms/IPredict.py +0 -0
  80. {swarmauri_core-0.5.3.dev3/swarmauri_core/prompts → swarmauri_core-0.6.0.dev1/swarmauri_core/llms}/__init__.py +0 -0
  81. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/measurements/IMeasurement.py +0 -0
  82. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/measurements/IMeasurementAggregate.py +0 -0
  83. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/measurements/IMeasurementCalculate.py +0 -0
  84. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/measurements/IThreshold.py +0 -0
  85. {swarmauri_core-0.5.3.dev3/swarmauri_core/schema_converters → swarmauri_core-0.6.0.dev1/swarmauri_core/measurements}/__init__.py +0 -0
  86. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/messages/IMessage.py +0 -0
  87. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/messages/__init__.py +0 -0
  88. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/parsers/IParser.py +0 -0
  89. {swarmauri_core-0.5.3.dev3/swarmauri_core/swarm_apis → swarmauri_core-0.6.0.dev1/swarmauri_core/parsers}/__init__.py +0 -0
  90. {swarmauri_core-0.5.3.dev3/swarmauri_core/swarms → swarmauri_core-0.6.0.dev1/swarmauri_core/pipelines}/__init__.py +0 -0
  91. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/prompts/IPrompt.py +0 -0
  92. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/prompts/IPromptMatrix.py +0 -0
  93. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/prompts/ITemplate.py +0 -0
  94. {swarmauri_core-0.5.3.dev3/swarmauri_core/toolkits → swarmauri_core-0.6.0.dev1/swarmauri_core/prompts}/__init__.py +0 -0
  95. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/schema_converters/ISchemaConvert.py +0 -0
  96. {swarmauri_core-0.5.3.dev3/swarmauri_core/tools → swarmauri_core-0.6.0.dev1/swarmauri_core/schema_converters}/__init__.py +0 -0
  97. {swarmauri_core-0.5.3.dev3/swarmauri_core/tracing → swarmauri_core-0.6.0.dev1/swarmauri_core/service_registries}/__init__.py +0 -0
  98. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/swarm_apis/IAgentRegistrationAPI.py +0 -0
  99. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/swarm_apis/ISwarmAPI.py +0 -0
  100. {swarmauri_core-0.5.3.dev3/swarmauri_core/utils → swarmauri_core-0.6.0.dev1/swarmauri_core/swarm_apis}/__init__.py +0 -0
  101. {swarmauri_core-0.5.3.dev3/swarmauri_core/vcms → swarmauri_core-0.6.0.dev1/swarmauri_core/swarms}/__init__.py +0 -0
  102. {swarmauri_core-0.5.3.dev3/swarmauri_core/vector_stores → swarmauri_core-0.6.0.dev1/swarmauri_core/task_mgmt_strategies}/__init__.py +0 -0
  103. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/toolkits/IToolkit.py +0 -0
  104. {swarmauri_core-0.5.3.dev3/swarmauri_core/vectors → swarmauri_core-0.6.0.dev1/swarmauri_core/toolkits}/__init__.py +0 -0
  105. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/tools/IParameter.py +0 -0
  106. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/tools/ITool.py +0 -0
  107. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/tracing/IChainTracer.py +0 -0
  108. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/tracing/ITraceContext.py +0 -0
  109. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/tracing/ITracer.py +0 -0
  110. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/utils/ITransactional.py +0 -0
  111. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vcms/IPredictVision.py +0 -0
  112. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vector_stores/ICloudVectorStore.py +0 -0
  113. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vector_stores/IPersistentVectorStore.py +0 -0
  114. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vector_stores/ISimilarity.py +0 -0
  115. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vector_stores/IVectorNorm.py +0 -0
  116. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vector_stores/IVectorStore.py +0 -0
  117. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vector_stores/IVectorStoreRetrieve.py +0 -0
  118. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vector_stores/IVectorStoreSaveLoad.py +0 -0
  119. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vectors/IVector.py +0 -0
  120. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vectors/IVectorMeta.py +0 -0
  121. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/swarmauri_core/vectors/IVectorProduct.py +0 -0
  122. {swarmauri_core-0.5.3.dev3 → swarmauri_core-0.6.0.dev1}/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.3.dev3
3
+ Version: 0.6.0.dev1
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.3.dev3"
3
+ version = "0.6.0.dev1"
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"]
@@ -0,0 +1,427 @@
1
+ # swarmauri_core/ComponentBase.py
2
+
3
+ import hashlib
4
+ import inspect
5
+ import json
6
+ import logging
7
+ from enum import Enum
8
+ from threading import Lock
9
+ from uuid import uuid4
10
+ from pydantic import BaseModel, Field, ValidationError, field_validator
11
+ from typing import (
12
+ Annotated,
13
+ Any,
14
+ ClassVar,
15
+ Dict,
16
+ Generic,
17
+ List,
18
+ Literal,
19
+ Optional,
20
+ Set,
21
+ Type,
22
+ TypeVar,
23
+ Union,
24
+ Tuple,
25
+ get_args,
26
+ get_origin,
27
+ )
28
+
29
+ logger = logging.getLogger(__name__)
30
+ T = TypeVar("T", bound="ComponentBase")
31
+
32
+ class ResourceType:
33
+ """
34
+ Metadata class to hold resource type information for Annotated fields.
35
+ """
36
+ def __init__(self, resource_type: Type['ComponentBase']):
37
+ self.resource_type = resource_type
38
+
39
+ class SubclassUnion(type):
40
+ """
41
+ A generic class to create discriminated unions based on resource types.
42
+ """
43
+ def __class_getitem__(cls, resource_type: Type[T]) -> type:
44
+ """
45
+ Allows usage of SubclassUnion[ResourceType] to get the corresponding discriminated Union.
46
+
47
+ Parameters:
48
+ - resource_type: The base class of the resource (e.g., Shape, Kind).
49
+
50
+ Returns:
51
+ - An Annotated Union of all subclasses registered under the resource_type, with 'type' as the discriminator.
52
+ """
53
+ registered_classes = list(ComponentBase.TYPE_REGISTRY.get(resource_type, {}).values())
54
+ if not registered_classes:
55
+ logger.debug(f"No subclasses registered for resource type '{resource_type.__name__}'. Using 'Any' as a placeholder.")
56
+ return Annotated[Any, Field(...), ResourceType(resource_type)]
57
+ else:
58
+ union_type = Union[tuple(registered_classes)]
59
+ return Annotated[union_type, Field(discriminator='type'), ResourceType(resource_type)]
60
+
61
+ class ResourceTypes(Enum):
62
+ UNIVERSAL_BASE = "ComponentBase"
63
+ AGENT = "Agent"
64
+ AGENT_FACTORY = "AgentFactory"
65
+ CHAIN = "Chain"
66
+ CHAIN_METHOD = "ChainMethod"
67
+ CHUNKER = "Chunker"
68
+ CONVERSATION = "Conversation"
69
+ DISTANCE = "Distance"
70
+ DOCUMENT_STORE = "DocumentStore"
71
+ DOCUMENT = "Document"
72
+ EMBEDDING = "Embedding"
73
+ EXCEPTION = "Exception"
74
+ IMAGE_GEN = "ImageGen"
75
+ LLM = "LLM"
76
+ MESSAGE = "Message"
77
+ MEASUREMENT = "Measurement"
78
+ PARSER = "Parser"
79
+ PROMPT = "Prompt"
80
+ STATE = "State"
81
+ CHAINSTEP = "ChainStep"
82
+ SCHEMA_CONVERTER = "SchemaConverter"
83
+ SWARM = "Swarm"
84
+ TOOLKIT = "Toolkit"
85
+ TOOL = "Tool"
86
+ PARAMETER = "Parameter"
87
+ TRACE = "Trace"
88
+ UTIL = "Util"
89
+ VECTOR_STORE = "VectorStore"
90
+ VECTOR = "Vector"
91
+ VCM = "VCM"
92
+ DATA_CONNECTOR = "DataConnector"
93
+ TRANSPORT = "Transport"
94
+ FACTORY = "Factory"
95
+ PIPELINE = "Pipeline"
96
+ SERVICE_REGISTRY = "ServiceRegistry"
97
+ CONTROL_PANEL = "ControlPanel"
98
+ TASK_MGMT_STRATEGY = "TaskMgmtStrategy"
99
+
100
+ def generate_id() -> str:
101
+ return str(uuid4())
102
+
103
+ class ComponentBase(BaseModel):
104
+ """
105
+ Base class for all components.
106
+ """
107
+ # Class-level registry mapping resource types to their type mappings
108
+ TYPE_REGISTRY: ClassVar[Dict[Type['ComponentBase'], Dict[str, Type['ComponentBase']]]] = {}
109
+ # Model registry mapping models to their resource types
110
+ MODEL_REGISTRY: ClassVar[Dict[Type[BaseModel], List[Type['ComponentBase']]]] = {}
111
+ _lock: ClassVar[Lock] = Lock()
112
+
113
+ name: Optional[str] = None
114
+ id: str = Field(default_factory=generate_id)
115
+ members: List[str] = Field(default_factory=list)
116
+ owner: Optional[str] = None
117
+ host: Optional[str] = None
118
+ resource: str = Field(default="ComponentBase")
119
+ version: str = "0.1.0"
120
+ type: Literal["ComponentBase"] = "ComponentBase"
121
+
122
+ @field_validator("type")
123
+ def set_type(cls, v, values):
124
+ if v == "ComponentBase" and cls.__name__ != "ComponentBase":
125
+ return cls.__name__
126
+ return v
127
+
128
+ # Normative Class Methods
129
+ def __swm_class_hash__(self):
130
+ sig_hash = hashlib.sha256()
131
+ for attr_name in dir(self):
132
+ attr_value = getattr(self, attr_name)
133
+ if callable(attr_value) and not attr_name.startswith("_"):
134
+ sig = inspect.signature(attr_value)
135
+ sig_hash.update(str(sig).encode())
136
+ return sig_hash.hexdigest()
137
+
138
+ @classmethod
139
+ def swm_public_interfaces(cls):
140
+ methods = []
141
+ for attr_name in dir(cls):
142
+ attr_value = getattr(cls, attr_name)
143
+ if (callable(attr_value) and not attr_name.startswith("_")) or isinstance(
144
+ attr_value, property
145
+ ):
146
+ methods.append(attr_name)
147
+ return methods
148
+
149
+ @classmethod
150
+ def swm_ismethod_registered(cls, method_name: str):
151
+ return method_name in cls.swm_public_interfaces()
152
+
153
+ @classmethod
154
+ def swm_method_signature(cls, input_signature):
155
+ for method_name in cls.swm_public_interfaces():
156
+ method = getattr(cls, method_name)
157
+ if callable(method):
158
+ sig = str(inspect.signature(method))
159
+ if sig == input_signature:
160
+ return True
161
+ return False
162
+
163
+ @property
164
+ def swm_path(self):
165
+ if self.host and self.owner:
166
+ return f"{self.host}/{self.owner}/{self.resource}/{self.name}/{self.id}"
167
+ if self.resource and self.name:
168
+ return f"/{self.resource}/{self.name}/{self.id}"
169
+ return f"/{self.resource}/{self.id}"
170
+
171
+ @property
172
+ def swm_isremote(self):
173
+ return bool(self.host)
174
+
175
+ # Functional Class Methods
176
+
177
+ @classmethod
178
+ def register_type(cls, resource_type: Type[T], type_name: str):
179
+ """
180
+ Decorator to register a component class with a specific type name under a resource type.
181
+ """
182
+ def decorator(subclass: Type['ComponentBase']):
183
+ if not issubclass(subclass, resource_type):
184
+ raise TypeError(f"Registered class '{subclass.__name__}' must be a subclass of {resource_type.__name__}")
185
+ if resource_type not in cls.TYPE_REGISTRY:
186
+ cls.TYPE_REGISTRY[resource_type] = {}
187
+ cls.TYPE_REGISTRY[resource_type][type_name] = subclass
188
+ # Automatically recreate models after registering a new type
189
+ cls.recreate_models()
190
+ logger.info(f"Registered type '{type_name}' for resource '{resource_type.__name__}' with subclass '{subclass.__name__}'")
191
+ return subclass
192
+ return decorator
193
+
194
+ @classmethod
195
+ def register_model(cls):
196
+ """
197
+ Decorator to register a Pydantic model by automatically detecting resource types
198
+ from fields that use SubclassUnion.
199
+ """
200
+ def decorator(model_cls: Type[BaseModel]):
201
+ # Initialize list if not present
202
+ if model_cls not in cls.MODEL_REGISTRY:
203
+ cls.MODEL_REGISTRY[model_cls] = []
204
+
205
+ # Inspect all fields to find SubclassUnion annotations
206
+ for field_name, field in model_cls.__fields__.items():
207
+ field_annotation = model_cls.__annotations__.get(field_name)
208
+ if not field_annotation:
209
+ continue
210
+
211
+ # Check if field uses SubclassUnion
212
+ if cls.field_contains_subclass_union(field_annotation):
213
+ # Extract resource types from SubclassUnion
214
+ resource_types = cls.extract_resource_types_from_field(field_annotation)
215
+ for resource_type in resource_types:
216
+ if resource_type not in cls.MODEL_REGISTRY[model_cls]:
217
+ cls.MODEL_REGISTRY[model_cls].append(resource_type)
218
+ logger.info(f"Registered model '{model_cls.__name__}' for resource '{resource_type.__name__}'")
219
+ cls.recreate_models()
220
+ return model_cls
221
+ return decorator
222
+
223
+ @classmethod
224
+ def get_class_by_type(cls, resource_type: Type[T], type_name: str) -> Type['ComponentBase']:
225
+ """
226
+ Retrieve a component class based on its resource type and type name.
227
+
228
+ Parameters:
229
+ - resource_type: The base class of the resource.
230
+ - type_name: The string identifier for the component type.
231
+
232
+ Returns:
233
+ - The corresponding component class.
234
+ """
235
+ return cls.TYPE_REGISTRY.get(resource_type, {}).get(type_name)
236
+
237
+ @classmethod
238
+ def field_contains_subclass_union(cls, field_annotation) -> bool:
239
+ """
240
+ Check if the field annotation contains a SubclassUnion or associated ResourceType metadata.
241
+
242
+ Parameters:
243
+ - field_annotation: The type annotation of the field.
244
+
245
+ Returns:
246
+ - True if SubclassUnion or ResourceType is present, False otherwise.
247
+ """
248
+ logger.debug(f"Checking if field annotation '{field_annotation}' contains a SubclassUnion or ResourceType")
249
+
250
+ origin = get_origin(field_annotation)
251
+ args = get_args(field_annotation)
252
+
253
+ # Check for Annotated fields
254
+ if origin is Annotated:
255
+ for arg in args:
256
+ if isinstance(arg, ResourceType):
257
+ logger.debug(f"Annotated field contains ResourceType metadata for resource '{arg.resource_type.__name__}'")
258
+ return True
259
+ if cls.field_contains_subclass_union(arg):
260
+ logger.debug(f"Annotated field contains SubclassUnion in '{arg}'")
261
+ return True
262
+
263
+ # Check for container types (List, Union, Dict)
264
+ if origin in {Union, List, Dict, Set, Tuple, Optional}:
265
+ for arg in args:
266
+ if cls.field_contains_subclass_union(arg):
267
+ logger.debug(f"Container field '{field_annotation}' contains SubclassUnion in its arguments")
268
+ return True
269
+
270
+ logger.debug(f"Field annotation '{field_annotation}' does not contain SubclassUnion or ResourceType")
271
+ return False
272
+
273
+
274
+ @classmethod
275
+ def extract_resource_types_from_field(cls, field_annotation) -> List[Type['ComponentBase']]:
276
+ """
277
+ Extracts all resource types from a field annotation using SubclassUnion.
278
+
279
+ Parameters:
280
+ - field_annotation: The type annotation of the field.
281
+
282
+ Returns:
283
+ - A list of resource type classes.
284
+ """
285
+ logger.debug(f"Extracting resource types from field annotation '{field_annotation}'")
286
+ resource_types = []
287
+ try:
288
+ origin = get_origin(field_annotation)
289
+ args = get_args(field_annotation)
290
+
291
+ if origin is Annotated:
292
+ for arg in args[1:]: # Skip the first argument which is the main type
293
+ if isinstance(arg, ResourceType):
294
+ resource_types.append(arg.resource_type)
295
+ logger.debug(f"Found ResourceType metadata with resource type '{arg.resource_type.__name__}'")
296
+ else:
297
+ resource_types.extend(cls.extract_resource_types_from_field(arg))
298
+
299
+ elif origin in {Union, List, Dict, Set, Tuple, Optional}:
300
+ for arg in args:
301
+ resource_types.extend(cls.extract_resource_types_from_field(arg))
302
+
303
+ return resource_types
304
+ except TypeError as e:
305
+ logger.error(f"TypeError while extracting resource types from field annotation '{field_annotation}': {e}")
306
+ return resource_types
307
+
308
+
309
+ @classmethod
310
+ def determine_new_type(cls, field_annotation, resource_type):
311
+ """
312
+ Determine the new type for a field based on its annotation and resource type.
313
+
314
+ Parameters:
315
+ - field_annotation: The original type annotation.
316
+ - resource_type: The resource type associated with the field.
317
+
318
+ Returns:
319
+ - The updated type annotation incorporating SubclassUnion.
320
+ """
321
+ logger.debug(f"Determining new type for field annotation '{field_annotation}' with resource type '{resource_type.__name__}'")
322
+ try:
323
+ origin = get_origin(field_annotation)
324
+ args = get_args(field_annotation)
325
+
326
+ is_optional = False
327
+
328
+ # Handle Optional[...] (Union[..., NoneType])
329
+ if origin is Union and type(None) in args:
330
+ non_none_args = [arg for arg in args if arg is not type(None)]
331
+ if len(non_none_args) == 1:
332
+ field_annotation = non_none_args[0]
333
+ origin = get_origin(field_annotation)
334
+ args = get_args(field_annotation)
335
+ is_optional = True
336
+ else:
337
+ # Multiple non-None types, complex Union
338
+ logger.warning(f"Field annotation '{field_annotation}' has multiple non-None Union types; optionality may not be preserved correctly.")
339
+
340
+ # Handle Annotated
341
+ if origin is Annotated:
342
+ base_type = args[0]
343
+ metadata = [arg for arg in args[1:] if not isinstance(arg, ResourceType)]
344
+ # Append the new ResourceType
345
+ metadata.append(ResourceType(resource_type))
346
+ logger.debug(f"Preserving existing metadata and adding ResourceType for resource '{resource_type.__name__}'")
347
+ field_annotation = Annotated[base_type, *metadata]
348
+
349
+ # Construct the new type with SubclassUnion and discriminated Union
350
+ subclass_union = SubclassUnion[resource_type]
351
+
352
+ # Preserve Optionality if necessary
353
+ if is_optional:
354
+ new_type = Union[subclass_union, type(None)]
355
+ else:
356
+ new_type = subclass_union
357
+
358
+ logger.debug(f"New type for field: {new_type}")
359
+ return new_type
360
+ except TypeError as e:
361
+ logger.error(f"TypeError while determining new type for field annotation '{field_annotation}': {e}")
362
+ return field_annotation # Fallback to original type if error occurs
363
+
364
+
365
+
366
+ @classmethod
367
+ def generate_models_with_fields(cls) -> Dict[Type[BaseModel], Dict[str, Any]]:
368
+ """
369
+ Automatically generate the models_with_fields dictionary based on registered models.
370
+
371
+ Returns:
372
+ - A dictionary mapping model classes to their fields and corresponding resource types.
373
+ """
374
+ logging.info("Starting generation of models_with_fields")
375
+
376
+ models_with_fields = {}
377
+ for model_cls, resource_types in cls.MODEL_REGISTRY.items():
378
+ logging.debug(f"Processing model: {model_cls.__name__}")
379
+ models_with_fields[model_cls] = {}
380
+
381
+ for field_name, field in model_cls.__fields__.items():
382
+ logging.debug(f"Processing field: {field_name}")
383
+
384
+ field_annotation = model_cls.__annotations__.get(field_name)
385
+ if not field_annotation:
386
+ logging.debug(f"Field {field_name} in model {model_cls.__name__} has no annotation, skipping.")
387
+ continue
388
+
389
+ # Check if SubclassUnion is used in the field type
390
+ if not cls.field_contains_subclass_union(field_annotation):
391
+ logging.debug(f"Field {field_name} does not contain SubclassUnion, skipping.")
392
+ continue # Only process fields that use SubclassUnion
393
+
394
+ # Extract all resource types from the field
395
+ field_resource_types = cls.extract_resource_types_from_field(field_annotation)
396
+ logging.debug(f"Extracted resource types for field {field_name}: {field_resource_types}")
397
+
398
+ for resource_type in field_resource_types:
399
+ new_type = cls.determine_new_type(field_annotation, resource_type)
400
+ logging.debug(f"Determined new type for resource {resource_type}: {new_type}")
401
+
402
+ models_with_fields[model_cls][field_name] = new_type
403
+
404
+ logging.info("Completed generation of models_with_fields")
405
+ return models_with_fields
406
+
407
+ @classmethod
408
+ def recreate_models(cls):
409
+ """
410
+ Recreate all models based on the dynamically generated models_with_fields.
411
+ """
412
+ with cls._lock:
413
+ models_with_fields = cls.generate_models_with_fields()
414
+ for model_class, fields in models_with_fields.items():
415
+ for field_name, new_type in fields.items():
416
+ if field_name in model_class.model_fields:
417
+ model_class.model_fields[field_name].annotation = new_type
418
+ else:
419
+ raise ValueError(f"Field '{field_name}' does not exist in model '{model_class.__name__}'")
420
+ try:
421
+ model_class.model_rebuild(force=True)
422
+ logger.debug(f"'{model_class}' has been successfully recreated.")
423
+ except ValidationError as ve:
424
+ logger.error(f"Validation error while rebuilding model '{model_class.__name__}': {ve}")
425
+ except Exception as e:
426
+ logger.error(f"Error while rebuilding model '{model_class.__name__}': {e}")
427
+ logger.info("All models have been successfully recreated.")
@@ -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,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