gen_ai_hub.evaluations.credentials module

gen_ai_hub.evaluations.credentials.get_home() str
gen_ai_hub.evaluations.credentials.get_nested_value(data_dict, keys: List[str])

Retrieve a nested value from a dictionary using a list of strings.

Parameters:
  • data_dict – The dictionary to search.

  • keys – A list of strings representing nested keys.

Returns:

The value associated with the nested keys, or None if not found.

class gen_ai_hub.evaluations.credentials.VCAPEnvironment(services: 'List[Service]')

Bases: object

services: List[Service]
classmethod from_env(env_var: str | None = None)
classmethod from_dict(env: Dict[str, Any])
get_service(label, exactly_one: bool = True) Service
get_service_by_name(name, exactly_one: bool = True) Service
__init__(services: List[Service]) None
class gen_ai_hub.evaluations.credentials.Service(env: Dict[str, Any])

Bases: object

__init__(env: Dict[str, Any])
property label: str | None
property name: str | None
get(key, default=<object object>)
class gen_ai_hub.evaluations.credentials.CredentialsValue(name: 'str', vcap_key: 'Optional[Tuple[str, ...]]' = None, transform_fn: 'Optional[Callable]' = None)

Bases: object

name: str
vcap_key: Tuple[str, ...] | None = None
transform_fn: Callable | None = None
__init__(name: str, vcap_key: Tuple[str, ...] | None = None, transform_fn: Callable | None = None) None
class gen_ai_hub.evaluations.credentials.Source(name: 'str', get: 'Callable[[CredentialsValue], Optional[str]]')

Bases: object

name: str
get: Callable[[CredentialsValue], str | None]
__init__(name: str, get: Callable[[CredentialsValue], str | None]) None
gen_ai_hub.evaluations.credentials.init_conf(profile: str = None)
gen_ai_hub.evaluations.credentials.extract_credentials(source: Source, exclude: List[str] = None) Dict[str, str]

Extract all credentials from a source.

gen_ai_hub.evaluations.credentials.resolve_credentials(sources: List[Source]) Dict[str, str]

Extract credentials from the first source that has any defined.

gen_ai_hub.evaluations.credentials.resolve_resource_group(sources: List[Source]) str | None

Find resource_group from the first source that defines it.

gen_ai_hub.evaluations.credentials.validate_credentials(credentials: Dict[str, str]) None

Validate that we have a complete authentication method.

gen_ai_hub.evaluations.credentials.fetch_credentials(profile: str = None, **kwargs) Dict[str, str]

Fetch credentials from a single source based on precedence.

Precedence order: kwargs > environment variables > config file > VCAP service

Once a source is selected (first one with any credential), all credentials come from that source only. Resource group is an exception and follows precedence independently.