Skip to main content

Functions

FUNC get_adapter_for_intrinsic

get_adapter_for_intrinsic(intrinsic_name: str, intrinsic_adapter_types: list[AdapterType] | tuple[AdapterType, ...], available_adapters: dict[str, T]) -> T | None
Finds an adapter from a dict of available adapters based on the intrinsic name and its allowed adapter types. Args:
  • repo_id: Name of Hugging Face Hub repository containing the adapters that implement the intrinsic
  • intrinsic_name: the name of the intrinsic, like “answerability”
  • intrinsic_adapter_types: the adapter types allowed for this intrinsic, like ALORA / LORA
  • available_adapters: the available adapters to choose from; maps adapter.qualified_name to the Adapter
Returns:
  • an Adapter if found; else None

Classes

CLASS Adapter

An adapter that can be added to a single backend.

CLASS OpenAIAdapter

Adapter for OpenAIBackends.
Methods:

FUNC get_open_ai_path

get_open_ai_path(self, base_model_name: str, server_type: _ServerType = _ServerType.LOCALHOST, remote_path: str | None = None) -> str
Returns the path needed to load the adapter. Args:
  • base_model_name: the base model; typically the last part of the huggingface model id like “granite-3.3-8b-instruct”
  • server_type: the server type (ie LOCALHOST / OPENAI); usually the backend has information on this
  • remote_path: optional; used only if the server_type is REMOTE_VLLM; base path at which to find the adapter

CLASS LocalHFAdapter

Adapter for LocalHFBackends.
Methods:

FUNC get_local_hf_path

get_local_hf_path(self, base_model_name: str) -> str
Returns the path needed to load the adapter. Args:
  • base_model_name: the base model; typically the last part of the huggingface model id like “granite-3.3-8b-instruct”

CLASS GraniteCommonAdapter

Adapter for intrinsics that utilize the granite-common library.
Methods:

FUNC get_open_ai_path

get_open_ai_path(self, base_model_name: str, server_type: _ServerType = _ServerType.LOCALHOST, remote_path: str | None = None) -> str
Returns the path needed to load the adapter. Args:
  • base_model_name: the base model; typically the last part of the huggingface model id like “granite-3.3-8b-instruct”
  • server_type: the server type (ie LOCALHOST / OPENAI); usually the backend has information on this
  • remote_path: optional; used only if the server_type is REMOTE_VLLM; base path at which to find the adapter

FUNC get_local_hf_path

get_local_hf_path(self, base_model_name: str) -> str
Returns the path needed to load the adapter. Args:
  • base_model_name: the base model; typically the last part of the huggingface model id like “granite-3.3-8b-instruct”

FUNC download_and_get_path

download_and_get_path(self, base_model_name: str) -> str
Downloads the required rag intrinsics files if necessary and returns the path to them. Args:
  • base_model_name: the base model; typically the last part of the huggingface model id like “granite-3.3-8b-instruct”
Returns:
  • a path to the files

FUNC get_path_on_remote

get_path_on_remote(self, base_model_name: str, base_path: str) -> str
Assumes the files have already been downloaded on the remote server.

CLASS AdapterMixin

Mixin class for backends capable of utilizing adapters.
Methods:

FUNC base_model_name

base_model_name(self) -> str
Returns the base_model_id of the model used by the backend. For example, granite-3.3-8b-instruct for ibm-granite/granite-3.3-8b-instruct.

FUNC add_adapter

add_adapter(self, *args, **kwargs)
Adds the given adapter to the backend. Must not have been added to a different backend.

FUNC load_adapter

load_adapter(self, adapter_qualified_name: str)
Loads the given adapter for the backend. Must have previously been added.

FUNC unload_adapter

unload_adapter(self, adapter_qualified_name: str)
Unloads the given adapter from the backend.

FUNC list_adapters

list_adapters(self) -> list[str]
Lists the adapters added via add_adapter(). :returns: list of adapter names that are currently registered with this backend