swarmauri-core 0.5.0.dev1__py3-none-any.whl
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.
- swarmauri_core/ComponentBase.py +163 -0
- swarmauri_core/__init__.py +11 -0
- swarmauri_core/agent_apis/IAgentCommands.py +83 -0
- swarmauri_core/agent_apis/IAgentRouterCRUD.py +56 -0
- swarmauri_core/agent_apis/__init__.py +4 -0
- swarmauri_core/agent_factories/IAgentFactory.py +79 -0
- swarmauri_core/agent_factories/IExportConf.py +40 -0
- swarmauri_core/agent_factories/__init__.py +0 -0
- swarmauri_core/agents/IAgent.py +12 -0
- swarmauri_core/agents/IAgentConversation.py +5 -0
- swarmauri_core/agents/IAgentParser.py +14 -0
- swarmauri_core/agents/IAgentRetrieve.py +4 -0
- swarmauri_core/agents/IAgentSystemContext.py +4 -0
- swarmauri_core/agents/IAgentToolkit.py +4 -0
- swarmauri_core/agents/IAgentVectorStore.py +4 -0
- swarmauri_core/agents/__init__.py +0 -0
- swarmauri_core/chains/ICallableChain.py +15 -0
- swarmauri_core/chains/IChain.py +75 -0
- swarmauri_core/chains/IChainContext.py +11 -0
- swarmauri_core/chains/IChainContextLoader.py +8 -0
- swarmauri_core/chains/IChainDependencyResolver.py +32 -0
- swarmauri_core/chains/IChainFactory.py +61 -0
- swarmauri_core/chains/IChainStep.py +7 -0
- swarmauri_core/chains/__init__.py +1 -0
- swarmauri_core/chunkers/IChunker.py +15 -0
- swarmauri_core/chunkers/__init__.py +0 -0
- swarmauri_core/conversations/IConversation.py +45 -0
- swarmauri_core/conversations/IMaxSize.py +4 -0
- swarmauri_core/conversations/ISystemContext.py +4 -0
- swarmauri_core/conversations/__init__.py +0 -0
- swarmauri_core/distances/IDistanceSimilarity.py +49 -0
- swarmauri_core/distances/__init__.py +0 -0
- swarmauri_core/document_stores/IDocumentRetrieve.py +25 -0
- swarmauri_core/document_stores/IDocumentStore.py +79 -0
- swarmauri_core/document_stores/__init__.py +0 -0
- swarmauri_core/documents/IDocument.py +4 -0
- swarmauri_core/documents/IExperimentDocument.py +120 -0
- swarmauri_core/documents/__init__.py +0 -0
- swarmauri_core/embeddings/IFeature.py +9 -0
- swarmauri_core/embeddings/ISaveModel.py +30 -0
- swarmauri_core/embeddings/IVectorize.py +26 -0
- swarmauri_core/embeddings/__init__.py +1 -0
- swarmauri_core/experiment_stores/IExperimentStore.py +72 -0
- swarmauri_core/experiment_stores/__init__.py +99 -0
- swarmauri_core/llms/IFit.py +13 -0
- swarmauri_core/llms/IPredict.py +13 -0
- swarmauri_core/llms/__init__.py +0 -0
- swarmauri_core/messages/IMessage.py +10 -0
- swarmauri_core/messages/__init__.py +1 -0
- swarmauri_core/metrics/IMetric.py +19 -0
- swarmauri_core/metrics/IMetricAggregate.py +16 -0
- swarmauri_core/metrics/IMetricCalculate.py +30 -0
- swarmauri_core/metrics/IThreshold.py +4 -0
- swarmauri_core/metrics/__init__.py +0 -0
- swarmauri_core/parsers/IParser.py +19 -0
- swarmauri_core/parsers/__init__.py +0 -0
- swarmauri_core/prompts/IPrompt.py +18 -0
- swarmauri_core/prompts/IPromptMatrix.py +30 -0
- swarmauri_core/prompts/ITemplate.py +46 -0
- swarmauri_core/prompts/__init__.py +0 -0
- swarmauri_core/schema_converters/ISchemaConvert.py +9 -0
- swarmauri_core/schema_converters/__init__.py +0 -0
- swarmauri_core/swarm_apis/IAgentRegistrationAPI.py +72 -0
- swarmauri_core/swarm_apis/ISwarmAPI.py +24 -0
- swarmauri_core/swarm_apis/__init__.py +0 -0
- swarmauri_core/swarms/ISwarm.py +67 -0
- swarmauri_core/swarms/ISwarmAgentRegistration.py +73 -0
- swarmauri_core/swarms/ISwarmChainCRUD.py +62 -0
- swarmauri_core/swarms/ISwarmComponent.py +13 -0
- swarmauri_core/swarms/ISwarmConfigurationExporter.py +33 -0
- swarmauri_core/swarms/ISwarmFactory.py +120 -0
- swarmauri_core/swarms/__init__.py +0 -0
- swarmauri_core/toolkits/IToolkit.py +44 -0
- swarmauri_core/toolkits/__init__.py +0 -0
- swarmauri_core/tools/IParameter.py +9 -0
- swarmauri_core/tools/ITool.py +12 -0
- swarmauri_core/tools/__init__.py +0 -0
- swarmauri_core/tracing/IChainTracer.py +25 -0
- swarmauri_core/tracing/ITraceContext.py +29 -0
- swarmauri_core/tracing/ITracer.py +45 -0
- swarmauri_core/tracing/__init__.py +0 -0
- swarmauri_core/typing.py +26 -0
- swarmauri_core/utils/ITransactional.py +24 -0
- swarmauri_core/utils/__init__.py +0 -0
- swarmauri_core/vector_stores/IAngleBetweenVectors.py +23 -0
- swarmauri_core/vector_stores/ICloudVectorStore.py +21 -0
- swarmauri_core/vector_stores/IDecompose.py +24 -0
- swarmauri_core/vector_stores/IDivergence.py +21 -0
- swarmauri_core/vector_stores/IGradient.py +22 -0
- swarmauri_core/vector_stores/IOrthogonalProject.py +21 -0
- swarmauri_core/vector_stores/IPersistentVectorStore.py +21 -0
- swarmauri_core/vector_stores/IProject.py +22 -0
- swarmauri_core/vector_stores/IReflect.py +21 -0
- swarmauri_core/vector_stores/ISimilarity.py +26 -0
- swarmauri_core/vector_stores/ISimiliarityQuery.py +19 -0
- swarmauri_core/vector_stores/IVectorArithmetic.py +31 -0
- swarmauri_core/vector_stores/IVectorBasisCheck.py +20 -0
- swarmauri_core/vector_stores/IVectorLinearCombination.py +21 -0
- swarmauri_core/vector_stores/IVectorNorm.py +49 -0
- swarmauri_core/vector_stores/IVectorRotate.py +24 -0
- swarmauri_core/vector_stores/IVectorSpan.py +21 -0
- swarmauri_core/vector_stores/IVectorStore.py +88 -0
- swarmauri_core/vector_stores/IVectorStoreRetrieve.py +26 -0
- swarmauri_core/vector_stores/IVectorStoreSaveLoad.py +45 -0
- swarmauri_core/vector_stores/__init__.py +0 -0
- swarmauri_core/vectors/IVector.py +10 -0
- swarmauri_core/vectors/IVectorMeta.py +28 -0
- swarmauri_core/vectors/IVectorProduct.py +66 -0
- swarmauri_core/vectors/IVectorTransform.py +49 -0
- swarmauri_core/vectors/__init__.py +0 -0
- swarmauri_core-0.5.0.dev1.dist-info/METADATA +26 -0
- swarmauri_core-0.5.0.dev1.dist-info/RECORD +114 -0
- swarmauri_core-0.5.0.dev1.dist-info/WHEEL +5 -0
- swarmauri_core-0.5.0.dev1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
class IFit(ABC):
|
|
4
|
+
"""
|
|
5
|
+
Interface for training models.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
@abstractmethod
|
|
9
|
+
def fit(self, X_train, y_train, epochs: int, batch_size: int) -> None:
|
|
10
|
+
"""
|
|
11
|
+
Train the model on the provided dataset.
|
|
12
|
+
"""
|
|
13
|
+
pass
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
class IPredict(ABC):
|
|
4
|
+
"""
|
|
5
|
+
Interface focusing on the basic properties and settings essential for defining models.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
@abstractmethod
|
|
9
|
+
def predict(self, *args, **kwargs) -> any:
|
|
10
|
+
"""
|
|
11
|
+
Generate predictions based on the input data provided to the model.
|
|
12
|
+
"""
|
|
13
|
+
pass
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
class IMessage(ABC):
|
|
4
|
+
"""
|
|
5
|
+
An abstract interface representing a general message structure.
|
|
6
|
+
|
|
7
|
+
This interface defines the basic attributes that all
|
|
8
|
+
messages should have, including type, name, and content,
|
|
9
|
+
and requires subclasses to implement representation and formatting methods.
|
|
10
|
+
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .IMessage import IMessage
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
|
|
4
|
+
class IMetric(ABC):
|
|
5
|
+
"""
|
|
6
|
+
Defines a general interface for metrics within the SwarmaURI system.
|
|
7
|
+
Metrics can be anything from system performance measurements to
|
|
8
|
+
machine learning model evaluation metrics.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def __call__(self, **kwargs) -> Any:
|
|
13
|
+
"""
|
|
14
|
+
Retrieves the current value of the metric.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
The current value of the metric.
|
|
18
|
+
"""
|
|
19
|
+
pass
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from typing import List, Any
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
|
|
4
|
+
class IMetricAggregate(ABC):
|
|
5
|
+
|
|
6
|
+
@abstractmethod
|
|
7
|
+
def add_measurement(self, measurement: Any) -> None:
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
@abstractmethod
|
|
11
|
+
def reset(self) -> None:
|
|
12
|
+
"""
|
|
13
|
+
Reset or clear the metric's current state, starting fresh as if no data had been processed.
|
|
14
|
+
This is useful for metrics that might aggregate or average data over time and need to be reset.
|
|
15
|
+
"""
|
|
16
|
+
pass
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
|
|
4
|
+
class IMetricCalculate(ABC):
|
|
5
|
+
|
|
6
|
+
@abstractmethod
|
|
7
|
+
def calculate(self, **kwargs) -> Any:
|
|
8
|
+
"""
|
|
9
|
+
Calculate the metric based on the provided data.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
*args: Variable length argument list that the metric calculation might require.
|
|
13
|
+
**kwargs: Arbitrary keyword arguments that the metric calculation might require.
|
|
14
|
+
"""
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def update(self, value) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Update the metric value based on new information.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
value: The new information used to update the metric. This could be a new
|
|
24
|
+
measurement or data point that affects the metric's current value.
|
|
25
|
+
|
|
26
|
+
Note:
|
|
27
|
+
This method is intended for internal use and should not be publicly accessible.
|
|
28
|
+
"""
|
|
29
|
+
pass
|
|
30
|
+
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import List, Union, Any
|
|
3
|
+
from swarmauri.core.documents.IDocument import IDocument
|
|
4
|
+
|
|
5
|
+
class IParser(ABC):
|
|
6
|
+
"""
|
|
7
|
+
Abstract base class for parsers. It defines a public method to parse input data (str or Message) into documents,
|
|
8
|
+
and relies on subclasses to implement the specific parsing logic through protected and private methods.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def parse(self, data: Union[str, Any]) -> List[IDocument]:
|
|
13
|
+
"""
|
|
14
|
+
Public method to parse input data (either a str or a Message) into a list of Document instances.
|
|
15
|
+
|
|
16
|
+
This method leverages the abstract _parse_data method which must be
|
|
17
|
+
implemented by subclasses to define specific parsing logic.
|
|
18
|
+
"""
|
|
19
|
+
pass
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Optional, Any
|
|
3
|
+
|
|
4
|
+
class IPrompt(ABC):
|
|
5
|
+
"""
|
|
6
|
+
A base abstract class representing a prompt system.
|
|
7
|
+
|
|
8
|
+
Methods:
|
|
9
|
+
__call__: Abstract method that subclasses must implement to enable the instance to be called directly.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
@abstractmethod
|
|
13
|
+
def __call__(self, **kwargs) -> str:
|
|
14
|
+
"""
|
|
15
|
+
Abstract method that subclasses must implement to define the behavior of the prompt when called.
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
pass
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import List, Tuple, Optional, Any
|
|
3
|
+
|
|
4
|
+
class IPromptMatrix(ABC):
|
|
5
|
+
|
|
6
|
+
@property
|
|
7
|
+
@abstractmethod
|
|
8
|
+
def shape(self) -> Tuple[int, int]:
|
|
9
|
+
"""Get the shape (number of agents, sequence length) of the prompt matrix."""
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
@abstractmethod
|
|
13
|
+
def add_prompt_sequence(self, sequence: List[Optional[str]]) -> None:
|
|
14
|
+
"""Add a new prompt sequence to the matrix."""
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def remove_prompt_sequence(self, index: int) -> None:
|
|
19
|
+
"""Remove a prompt sequence from the matrix by index."""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def get_prompt_sequence(self, index: int) -> List[Optional[str]]:
|
|
24
|
+
"""Get a prompt sequence from the matrix by index."""
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
@abstractmethod
|
|
28
|
+
def show(self) -> List[List[Optional[str]]]:
|
|
29
|
+
"""Show the entire prompt matrix."""
|
|
30
|
+
pass
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from typing import Dict, List, Any, Union
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ITemplate(ABC):
|
|
6
|
+
"""
|
|
7
|
+
Interface for template-based prompt generation within the SwarmAURI framework.
|
|
8
|
+
Defines standard operations and attributes for managing and utilizing templates.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def set_template(self, template: str) -> None:
|
|
13
|
+
"""
|
|
14
|
+
Sets or updates the current template string.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
template (str): The new template string to be used for generating prompts.
|
|
18
|
+
"""
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
@abstractmethod
|
|
22
|
+
def set_variables(self,
|
|
23
|
+
variables: Union[List[Dict[str, Any]], Dict[str, Any]] = {}) -> None:
|
|
24
|
+
"""
|
|
25
|
+
Sets or updates the variables to be substituted into the template.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
variables (List[Dict[str, str]]): A dictionary of variables where each key-value
|
|
29
|
+
pair corresponds to a placeholder name and its
|
|
30
|
+
replacement value in the template.
|
|
31
|
+
"""
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def generate_prompt(self, **kwargs) -> str:
|
|
36
|
+
"""
|
|
37
|
+
Generates a prompt string based on the current template and provided keyword arguments.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
**kwargs: Keyword arguments containing variables for template substitution.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
str: The generated prompt string with template variables replaced by their
|
|
44
|
+
corresponding values provided in `kwargs`.
|
|
45
|
+
"""
|
|
46
|
+
pass
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Any, Dict
|
|
3
|
+
from swarmauri.core.tools.ITool import ITool
|
|
4
|
+
|
|
5
|
+
class ISchemaConvert(ABC):
|
|
6
|
+
|
|
7
|
+
@abstractmethod
|
|
8
|
+
def convert(self, tool: ITool) -> Dict[str, Any]:
|
|
9
|
+
raise NotImplementedError("Subclasses must implement the convert method.")
|
|
File without changes
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import List, Dict, Optional
|
|
3
|
+
from swarmauri.core.agents.IAgent import IAgent
|
|
4
|
+
|
|
5
|
+
class IAgentRegistrationAPI(ABC):
|
|
6
|
+
"""
|
|
7
|
+
Interface for registering agents with the swarm, designed to support CRUD operations on IAgent instances.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
@abstractmethod
|
|
11
|
+
def register_agent(self, agent: IAgent) -> bool:
|
|
12
|
+
"""
|
|
13
|
+
Register a new agent with the swarm.
|
|
14
|
+
|
|
15
|
+
Parameters:
|
|
16
|
+
agent (IAgent): An instance of IAgent representing the agent to register.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
bool: True if the registration succeeded; False otherwise.
|
|
20
|
+
"""
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def update_agent(self, agent_id: str, updated_agent: IAgent) -> bool:
|
|
25
|
+
"""
|
|
26
|
+
Update the details of an existing agent. This could include changing the agent's configuration,
|
|
27
|
+
task assignment, or any other mutable attribute.
|
|
28
|
+
|
|
29
|
+
Parameters:
|
|
30
|
+
agent_id (str): The unique identifier for the agent.
|
|
31
|
+
updated_agent (IAgent): An updated IAgent instance to replace the existing one.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
bool: True if the update was successful; False otherwise.
|
|
35
|
+
"""
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def remove_agent(self, agent_id: str) -> bool:
|
|
40
|
+
"""
|
|
41
|
+
Remove an agent from the swarm based on its unique identifier.
|
|
42
|
+
|
|
43
|
+
Parameters:
|
|
44
|
+
agent_id (str): The unique identifier for the agent to be removed.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
bool: True if the removal was successful; False otherwise.
|
|
48
|
+
"""
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
@abstractmethod
|
|
52
|
+
def get_agent(self, agent_id: str) -> Optional[IAgent]:
|
|
53
|
+
"""
|
|
54
|
+
Retrieve an agent's instance from its unique identifier.
|
|
55
|
+
|
|
56
|
+
Parameters:
|
|
57
|
+
agent_id (str): The unique identifier for the agent of interest.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
Optional[IAgent]: The IAgent instance if found; None otherwise.
|
|
61
|
+
"""
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def list_agents(self) -> List[IAgent]:
|
|
66
|
+
"""
|
|
67
|
+
List all registered agents.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
List[IAgent]: A list containing instances of all registered IAgents.
|
|
71
|
+
"""
|
|
72
|
+
pass
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import List, Dict, Any
|
|
3
|
+
|
|
4
|
+
class ISwarmAPI(ABC):
|
|
5
|
+
"""
|
|
6
|
+
Interface for managing the swarm's API endpoints.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
@abstractmethod
|
|
10
|
+
def dispatch_request(self, request_data: Dict[str, Any]) -> Any:
|
|
11
|
+
"""
|
|
12
|
+
Dispatches an incoming user request to one or more suitable agents based on their capabilities.
|
|
13
|
+
|
|
14
|
+
Parameters:
|
|
15
|
+
- request_data (Dict[str, Any]): Data related to the incoming request.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
- Any: Response from processing the request.
|
|
19
|
+
"""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def broadcast_request(self, request_data: Dict[str, Any]) -> Any:
|
|
24
|
+
pass
|
|
File without changes
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Any, List, Dict
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from swarmauri.core.agents.IAgent import IAgent
|
|
5
|
+
from swarmauri.core.chains.ICallableChain import ICallableChain
|
|
6
|
+
|
|
7
|
+
class ISwarm(ABC):
|
|
8
|
+
"""
|
|
9
|
+
Interface for a Swarm, representing a collective of agents capable of performing tasks, executing callable chains, and adaptable configurations.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# Abstract properties and setters
|
|
13
|
+
@property
|
|
14
|
+
@abstractmethod
|
|
15
|
+
def id(self) -> str:
|
|
16
|
+
"""Unique identifier for the factory instance."""
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
@id.setter
|
|
20
|
+
@abstractmethod
|
|
21
|
+
def id(self, value: str) -> None:
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def name(self) -> str:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@name.setter
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def name(self, value: str) -> None:
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def type(self) -> str:
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@type.setter
|
|
40
|
+
@abstractmethod
|
|
41
|
+
def type(self, value: str) -> None:
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
@abstractmethod
|
|
46
|
+
def date_created(self) -> datetime:
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
@abstractmethod
|
|
51
|
+
def last_modified(self) -> datetime:
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
@last_modified.setter
|
|
55
|
+
@abstractmethod
|
|
56
|
+
def last_modified(self, value: datetime) -> None:
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
def __hash__(self):
|
|
60
|
+
"""
|
|
61
|
+
The __hash__ method allows objects of this class to be used in sets and as dictionary keys.
|
|
62
|
+
__hash__ should return an integer and be defined based on immutable properties.
|
|
63
|
+
This is generally implemented directly in concrete classes rather than in the interface,
|
|
64
|
+
but it's declared here to indicate that implementing classes must provide it.
|
|
65
|
+
"""
|
|
66
|
+
pass
|
|
67
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import List, Dict, Optional
|
|
3
|
+
from swarmauri.core.agents.IAgent import IAgent
|
|
4
|
+
|
|
5
|
+
class ISwarmAgentRegistration(ABC):
|
|
6
|
+
"""
|
|
7
|
+
Interface for registering agents with the swarm, designed to support CRUD operations on IAgent instances.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
@id.setter
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def registry(self, value: str) -> None:
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
@abstractmethod
|
|
17
|
+
def registry(self) -> List[IAgent]:
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
@abstractmethod
|
|
21
|
+
def register_agent(self, agent: IAgent) -> bool:
|
|
22
|
+
"""
|
|
23
|
+
Register a new agent with the swarm.
|
|
24
|
+
|
|
25
|
+
Parameters:
|
|
26
|
+
agent (IAgent): An instance of IAgent representing the agent to register.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
bool: True if the registration succeeded; False otherwise.
|
|
30
|
+
"""
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
def update_agent(self, agent_id: str, updated_agent: IAgent) -> bool:
|
|
35
|
+
"""
|
|
36
|
+
Update the details of an existing agent. This could include changing the agent's configuration,
|
|
37
|
+
task assignment, or any other mutable attribute.
|
|
38
|
+
|
|
39
|
+
Parameters:
|
|
40
|
+
agent_id (str): The unique identifier for the agent.
|
|
41
|
+
updated_agent (IAgent): An updated IAgent instance to replace the existing one.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
bool: True if the update was successful; False otherwise.
|
|
45
|
+
"""
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
@abstractmethod
|
|
49
|
+
def remove_agent(self, agent_id: str) -> bool:
|
|
50
|
+
"""
|
|
51
|
+
Remove an agent from the swarm based on its unique identifier.
|
|
52
|
+
|
|
53
|
+
Parameters:
|
|
54
|
+
agent_id (str): The unique identifier for the agent to be removed.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
bool: True if the removal was successful; False otherwise.
|
|
58
|
+
"""
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
@abstractmethod
|
|
62
|
+
def get_agent(self, agent_id: str) -> Optional[IAgent]:
|
|
63
|
+
"""
|
|
64
|
+
Retrieve an agent's instance from its unique identifier.
|
|
65
|
+
|
|
66
|
+
Parameters:
|
|
67
|
+
agent_id (str): The unique identifier for the agent of interest.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Optional[IAgent]: The IAgent instance if found; None otherwise.
|
|
71
|
+
"""
|
|
72
|
+
pass
|
|
73
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import List, Dict, Any
|
|
3
|
+
|
|
4
|
+
class ISwarmChainCRUD(ABC):
|
|
5
|
+
"""
|
|
6
|
+
Interface to provide CRUD operations for ICallableChain within swarms.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
@abstractmethod
|
|
10
|
+
def create_chain(self, chain_id: str, chain_definition: Dict[str, Any]) -> None:
|
|
11
|
+
"""
|
|
12
|
+
Creates a callable chain with the provided definition.
|
|
13
|
+
|
|
14
|
+
Parameters:
|
|
15
|
+
- chain_id (str): A unique identifier for the callable chain.
|
|
16
|
+
- chain_definition (Dict[str, Any]): The definition of the callable chain including steps and their configurations.
|
|
17
|
+
"""
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
@abstractmethod
|
|
21
|
+
def read_chain(self, chain_id: str) -> Dict[str, Any]:
|
|
22
|
+
"""
|
|
23
|
+
Retrieves the definition of a callable chain by its identifier.
|
|
24
|
+
|
|
25
|
+
Parameters:
|
|
26
|
+
- chain_id (str): The unique identifier of the callable chain to be retrieved.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
- Dict[str, Any]: The definition of the callable chain.
|
|
30
|
+
"""
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
def update_chain(self, chain_id: str, new_definition: Dict[str, Any]) -> None:
|
|
35
|
+
"""
|
|
36
|
+
Updates an existing callable chain with a new definition.
|
|
37
|
+
|
|
38
|
+
Parameters:
|
|
39
|
+
- chain_id (str): The unique identifier of the callable chain to be updated.
|
|
40
|
+
- new_definition (Dict[str, Any]): The new definition of the callable chain including updated steps and configurations.
|
|
41
|
+
"""
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
@abstractmethod
|
|
45
|
+
def delete_chain(self, chain_id: str) -> None:
|
|
46
|
+
"""
|
|
47
|
+
Removes a callable chain from the swarm.
|
|
48
|
+
|
|
49
|
+
Parameters:
|
|
50
|
+
- chain_id (str): The unique identifier of the callable chain to be removed.
|
|
51
|
+
"""
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
@abstractmethod
|
|
55
|
+
def list_chains(self) -> List[Dict[str, Any]]:
|
|
56
|
+
"""
|
|
57
|
+
Lists all callable chains currently managed by the swarm.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
- List[Dict[str, Any]]: A list of callable chain definitions.
|
|
61
|
+
"""
|
|
62
|
+
pass
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
class ISwarmComponent(ABC):
|
|
4
|
+
"""
|
|
5
|
+
Interface for defining a general component within a swarm system.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
@abstractmethod
|
|
9
|
+
def __init__(self, key: str, name: str):
|
|
10
|
+
"""
|
|
11
|
+
Initializes a swarm component with a unique key and name.
|
|
12
|
+
"""
|
|
13
|
+
pass
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Dict
|
|
3
|
+
class ISwarmConfigurationExporter(ABC):
|
|
4
|
+
|
|
5
|
+
@abstractmethod
|
|
6
|
+
def to_dict(self) -> Dict:
|
|
7
|
+
"""
|
|
8
|
+
Serializes the swarm configuration to a dictionary.
|
|
9
|
+
|
|
10
|
+
Returns:
|
|
11
|
+
Dict: The serialized configuration as a dictionary.
|
|
12
|
+
"""
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
@abstractmethod
|
|
16
|
+
def to_json(self) -> str:
|
|
17
|
+
"""
|
|
18
|
+
Serializes the swarm configuration to a JSON string.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
str: The serialized configuration as a JSON string.
|
|
22
|
+
"""
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def to_pickle(self) -> bytes:
|
|
27
|
+
"""
|
|
28
|
+
Serializes the swarm configuration to a Pickle byte stream.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
bytes: The serialized configuration as a Pickle byte stream.
|
|
32
|
+
"""
|
|
33
|
+
pass
|