NumPy allowed · plain Python earns 10 bonus points
Softmax(logits) → probability distribution
Maintain high availability across LLM APIs by automatically failing over across primary and secondary model providers.
Implement execute_fallback_cascade(providers, request). Iterate through providers in order. For each provider, accumulate latency_ms. If fail_rate_limit or fail_server_error is True, record the failure attempt and proceed to the next provider. On the first provider without failure flags, record successful attempt and return {'successful_provider': name, 'response': response_text, 'attempts': attempts, 'total_latency_ms': total_latency}. If all fail, raise RuntimeError('All providers in fallback cascade failed'). If providers is empty, raise ValueError.
execute_fallback_cascade(providers: list[dict], request: dict) -> dict