Ajuste segurança-extra

This commit is contained in:
2026-05-05 13:13:23 -03:00
parent 25bc77f582
commit d698f8f834
15 changed files with 580 additions and 4 deletions

View File

@@ -18,3 +18,23 @@ def validar_groundedness(resposta:str, context:dict)->RailResult:
def supervisor_vas_avulso(payload:dict)->RailResult:
with span("supervisor.REVPREC_SUP", mechanism="llm_supervisor"):
out=_client.classify("SUPERVISOR_VAS", payload); return RailResult(out["allowed"],out.get("reason",""),code="REVPREC_SUP",mechanism="llm_supervisor",data=out)
# =========================
# FILTROS ADICIONADOS DE SEGURANCA
# =========================
def detectar_prompt_injection_jailbreak(text:str, context:dict)->RailResult:
with span("rail.PINJ", mechanism="llm_rail"):
out=_client.classify("PINJ", {"text":text,"context":context}); return RailResult(out["allowed"],out.get("reason",""),text,"PINJ","llm_rail",out)
def detectar_rag_injection_context_poisoning(text:str, context:dict)->RailResult:
with span("rail.RAGSEC", mechanism="llm_rail"):
out=_client.classify("RAGSEC", {"text":text,"context":context}); return RailResult(out["allowed"],out.get("reason",""),text,"RAGSEC","llm_rail",out)
def detectar_data_leakage_input(text:str, context:dict)->RailResult:
with span("rail.DLEX_IN", mechanism="llm_rail"):
out=_client.classify("DLEX_IN", {"text":text,"context":context}); return RailResult(out["allowed"],out.get("reason",""),text,"DLEX_IN","llm_rail",out)
def detectar_data_leakage_output(text:str, context:dict)->RailResult:
with span("rail.DLEX_OUT", mechanism="llm_rail"):
out=_client.classify("DLEX_OUT", {"text":text,"context":context}); return RailResult(out["allowed"],out.get("reason",""),text,"DLEX_OUT","llm_rail",out)