Deploy Small Talk: Reachy Mini AI podcast (gradio.Server + three.js + LiveKit)
Browse files- backend/__pycache__/showgen.cpython-313.pyc +0 -0
- backend/showgen.py +5 -9
- requirements.txt +1 -0
backend/__pycache__/showgen.cpython-313.pyc
CHANGED
|
Binary files a/backend/__pycache__/showgen.cpython-313.pyc and b/backend/__pycache__/showgen.cpython-313.pyc differ
|
|
|
backend/showgen.py
CHANGED
|
@@ -14,6 +14,7 @@ import re
|
|
| 14 |
import tempfile
|
| 15 |
|
| 16 |
import httpx
|
|
|
|
| 17 |
|
| 18 |
from . import config
|
| 19 |
|
|
@@ -48,20 +49,15 @@ MODERATE_SYS = (
|
|
| 48 |
'{"safe": true|false, "reason": "<short reason if unsafe>"}'
|
| 49 |
)
|
| 50 |
|
| 51 |
-
# cheap last line of defence so the obvious stuff dies even if the LLM is down
|
| 52 |
-
_BLOCKLIST = re.compile(
|
| 53 |
-
r"\b(nsfw|porn\w*|hentai|xxx|blowjob|cumshot|deepthroat|gangbang|paedo\w*|pedo\w*|"
|
| 54 |
-
r"rape\w*|bestiality|loli\w*|nigger|faggot)\b", re.IGNORECASE)
|
| 55 |
-
|
| 56 |
-
|
| 57 |
async def moderate_topic(title: str, topic: str) -> tuple[bool, str]:
|
| 58 |
"""One fast LLM pass: is this title/topic okay for a public, all-ages show?
|
| 59 |
|
| 60 |
-
Fails OPEN on LLM errors (the
|
| 61 |
-
flaky Modal endpoint can't take room creation down with it.
|
| 62 |
"""
|
| 63 |
text = f"{title}\n{topic}".strip()
|
| 64 |
-
|
|
|
|
| 65 |
return False, "that topic isn't suitable for a public show"
|
| 66 |
try:
|
| 67 |
async with httpx.AsyncClient(timeout=90) as cx:
|
|
|
|
| 14 |
import tempfile
|
| 15 |
|
| 16 |
import httpx
|
| 17 |
+
from better_profanity import profanity
|
| 18 |
|
| 19 |
from . import config
|
| 20 |
|
|
|
|
| 49 |
'{"safe": true|false, "reason": "<short reason if unsafe>"}'
|
| 50 |
)
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
async def moderate_topic(title: str, topic: str) -> tuple[bool, str]:
|
| 53 |
"""One fast LLM pass: is this title/topic okay for a public, all-ages show?
|
| 54 |
|
| 55 |
+
Fails OPEN on LLM errors (the better-profanity wordlist still applies) so a
|
| 56 |
+
cold or flaky Modal endpoint can't take room creation down with it.
|
| 57 |
"""
|
| 58 |
text = f"{title}\n{topic}".strip()
|
| 59 |
+
# wordlist first: the obvious stuff dies instantly, even with the LLM down
|
| 60 |
+
if profanity.contains_profanity(text):
|
| 61 |
return False, "that topic isn't suitable for a public show"
|
| 62 |
try:
|
| 63 |
async with httpx.AsyncClient(timeout=90) as cx:
|
requirements.txt
CHANGED
|
@@ -4,3 +4,4 @@ livekit-api>=1.0
|
|
| 4 |
numpy>=1.26
|
| 5 |
python-dotenv>=1.0
|
| 6 |
python-multipart>=0.0.9
|
|
|
|
|
|
| 4 |
numpy>=1.26
|
| 5 |
python-dotenv>=1.0
|
| 6 |
python-multipart>=0.0.9
|
| 7 |
+
better-profanity>=0.7
|