Skip to content
Back to top
View this page

# mindroot.lib.providers package

## Subpackages

- mindroot.lib.providers.backup package
  - Module contents

## Submodules

## mindroot.lib.providers.commands module

mindroot.lib.providers.commands.command(*, flags=[])

## mindroot.lib.providers.hooks module

mindroot.lib.providers.hooks.hook()

## mindroot.lib.providers.missing module

async mindroot.lib.providers.missing.get_missing_commands(agent_name=None, context=None)

  Identify commands that are used in agent instructions but not available in the system.

  Parameters:

    agent_name (str, optional) – Name of the agent to check

  Returns:

    Mapping of missing commands and potential plugins that provide them

  Return type:

    dict

## mindroot.lib.providers.model_preferences_v2 module

class mindroot.lib.providers.model_preferences_v2.ModelPreferencesV2

  Bases: `object`

  New model preferences system supporting ordered provider/model pairs for fallback selection.

  add_preference(service: str, provider: str, model: str, position: int | None = None) → None

    Add a provider/model preference for a service at specified position (or end).

  ensure_preferences_exist() → None

    Copy template preferences file to data directory if it doesn’t exist.

  get_ordered_providers_for_service(service_name: str) → List[Tuple[str, str]]

    Get ordered list of (provider, model) pairs for a service.

  get_preferences() → Dict[str, List[List[str]]]

    Get preferences in new format: {service: [[provider, model], …]}

  migrate_from_old_format(old_preferences: List[Dict]) → Dict[str, List[List[str]]]

    Convert old format preferences to new format.

    Old format: [{“service_or_command_name”: “stream_chat”, “flag”: “default”, “model”: “claude-3”}] New format: {“stream_chat”: [[“ah_anthropic”, “claude-3.5-sonnet”]]}

  remove_preference(service: str, provider: str, model: str) → bool

    Remove a provider/model preference for a service. Returns True if removed.

  reorder_preferences(service: str, ordered_pairs: List[List[str]]) → None

    Set the complete ordered list of provider/model pairs for a service.

  save_preferences(preferences: Dict[str, List[List[str]]]) → None

    Save preferences in new format.

## mindroot.lib.providers.services module

mindroot.lib.providers.services.service(*, flags=[])

mindroot.lib.providers.services.service_class(protocol: Type[P], *, flags=[])

  Class decorator that registers all Protocol methods as services.

  This enables class-based service implementations with IDE autocomplete when inheriting from a Protocol.

  Parameters:

    - protocol – The Protocol class being implemented. Only methods defined in this Protocol will be registered as services.

    - flags – Optional flags to pass to each service registration.

  Example

  from mindroot.services import service_class from mindroot.protocols import LLM

  @service_class(LLM) class DeepSeekLLM(LLM):

  > async def stream_chat(self, model: str, messages: list = None,

  >   > context = None, …) -> AsyncIterator[str]:

  >   # IDE autocomplete works here! …

  > async def format_image_message(self, pil_image, context = None) -> dict:

  >   …

  The decorator will: 1. Instantiate the class (must have no required __init__ args) 2. Find all methods that are defined in the Protocol 3. Register each matching method as a service

## Module contents

class mindroot.lib.providers.HookManager

  Bases: `object`

  async execute_hooks(name, *args, **kwargs)
  get_docstring(name)
  get_docstrings()
  get_hooks()
  register_hook(name, implementation, signature, docstring)

class mindroot.lib.providers.ProviderManager

  Bases: `object`

  async exec_with_provider(name, provider, *args, **kwargs)
  async execute(name, *args, **kwargs)
  get_detailed_functions()
  get_docstring(name)
  get_docstrings()
  get_functions()
  get_some_docstrings(names)
  register_function(name, provider, implementation, signature, docstring, flags)