def _get_candidate_text_safe()

in aidial_adapter_vertexai/chat/gemini/adapter/vertex_lib.py [0:0]


def _get_candidate_text_safe(candidate: Candidate) -> str | None:
    # The text content of a candidate may be missing when function is called or
    # when the generation was terminated with SAFETY finish reason.
    try:
        return candidate.text
    except ValueError as e:
        log.debug(f"The Candidate doesn't have text: {e}")
        return None