Add multilingual audit CI pipeline + extract mandelblog_content_guard
This commit is contained in:
16
mandelblog_content_guard/ai.py
Normal file
16
mandelblog_content_guard/ai.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from .agents import get_language_agent
|
||||
from .validators.multilingual import validate_ai_text_or_raise
|
||||
|
||||
|
||||
def guard_ai_output(locale_code: str, field_path: str, value: str) -> str:
|
||||
validate_ai_text_or_raise(locale_code, field_path, value)
|
||||
return value
|
||||
|
||||
|
||||
def rewrite_ai_output(locale_code: str, field_path: str, value: str) -> str:
|
||||
agent = get_language_agent(locale_code)
|
||||
rewritten = agent.rewrite(value, field_path=field_path)
|
||||
validate_ai_text_or_raise(locale_code, field_path, rewritten)
|
||||
return rewritten
|
||||
Reference in New Issue
Block a user