v1.6.0: max_bot fixes — feature keys, flush→commit, test-run, categories, broadcast page, proxy error handling, deploy scripts
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from app.settings_cache import SettingsCache
|
||||
from app.integrations.yandex_gpt import analyze_emotion_with_gpt
|
||||
|
||||
_NEGATIVE_WORDS = [
|
||||
"ужасно", "плохо", "долго", "кошмар", "отвратительно", "невыносимо",
|
||||
"бесполезно", "халтура", "безобразие", "позор", "разочарован", "злюсь",
|
||||
"раздражён", "недоволен", "жалоба", "претензия", "скандал", "суд",
|
||||
"верните деньги", "мошенники", "обман",
|
||||
]
|
||||
|
||||
|
||||
async def detect_emotion(text: str) -> str:
|
||||
gpt_key = SettingsCache.get("yandex_gpt_key")
|
||||
if gpt_key:
|
||||
try:
|
||||
result = await analyze_emotion_with_gpt(text)
|
||||
if result in ("positive", "neutral", "negative"):
|
||||
return result
|
||||
except Exception:
|
||||
pass
|
||||
return _keyword_fallback(text)
|
||||
|
||||
|
||||
def _keyword_fallback(text: str) -> str:
|
||||
text_lower = text.lower()
|
||||
if any(word in text_lower for word in _NEGATIVE_WORDS):
|
||||
return "negative"
|
||||
return "neutral"
|
||||
Reference in New Issue
Block a user