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.
Files changed (114) hide show
  1. swarmauri_core/ComponentBase.py +163 -0
  2. swarmauri_core/__init__.py +11 -0
  3. swarmauri_core/agent_apis/IAgentCommands.py +83 -0
  4. swarmauri_core/agent_apis/IAgentRouterCRUD.py +56 -0
  5. swarmauri_core/agent_apis/__init__.py +4 -0
  6. swarmauri_core/agent_factories/IAgentFactory.py +79 -0
  7. swarmauri_core/agent_factories/IExportConf.py +40 -0
  8. swarmauri_core/agent_factories/__init__.py +0 -0
  9. swarmauri_core/agents/IAgent.py +12 -0
  10. swarmauri_core/agents/IAgentConversation.py +5 -0
  11. swarmauri_core/agents/IAgentParser.py +14 -0
  12. swarmauri_core/agents/IAgentRetrieve.py +4 -0
  13. swarmauri_core/agents/IAgentSystemContext.py +4 -0
  14. swarmauri_core/agents/IAgentToolkit.py +4 -0
  15. swarmauri_core/agents/IAgentVectorStore.py +4 -0
  16. swarmauri_core/agents/__init__.py +0 -0
  17. swarmauri_core/chains/ICallableChain.py +15 -0
  18. swarmauri_core/chains/IChain.py +75 -0
  19. swarmauri_core/chains/IChainContext.py +11 -0
  20. swarmauri_core/chains/IChainContextLoader.py +8 -0
  21. swarmauri_core/chains/IChainDependencyResolver.py +32 -0
  22. swarmauri_core/chains/IChainFactory.py +61 -0
  23. swarmauri_core/chains/IChainStep.py +7 -0
  24. swarmauri_core/chains/__init__.py +1 -0
  25. swarmauri_core/chunkers/IChunker.py +15 -0
  26. swarmauri_core/chunkers/__init__.py +0 -0
  27. swarmauri_core/conversations/IConversation.py +45 -0
  28. swarmauri_core/conversations/IMaxSize.py +4 -0
  29. swarmauri_core/conversations/ISystemContext.py +4 -0
  30. swarmauri_core/conversations/__init__.py +0 -0
  31. swarmauri_core/distances/IDistanceSimilarity.py +49 -0
  32. swarmauri_core/distances/__init__.py +0 -0
  33. swarmauri_core/document_stores/IDocumentRetrieve.py +25 -0
  34. swarmauri_core/document_stores/IDocumentStore.py +79 -0
  35. swarmauri_core/document_stores/__init__.py +0 -0
  36. swarmauri_core/documents/IDocument.py +4 -0
  37. swarmauri_core/documents/IExperimentDocument.py +120 -0
  38. swarmauri_core/documents/__init__.py +0 -0
  39. swarmauri_core/embeddings/IFeature.py +9 -0
  40. swarmauri_core/embeddings/ISaveModel.py +30 -0
  41. swarmauri_core/embeddings/IVectorize.py +26 -0
  42. swarmauri_core/embeddings/__init__.py +1 -0
  43. swarmauri_core/experiment_stores/IExperimentStore.py +72 -0
  44. swarmauri_core/experiment_stores/__init__.py +99 -0
  45. swarmauri_core/llms/IFit.py +13 -0
  46. swarmauri_core/llms/IPredict.py +13 -0
  47. swarmauri_core/llms/__init__.py +0 -0
  48. swarmauri_core/messages/IMessage.py +10 -0
  49. swarmauri_core/messages/__init__.py +1 -0
  50. swarmauri_core/metrics/IMetric.py +19 -0
  51. swarmauri_core/metrics/IMetricAggregate.py +16 -0
  52. swarmauri_core/metrics/IMetricCalculate.py +30 -0
  53. swarmauri_core/metrics/IThreshold.py +4 -0
  54. swarmauri_core/metrics/__init__.py +0 -0
  55. swarmauri_core/parsers/IParser.py +19 -0
  56. swarmauri_core/parsers/__init__.py +0 -0
  57. swarmauri_core/prompts/IPrompt.py +18 -0
  58. swarmauri_core/prompts/IPromptMatrix.py +30 -0
  59. swarmauri_core/prompts/ITemplate.py +46 -0
  60. swarmauri_core/prompts/__init__.py +0 -0
  61. swarmauri_core/schema_converters/ISchemaConvert.py +9 -0
  62. swarmauri_core/schema_converters/__init__.py +0 -0
  63. swarmauri_core/swarm_apis/IAgentRegistrationAPI.py +72 -0
  64. swarmauri_core/swarm_apis/ISwarmAPI.py +24 -0
  65. swarmauri_core/swarm_apis/__init__.py +0 -0
  66. swarmauri_core/swarms/ISwarm.py +67 -0
  67. swarmauri_core/swarms/ISwarmAgentRegistration.py +73 -0
  68. swarmauri_core/swarms/ISwarmChainCRUD.py +62 -0
  69. swarmauri_core/swarms/ISwarmComponent.py +13 -0
  70. swarmauri_core/swarms/ISwarmConfigurationExporter.py +33 -0
  71. swarmauri_core/swarms/ISwarmFactory.py +120 -0
  72. swarmauri_core/swarms/__init__.py +0 -0
  73. swarmauri_core/toolkits/IToolkit.py +44 -0
  74. swarmauri_core/toolkits/__init__.py +0 -0
  75. swarmauri_core/tools/IParameter.py +9 -0
  76. swarmauri_core/tools/ITool.py +12 -0
  77. swarmauri_core/tools/__init__.py +0 -0
  78. swarmauri_core/tracing/IChainTracer.py +25 -0
  79. swarmauri_core/tracing/ITraceContext.py +29 -0
  80. swarmauri_core/tracing/ITracer.py +45 -0
  81. swarmauri_core/tracing/__init__.py +0 -0
  82. swarmauri_core/typing.py +26 -0
  83. swarmauri_core/utils/ITransactional.py +24 -0
  84. swarmauri_core/utils/__init__.py +0 -0
  85. swarmauri_core/vector_stores/IAngleBetweenVectors.py +23 -0
  86. swarmauri_core/vector_stores/ICloudVectorStore.py +21 -0
  87. swarmauri_core/vector_stores/IDecompose.py +24 -0
  88. swarmauri_core/vector_stores/IDivergence.py +21 -0
  89. swarmauri_core/vector_stores/IGradient.py +22 -0
  90. swarmauri_core/vector_stores/IOrthogonalProject.py +21 -0
  91. swarmauri_core/vector_stores/IPersistentVectorStore.py +21 -0
  92. swarmauri_core/vector_stores/IProject.py +22 -0
  93. swarmauri_core/vector_stores/IReflect.py +21 -0
  94. swarmauri_core/vector_stores/ISimilarity.py +26 -0
  95. swarmauri_core/vector_stores/ISimiliarityQuery.py +19 -0
  96. swarmauri_core/vector_stores/IVectorArithmetic.py +31 -0
  97. swarmauri_core/vector_stores/IVectorBasisCheck.py +20 -0
  98. swarmauri_core/vector_stores/IVectorLinearCombination.py +21 -0
  99. swarmauri_core/vector_stores/IVectorNorm.py +49 -0
  100. swarmauri_core/vector_stores/IVectorRotate.py +24 -0
  101. swarmauri_core/vector_stores/IVectorSpan.py +21 -0
  102. swarmauri_core/vector_stores/IVectorStore.py +88 -0
  103. swarmauri_core/vector_stores/IVectorStoreRetrieve.py +26 -0
  104. swarmauri_core/vector_stores/IVectorStoreSaveLoad.py +45 -0
  105. swarmauri_core/vector_stores/__init__.py +0 -0
  106. swarmauri_core/vectors/IVector.py +10 -0
  107. swarmauri_core/vectors/IVectorMeta.py +28 -0
  108. swarmauri_core/vectors/IVectorProduct.py +66 -0
  109. swarmauri_core/vectors/IVectorTransform.py +49 -0
  110. swarmauri_core/vectors/__init__.py +0 -0
  111. swarmauri_core-0.5.0.dev1.dist-info/METADATA +26 -0
  112. swarmauri_core-0.5.0.dev1.dist-info/RECORD +114 -0
  113. swarmauri_core-0.5.0.dev1.dist-info/WHEEL +5 -0
  114. swarmauri_core-0.5.0.dev1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,120 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Callable, Dict, List, NamedTuple, Optional, Type, Union
