from hermes_brain_v4 import preguntar_hermes_v4

def preguntar_hermes_panel(pregunta, usuario, sesion):
    resultado = preguntar_hermes_v4(
        pregunta,
        usuario,
        sesion
    )

    if not isinstance(resultado, dict):
        raise RuntimeError("Respuesta V4 inválida")

    respuesta = resultado.get("respuesta", "")

    if not isinstance(respuesta, str) or not respuesta.strip():
        raise RuntimeError("Hermes no devolvió texto")

    return respuesta
