GitHub

NameMapper

API reference for NameMapper.

Maps provider-defined tools' custom names to their provider names and back; other names map to themselves.

Attributes

AttributeTypeDescription
custom_namestuple[str, ...]
provider_namestuple[str, ...]

Functions

__init__

__init__(tools) -> None
ParameterTypeDescription
toolsSequence[AnyTool]
def __init__(self, tools: Sequence[AnyTool]) -> None:
    self._to_provider: dict[str, str] = {}
    self._to_custom: dict[str, str] = {}
    for tool in tools:
        if isinstance(tool, ProviderDefined):
            self._to_provider[tool.name] = tool.provider_name
            self._to_custom[tool.provider_name] = tool.name

get_custom_name

get_custom_name(provider_name) -> str
ParameterTypeDescription
provider_namestr

Returns str

def get_custom_name(self, provider_name: str) -> str:
    return self._to_custom.get(provider_name, provider_name)

get_provider_name

get_provider_name(custom_name) -> str
ParameterTypeDescription
custom_namestr

Returns str

def get_provider_name(self, custom_name: str) -> str:
    return self._to_provider.get(custom_name, custom_name)