- 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>
56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
namespace Nalu.Web.Services;
|
|
|
|
/// <summary>
|
|
/// Credit cost per validator. 1 = deterministic, 2 = light LLM, 5 = heavy LLM (70B context-aware).
|
|
/// </summary>
|
|
public static class CreditCosts
|
|
{
|
|
private static readonly Dictionary<string, int> _costs = new(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
// 1 credit — deterministic
|
|
["validate_cpf"] = 1,
|
|
["validate_cep"] = 1,
|
|
["validate_cnpj"] = 1,
|
|
["validate_email"] = 1,
|
|
["validate_phone_br"] = 1,
|
|
["validate_plate_br"] = 1,
|
|
["validate_postal_code"]= 1,
|
|
|
|
// 2 credits — light LLM
|
|
["validate_full_name"] = 2,
|
|
["validate_yes_no"] = 2,
|
|
["validate_birthdate"] = 2,
|
|
["validate_handoff"] = 2,
|
|
["validate_cancel_intent"] = 2,
|
|
["validate_company_name"] = 2,
|
|
|
|
// 5 credits — heavy LLM (validate_reply)
|
|
["validate_reply"] = 5,
|
|
};
|
|
|
|
public static int Get(string validatorId) =>
|
|
_costs.TryGetValue(validatorId, out var cost) ? cost : 1;
|
|
|
|
// Endpoint aliases → validator IDs
|
|
private static readonly Dictionary<string, string> _aliases = new(StringComparer.OrdinalIgnoreCase)
|
|
{
|
|
["name"] = "validate_full_name",
|
|
["cpf"] = "validate_cpf",
|
|
["cep"] = "validate_cep",
|
|
["phone"] = "validate_phone_br",
|
|
["email"] = "validate_email",
|
|
["postal-code"] = "validate_postal_code",
|
|
["yes-no"] = "validate_yes_no",
|
|
["birthdate"] = "validate_birthdate",
|
|
["handoff"] = "validate_handoff",
|
|
["cancel-intent"]= "validate_cancel_intent",
|
|
["cnpj"] = "validate_cnpj",
|
|
["plate-br"] = "validate_plate_br",
|
|
["company-name"] = "validate_company_name",
|
|
["reply"] = "validate_reply",
|
|
};
|
|
|
|
public static int GetByEndpoint(string endpoint) =>
|
|
_aliases.TryGetValue(endpoint, out var id) ? Get(id) : 1;
|
|
}
|