- ASP.NET Core 9 Razor Pages + Minimal API hybrid - 14 validators (CPF, CEP, CNPJ, email, phone, name, yes-no, birthdate, handoff, cancel-intent, company-name, plate-br, postal-code, validate_reply) - OAuth login (Google, Microsoft, GitHub) + cookie auth - MongoDB usage tracking + CEP cache collection - Stripe checkout with inline PriceData (no Price IDs) - MCP server for Claude Code / Cursor integration - Playground (10 calls/IP/day, no auth) - Docs: Quickstart, API Reference, N8N, MCP, Créditos, Erros, Fluxos - Credit system: 3 cr standard validators, 5 cr validate_reply - SmartSuggestion: contextual re-ask via IA when obtained=false - Per-IP rate limiting + daily cap + shared-IP abuse detection - Lightbox for comic images - Validadores page split: Brasileiros / Universais + Em breve Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
namespace Nalu.Web.Services.LlmRouter;
|
|
|
|
public class LlmRouter(IReadOnlyList<ILlmProvider> providers, ILogger<LlmRouter> logger) : ILlmRouter
|
|
{
|
|
public async Task<LlmResponse> CompleteAsync(LlmRequest request, CancellationToken ct)
|
|
{
|
|
foreach (var provider in providers)
|
|
{
|
|
try
|
|
{
|
|
return await provider.CompleteAsync(request, ct);
|
|
}
|
|
catch (RateLimitException ex)
|
|
{
|
|
logger.LogWarning("Provider {Provider} rate limited, trying next", ex.Provider);
|
|
}
|
|
catch (TimeoutException)
|
|
{
|
|
logger.LogWarning("Provider {Provider} timed out, trying next", provider.Name);
|
|
}
|
|
catch (Exception ex) when (ex is not OperationCanceledException)
|
|
{
|
|
logger.LogWarning(ex, "Provider {Provider} failed, trying next", provider.Name);
|
|
}
|
|
}
|
|
|
|
throw new ServiceUnavailableException("All LLM providers unavailable");
|
|
}
|
|
}
|