3
+ from swarmauri.core.swarms.ISwarm import ISwarm
4
+ from swarmauri.core.chains.ICallableChain import ICallableChain
5
+ from swarmauri.core.agents.IAgent import IAgent
6
+
7
+ class Step(NamedTuple):
8
+ description: str
9
+ callable: Callable # Reference to the function to execute
10
+ args: Optional[List[Any]] = None
11
+ kwargs: Optional[Dict[str, Any]] = None
12
+
13
+ class CallableChainItem(NamedTuple):
14
+ key: str # Unique identifier for the item within the chain
15
+ execution_context: Dict[str, Any] # Execution context and metadata
16
+ steps: List[Step]
17
+
18
+ class AgentDefinition(NamedTuple):
19
+ type: str
20
+ configuration: Dict[str, Any]
21
+ capabilities: List[str]
22
+ dependencies: List[str]
23
+ execution_context: Dict[str, Any]
24
+
25
+ class FunctionParameter(NamedTuple):
26
+ name: str
27
+ type: Type
28
+ default: Optional[Any] = None
29
+ required: bool = True
30
+
31
+ class FunctionDefinition(NamedTuple):
32
+ identifier: str
33
+ parameters: List[FunctionParameter]
34
+ return_type: Type
35
+ execution_context: Dict[str, Any]
36
+ callable_source: Callable
37
+
38
+ class ISwarmFactory(ABC):
39
+
40
+ @abstractmethod
41
+ def create_swarm(self, *args, **kwargs) -> ISwarm:
42
+ """
43
+ Creates and returns a new swarm instance configured with the provided arguments.
44
+ """
45
+ pass
46
+
47
+ @abstractmethod
48
+ def create_agent(self, agent_definition: AgentDefinition) -> IAgent:
49
+ """
50
+ Creates a new agent based on the provided enhanced agent definition.
51
+
52
+ Args:
53
+ agent_definition: An instance of AgentDefinition detailing the agent's setup.
54
+
55
+ Returns:
56
+ An instance or identifier of the newly created agent.
57
+ """
58
+ pass
59
+
60
+ @abstractmethod
61
+ def create_callable_chain(self, chain_definition: List[CallableChainItem]) -> ICallableChain:
62
+ """
63
+ Creates a new callable chain based on the provided definition.
64
+
65
+ Args:
66
+ chain_definition: Details required to build the chain, such as sequence of functions and arguments.
67
+
68
+ Returns:
69
+ ICallableChain: The constructed callable chain instance.
70
+ """
71
+ pass
72
+
73
+ @abstractmethod
74
+ def register_function(self, function_definition: FunctionDefinition) -> None:
75
+ """
76
+ Registers a function within the factory ecosystem, making it available for callable chains and agents.
77
+
78
+ Args:
79
+ function_definition: An instance of FunctionDefinition detailing the function's specification.
80
+ """
81
+ pass
82
+
83
+ @abstractmethod
84
+ def export_callable_chains(self, format_type: str = 'json') -> Union[dict, str, bytes]:
85
+ """
86
+ Exports configurations of all callable chains in the specified format.
87
+ Supported formats: 'json', 'pickle'.
88
+
89
+ Args:
90
+ format_type (str): The format for exporting the configurations.
91
+
92
+ Returns:
93
+ Union[dict, str, bytes]: The callable chain configurations in the specified format.
94
+ """
95
+ pass
96
+
97
+ @abstractmethod
98
+ def load_callable_chains(self, chains_data, format_type: str = 'json'):
99
+ """
100
+ Loads callable chain configurations from given data.
101
+
102
+ Args:
103
+ chains_data (Union[dict, str, bytes]): Data containing callable chain configurations.
104
+ format_type (str): The format of the provided chains data.
105
+ """
106
+ pass
107
+
108
+ @abstractmethod
109
+ def export_configuration(self, format_type: str = 'json') -> Union[dict, str, bytes]:
110
+ """
111
+ Exports the swarm's and agents' configurations in the specified format.
112
+ Supported formats: 'json', 'pickle'. Default is 'json'.
113
+
114
+ Args:
115
+ format_type (str): The format for exporting the configurations.
116
+
117
+ Returns:
118
+ Union[dict, str, bytes]: The configurations in the specified format.
119
+ """
120
+ pass
File without changes
@@ -0,0 +1,44 @@
1
+ from typing import Dict
2
+ from abc import ABC, abstractmethod
3
+ from swarmauri.core.tools.ITool import ITool
4
+
5
+ class IToolkit(ABC):
6
+ """
7
+ A class representing a toolkit used by Swarm Agents.
8
+ Tools are maintained in a dictionary keyed by the tool's name.
9
+ """
10
+
11
+ @abstractmethod
12
+ def add_tools(self, tools: Dict[str, ITool]):
13
+ """
14
+ An abstract method that should be implemented by subclasses to add multiple tools to the toolkit.
15
+ """
16
+ pass
17
+
18
+ @abstractmethod
19
+ def add_tool(self, tool: ITool):
20
+ """
21
+ An abstract method that should be implemented by subclasses to add a single tool to the toolkit.
22
+ """
23
+ pass
24
+
25
+ @abstractmethod
26
+ def remove_tool(self, tool_name: str):
27
+ """
28
+ An abstract method that should be implemented by subclasses to remove a tool from the toolkit by name.
29
+ """
30
+ pass
31
+
32
+ @abstractmethod
33
+ def get_tool_by_name(self, tool_name: str) -> ITool:
34
+ """
35
+ An abstract method that should be implemented by subclasses to retrieve a tool from the toolkit by name.
36
+ """
37
+ pass
38
+
39
+ @abstractmethod
40
+ def __len__(self) -> int:
41
+ """
42
+ An abstract method that should be implemented by subclasses to return the number of tools in the toolkit.
43
+ """
44
+ pass
File without changes
@@ -0,0 +1,9 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List, Union
3
+
4
+ class IParameter(ABC):
5
+ """
6
+ An abstract class to represent a parameter for a tool.
7
+ """
8
+
9
+ pass
@@ -0,0 +1,12 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Dict, Any
3
+
4
+
5
+ class ITool(ABC):
6
+ @abstractmethod
7
+ def call(self, *args, **kwargs):
8
+ pass
9
+
10
+ @abstractmethod
11
+ def __call__(self, *args, **kwargs) -> Dict[str, Any]:
12
+ pass
File without changes
@@ -0,0 +1,25 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Callable, List, Tuple, Dict, Any
3
+
4
+ class IChainTracer(ABC):
5
+ """
6
+ Interface for a tracer supporting method chaining through a list of tuples.
7
+ Each tuple in the list contains: trace context, function, args, and kwargs.
8
+ """
9
+
10
+ @abstractmethod
11
+ def process_chain(self, chain: List[Tuple[Any, Callable[..., Any], List[Any], Dict[str, Any]]]) -> "IChainTracer":
12
+ """
13
+ Processes a sequence of operations defined in a chain.
14
+
15
+ Args:
16
+ chain (List[Tuple[Any, Callable[..., Any], List[Any], Dict[str, Any]]]): A list where each tuple contains:
17
+ - The trace context or reference required by the function.
18
+ - The function (method of IChainTracer) to execute.
19
+ - A list of positional arguments for the function.
20
+ - A dictionary of keyword arguments for the function.
21
+
22
+ Returns:
23
+ IChainTracer: Returns self to allow further method chaining.
24
+ """
25
+ pass
@@ -0,0 +1,29 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any
3
+
4
+ class ITraceContext(ABC):
5
+ """
6
+ Interface for a trace context, representing a single trace instance.
7
+ This context carries the state and metadata of the trace across different system components.
8
+ """
9
+
10
+ @abstractmethod
11
+ def get_trace_id(self) -> str:
12
+ """
13
+ Retrieves the unique identifier for this trace.
14
+
15
+ Returns:
16
+ str: The unique trace identifier.
17
+ """
18
+ pass
19
+
20
+ @abstractmethod
21
+ def add_attribute(self, key: str, value: Any):
22
+ """
23
+ Adds or updates an attribute associated with this trace.
24
+
25
+ Args:
26
+ key (str): The attribute key or name.
27
+ value (Any): The value of the attribute.
28
+ """
29
+ pass
@@ -0,0 +1,45 @@
1
+ from swarmauri.core.tracing.ITraceContext import ITraceContext
2
+ from abc import ABC, abstractmethod
3
+ from typing import Optional, Dict, Any
4
+
5
+
6
+ class ITracer(ABC):
7
+ """
8
+ Interface for implementing distributed tracing across different components of the system.
9
+ """
10
+
11
+ @abstractmethod
12
+ def start_trace(self, name: str, initial_attributes: Optional[Dict[str, Any]] = None) -> ITraceContext:
13
+ """
14
+ Starts a new trace with a given name and optional initial attributes.
15
+
16
+ Args:
17
+ name (str): Name of the trace, usually represents the operation being traced.
18
+ initial_attributes (Optional[Dict[str, Any]]): Key-value pairs to be attached to the trace initially.
19
+
20
+ Returns:
21
+ ITraceContext: A context object representing this particular trace instance.
22
+ """
23
+ pass
24
+
25
+ @abstractmethod
26
+ def end_trace(self, trace_context: ITraceContext):
27
+ """
28
+ Marks the end of a trace, completing its lifecycle and recording its details.
29
+
30
+ Args:
31
+ trace_context (ITraceContext): The trace context to be ended.
32
+ """
33
+ pass
34
+
35
+ @abstractmethod
36
+ def annotate_trace(self, trace_context: ITraceContext, key: str, value: Any):
37
+ """
38
+ Adds an annotation to an existing trace, enriching it with more detailed information.
39
+
40
+ Args:
41
+ trace_context (ITraceContext): The trace context to annotate.
42
+ key (str): The key or name of the annotation.
43
+ value (Any): The value of the annotation.
44
+ """
45
+ pass
File without changes
@@ -0,0 +1,26 @@
1
+ import logging
2
+ from pydantic import BaseModel, Field
3
+ from typing import TypeVar, Generic, Union, Annotated, Type
4
+
5
+
6
+ class SubclassUnion:
7
+
8
+ @classmethod
9
+ def __class_getitem__(cls, baseclass):
10
+ subclasses = cls.__swm__get_subclasses__(baseclass)
11
+ return Union[tuple(subclasses)]
12
+
13
+ @classmethod
14
+ def __swm__get_subclasses__(cls, baseclass) -> set:
15
+ logging.debug('__swm__get_subclasses__ executed\n')
16
+ def is_excluded_module(module_name: str) -> bool:
17
+ return (module_name == 'builtins' or
18
+ module_name == 'types')
19
+
20
+ subclasses_dict = {baseclass.__name__: baseclass}
21
+ for subclass in baseclass.__subclasses__():
22
+ if not is_excluded_module(subclass.__module__):
23
+ subclasses_dict.update({_s.__name__: _s for _s in cls.__swm__get_subclasses__(subclass)
24
+ if not is_excluded_module(_s.__module__)})
25
+
26
+ return set(subclasses_dict.values())
@@ -0,0 +1,24 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+ class ITransactional(ABC):
4
+
5
+ @abstractmethod
6
+ def begin_transaction(self):
7
+ """
8
+ Initiates a transaction for a series of vector store operations.
9
+ """
10
+ pass
11
+
12
+ @abstractmethod
13
+ def commit_transaction(self):
14
+ """
15
+ Commits the current transaction, making all operations within the transaction permanent.
16
+ """
17
+ pass
18
+
19
+ @abstractmethod
20
+ def abort_transaction(self):
21
+ """
22
+ Aborts the current transaction, reverting all operations performed within the transaction.
23
+ """
24
+ pass
File without changes
@@ -0,0 +1,23 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List
3
+
4
+ class IAngleBetweenVectors(ABC):
5
+ """
6
+ Interface for calculating the angle between two vectors.
7
+ """
8
+
9
+ @abstractmethod
10
+ def angle_between(self, vector_a: List[float], vector_b: List[float]) -> float:
11
+ """
12
+ Method to calculate and return the angle in radians between two vectors.
13
+
14
+ Parameters:
15
+ - vector_a (List[float]): The first vector as a list of floats.
16
+ - vector_b (List[float]): The second vector as a list of floats.
17
+
18
+ Returns:
19
+ - float: The angle between vector_a and vector_b in radians.
20
+
21
+ Note: Implementations should handle the vectors' dimensionality and throw appropriate exceptions for incompatible vectors.
22
+ """
23
+ pass
@@ -0,0 +1,21 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+
4
+ class ICloudVectorStore(ABC):
5
+ """
6
+ Interface for a cloud-based vector store responsible for storing, indexing, and retrieving documents.
7
+ """
8
+
9
+ @abstractmethod
10
+ def connect(self) -> None:
11
+ """
12
+ Connects to the cloud-based vector store using provided credentials.
13
+ """
14
+ pass
15
+
16
+ @abstractmethod
17
+ def disconnect(self) -> None:
18
+ """
19
+ Disconnects from the cloud-based vector store.
20
+ """
21
+ pass
@@ -0,0 +1,24 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Tuple, List
3
+ from swarmauri.core.vectors.IVector import IVector # Assuming there's a base IVector interface for vector representations
4
+
5
+ class IDecompose(ABC):
6
+ """
7
+ Interface for decomposing a vector into components along specified basis vectors.
8
+ This operation is essential in expressing a vector in different coordinate systems or reference frames.
9
+ """
10
+
11
+ @abstractmethod
12
+ def decompose(self, vector: IVector, basis_vectors: List[IVector]) -> List[IVector]:
13
+ """
14
+ Decompose the given vector into components along the specified basis vectors.
15
+
16
+ Parameters:
17
+ - vector (IVector): The vector to be decomposed.
18
+ - basis_vectors (List[IVector]): A list of basis vectors along which to decompose the given vector.
19
+
20
+ Returns:
21
+ - List[IVector]: A list of vectors, each representing the component of the decomposed vector along
22
+ the corresponding basis vector in the `basis_vectors` list.
23
+ """
24
+ pass
@@ -0,0 +1,21 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List
3
+
4
+ class IDivergence(ABC):
5
+ """
6
+ Interface for calculating the divergence of a vector field.
7
+ """
8
+
9
+ @abstractmethod
10
+ def calculate_divergence(self, vector_field: List[List[float]], point: List[float]) -> float:
11
+ """
12
+ Calculate the divergence of a vector field at a specific point.
13
+
14
+ Parameters:
15
+ - vector_field (List[List[float]]): A representation of the vector field as a list of vectors.
16
+ - point (List[float]): The point at which the divergence is to be calculated.
17
+
18
+ Returns:
19
+ - float: The divergence value at the specified point.
20
+ """
21
+ pass
@@ -0,0 +1,22 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List, Callable
3
+
4
+ class IGradient(ABC):
5
+ """
6
+ Interface for calculating the gradient of a scalar field.
7
+ """
8
+
9
+ @abstractmethod
10
+ def calculate_gradient(self, scalar_field: Callable[[List[float]], float], point: List[float]) -> List[float]:
11
+ """
12
+ Calculate the gradient of a scalar field at a specific point.
13
+
14
+ Parameters:
15
+ - scalar_field (Callable[[List[float]], float]): The scalar field represented as a function
16
+ that takes a point and returns a scalar value.
17
+ - point (List[float]): The point at which the gradient is to be calculated.
18
+
19
+ Returns:
20
+ - List[float]: The gradient vector at the specified point.
21
+ """
22
+ pass
@@ -0,0 +1,21 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List
3
+
4
+ class IOrthogonalProject(ABC):
5
+ """
6
+ Interface for calculating the orthogonal projection of one vector onto another.
7
+ """
8
+
9
+ @abstractmethod
10
+ def orthogonal_project(self, vector_a: List[float], vector_b: List[float]) -> List[float]:
11
+ """
12
+ Calculates the orthogonal projection of vector_a onto vector_b.
13
+
14
+ Args:
15
+ vector_a (List[float]): The vector to be projected.
16
+ vector_b (List[float]): The vector onto which vector_a is orthogonally projected.
17
+
18
+ Returns:
19
+ List[float]: The orthogonal projection of vector_a onto vector_b.
20
+ """
21
+ pass
@@ -0,0 +1,21 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+
4
+ class IPersistentVectorStore(ABC):
5
+ """
6
+ Interface for a persitent-based vector store responsible for storing, indexing, and retrieving documents.
7
+ """
8
+
9
+ @abstractmethod
10
+ def connect(self) -> None:
11
+ """
12
+ Connects to the persistent-based vector store using provided credentials.
13
+ """
14
+ pass
15
+
16
+ @abstractmethod
17
+ def disconnect(self) -> None:
18
+ """
19
+ Disconnects from the persistent-based vector store.
20
+ """
21
+ pass
@@ -0,0 +1,22 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List
3
+
4
+ class IProject(ABC):
5
+ """
6
+ Interface for projecting one vector onto another.
7
+ """
8
+
9
+ @abstractmethod
10
+ def project(self, vector_a: List[float], vector_b: List[float]) -> List[float]:
11
+ """
12
+ Projects vector_a onto vector_b.
13
+
14
+ Args:
15
+ vector_a (List[float]): The vector to be projected.
16
+ vector_b (List[float]): The vector onto which vector_a is projected.
17
+
18
+ Returns:
19
+ List[float]: The projection of vector_a onto vector_b.
20
+ """
21
+ pass
22
+
@@ -0,0 +1,21 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List
3
+
4
+ class IReflect(ABC):
5
+ """
6
+ Interface for reflecting a vector across a specified plane or axis.
7
+ """
8
+
9
+ @abstractmethod
10
+ def reflect_vector(self, vector: List[float], normal: List[float]) -> List[float]:
11
+ """
12
+ Reflects a vector across a plane or axis defined by a normal vector.
13
+
14
+ Parameters:
15
+ - vector (List[float]): The vector to be reflected.
16
+ - normal (List[float]): The normal vector of the plane across which the vector will be reflected.
17
+
18
+ Returns:
19
+ - List[float]: The reflected vector.
20
+ """
21
+ pass
@@ -0,0 +1,26 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List, Tuple
3
+ from swarmauri.core.vectors.IVector import IVector
4
+
5
+ class ISimilarity(ABC):
6
+ """
7
+ Interface to define operations for computing similarity and distance between vectors.
8
+ This interface is crucial for systems that need to perform similarity searches, clustering,
9
+ or any operations where vector similarity plays a key role.
10
+ """
11
+
12
+ @abstractmethod
13
+ def similarity(self, vector_a: IVector, vector_b: IVector) -> float:
14
+ """
15
+ Compute the similarity between two vectors. The definition of similarity (e.g., cosine similarity)
16
+ should be implemented in concrete classes.
17
+
18
+ Args:
19
+ vector_a (IVector): The first vector.
20
+ vector_b (IVector): The second vector to compare with the first vector.
21
+
22
+ Returns:
23
+ float: A similarity score between vector_a and vector_b.
24
+ """
25
+ pass
26
+
@@ -0,0 +1,19 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List, Dict
3
+
4
+ class ISimilarityQuery(ABC):
5
+
6
+ @abstractmethod
7
+ def search_by_similarity_threshold(self, query_vector: List[float], similarity_threshold: float, space_name: str = None) -> List[Dict]:
8
+ """
9
+ Search vectors exceeding a similarity threshold to a query vector within an optional vector space.
10
+
11
+ Args:
12
+ query_vector (List[float]): The high-dimensional query vector.
13
+ similarity_threshold (float): The similarity threshold for filtering results.
14
+ space_name (str, optional): The name of the vector space to search within.
15
+
16
+ Returns:
17
+ List[Dict]: A list of dictionaries with vector IDs, similarity scores, and optional metadata that meet the similarity threshold.
18
+ """
19
+ pass
@@ -0,0 +1,31 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List
3
+
4
+ class IVectorArithmetic(ABC):
5
+ @abstractmethod
6
+ def add(self, vector1: List[float], vector2: List[float]) -> List[float]:
7
+ """
8
+ Vector addition of 'vector1' and 'vector2'.
9
+ """
10
+ pass
11
+
12
+ @abstractmethod
13
+ def subtract(self, vector1: List[float], vector2: List[float]) -> List[float]:
14
+ """
15
+ Vector subtraction of 'vector1' - 'vector2'.
16
+ """
17
+ pass
18
+
19
+ @abstractmethod
20
+ def multiply(self, vector: List[float], scalar: float) -> List[float]:
21
+ """
22
+ Scalar multiplication of 'vector' by 'scalar'.
23
+ """
24
+ pass
25
+
26
+ @abstractmethod
27
+ def divide(self, vector: List[float], scalar: float) -> List[float]:
28
+ """
29
+ Scalar division of 'vector' by 'scalar'.
30
+ """
31
+ pass
@@ -0,0 +1,20 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import List, Any
3
+
4
+ class IVectorBasisCheck(ABC):
5
+ """
6
+ Interface for checking if a given set of vectors forms a basis of the vector space.
7
+ """
8
+
9
+ @abstractmethod
10
+ def is_basis(self, vectors: List[Any]) -> bool:
11
+ """
12
+ Determines whether the given set of vectors forms a basis for their vector space.
13
+
14
+ Parameters:
15
+ - vectors (List[Any]): A list of vectors to be checked.
16
+
17
+ Returns:
18
+ - bool: True if the vectors form a basis, False otherwise.
19
+ """
20
+ pass