Skip to content

Class swarmauri_core.ensembles.IEnsemble.IEnsemble

swarmauri_core.ensembles.IEnsemble.IEnsemble

Bases: ABC

Interface for routing predictions across multiple providers.

add_model abstractmethod

add_model(name, model)

Add a provider to the ensemble.

Source code in swarmauri_core/ensembles/IEnsemble.py
10
11
12
13
@abstractmethod
def add_model(self, name: str, model: IPredict) -> None:
    """Add a provider to the ensemble."""
    pass

remove_model abstractmethod

remove_model(name)

Remove a provider from the ensemble.

Source code in swarmauri_core/ensembles/IEnsemble.py
15
16
17
18
@abstractmethod
def remove_model(self, name: str) -> bool:
    """Remove a provider from the ensemble."""
    pass

list_models abstractmethod

list_models()

Return the registered providers.

Source code in swarmauri_core/ensembles/IEnsemble.py
20
21
22
23
@abstractmethod
def list_models(self) -> Dict[str, IPredict]:
    """Return the registered providers."""
    pass

route_by_provider abstractmethod

route_by_provider(provider, prompt, **kwargs)

Route a request to a specific provider.

Source code in swarmauri_core/ensembles/IEnsemble.py
25
26
27
28
@abstractmethod
def route_by_provider(self, provider: str, prompt: str, **kwargs: Any) -> Any:
    """Route a request to a specific provider."""
    pass

aroute_by_provider abstractmethod async

aroute_by_provider(provider, prompt, **kwargs)

Asynchronously route a request to a specific provider.

Source code in swarmauri_core/ensembles/IEnsemble.py
30
31
32
33
34
35
@abstractmethod
async def aroute_by_provider(
    self, provider: str, prompt: str, **kwargs: Any
) -> Any:
    """Asynchronously route a request to a specific provider."""
    pass

route abstractmethod

route(prompt, **kwargs)

Route a request to a chosen provider.

Source code in swarmauri_core/ensembles/IEnsemble.py
37
38
39
40
@abstractmethod
def route(self, prompt: str, **kwargs: Any) -> Any:
    """Route a request to a chosen provider."""
    pass

aroute abstractmethod async

aroute(prompt, **kwargs)

Asynchronously route a request to a chosen provider.

Source code in swarmauri_core/ensembles/IEnsemble.py
42
43
44
45
@abstractmethod
async def aroute(self, prompt: str, **kwargs: Any) -> Any:
    """Asynchronously route a request to a chosen provider."""
    pass

broadcast abstractmethod

broadcast(prompt, **kwargs)

Send a request to all providers and return their responses.

Source code in swarmauri_core/ensembles/IEnsemble.py
47
48
49
50
@abstractmethod
def broadcast(self, prompt: str, **kwargs: Any) -> Dict[str, Any]:
    """Send a request to all providers and return their responses."""
    pass

abroadcast abstractmethod async

abroadcast(prompt, **kwargs)

Asynchronously broadcast a request to all providers.

Source code in swarmauri_core/ensembles/IEnsemble.py
52
53
54
55
@abstractmethod
async def abroadcast(self, prompt: str, **kwargs: Any) -> Dict[str, Any]:
    """Asynchronously broadcast a request to all providers."""
    pass