Add perplexity support. Address underflow with a safe_log function