From 01de5c7f9bbc6533f1ab28f01db8d247b98f9131 Mon Sep 17 00:00:00 2001 From: H4nnhoi Date: Mon, 1 Dec 2025 11:18:56 +0000 Subject: [PATCH 1/3] hotfix : miss fear_bps --- app/main.py | 7 ++++++- app/voice_service.py | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 0bd5be4..cbcddfa 100644 --- a/app/main.py +++ b/app/main.py @@ -929,7 +929,12 @@ def to_bps(x): sad = to_bps(probs.get("sad", 0)) neutral = to_bps(probs.get("neutral", 0)) angry = to_bps(probs.get("angry", 0)) - fear = to_bps(probs.get("fear", 0)) + # preview API에서도 fear/anxiety 계열을 합산해서 fear_bps로 보여준다. + fear_prob = ( + float(probs.get("fear", 0) or 0) + + float(probs.get("anxiety", 0) or 0) + ) + fear = to_bps(fear_prob) surprise = to_bps(probs.get("surprise", 0)) total = happy + sad + neutral + angry + fear + surprise if total == 0: diff --git a/app/voice_service.py b/app/voice_service.py index c8ae6fb..4aa07ff 100644 --- a/app/voice_service.py +++ b/app/voice_service.py @@ -454,7 +454,14 @@ def to_bps(v: float) -> int: sad = to_bps(probs.get("sad", probs.get("sadness", 0))) neutral = to_bps(probs.get("neutral", 0)) angry = to_bps(probs.get("angry", probs.get("anger", 0))) - fear = to_bps(probs.get("fear", probs.get("fearful", 0))) + # fear_bps 컬럼에는 'fear' + 'anxiety' 계열을 모두 합산해서 저장한다. + # emotion_service에서 "불안"은 anxiety, "두려움/공포"는 fear 로 매핑되므로 둘을 같은 버킷으로 취급. + fear_prob = ( + float(probs.get("fear", 0) or 0) + + float(probs.get("anxiety", 0) or 0) + + float(probs.get("fearful", 0) or 0) + ) + fear = to_bps(fear_prob) surprise = to_bps(probs.get("surprise", probs.get("surprised", 0))) # 모델 응답 키 보정: emotion_service는 기본적으로 "emotion"을 반환 From 033a34f9b51723e733d79827897f4e2778519903 Mon Sep 17 00:00:00 2001 From: H4nnhoi Date: Mon, 1 Dec 2025 13:57:49 +0000 Subject: [PATCH 2/3] hotfix : down angry weight --- app/services/va_fusion.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/services/va_fusion.py b/app/services/va_fusion.py index 48375d4..8c8209f 100644 --- a/app/services/va_fusion.py +++ b/app/services/va_fusion.py @@ -201,7 +201,7 @@ def apply_zero_prob_mask( def fuse_VA(audio_probs: Dict[str, float], text_score: float, text_magnitude: float) -> Dict[str, object]: """Fuse audio (emotion probabilities) and text (score,magnitude) into composite VA. - + Returns dict with keys: - V_final, A_final, intensity, V_audio, A_audio, V_text, A_text, alpha, beta (float) - per_emotion_bps (dict[str,int], sum=10000), top_emotion (str), top_confidence_bps (int) @@ -273,6 +273,22 @@ def fuse_VA(audio_probs: Dict[str, float], text_score: float, text_magnitude: fl t_sc = float(text_emotion_weight.get(emo, 0.0)) composite_score[emo] = alpha_prob * a_sc + beta_prob * t_sc + # Audio에서 분노 비율이 매우 낮은 경우(angry_bps <= 2000 → angry_prob <= 0.2), + # voice_composite에서 분노가 과도하게 top으로 나오는 것을 방지하기 위해 + # audio angry 정보의 최종 기여도를 완만하게 줄인다. + try: + angry_p = float(audio_probs.get("angry", 0.0)) + if angry_p <= 0.2: + neg = max(0.0, -float(v_text)) + mag = max(0.0, min(1.0, float(a_text))) + base_factor = 0.7 + extra_down = 0.15 * neg * mag # 최대 약 0.15 추가 감쇠 + factor = max(0.5, base_factor - extra_down) # 최소 0.5배까지 + composite_score["angry"] = composite_score.get("angry", 0.0) * factor + except Exception: + # 로직 실패 시에는 안전하게 무시 + pass + # 감정별 가중치 조정: neutral은 더 강하게 억제(긍정일수록 추가 억제) neutral_base_factor = 0.6 if v_text > 0: From 9f5fff3065b066e0abe32332acc75d2d73a8ef34 Mon Sep 17 00:00:00 2001 From: H4nnhoi Date: Mon, 1 Dec 2025 15:14:14 +0000 Subject: [PATCH 3/3] =?UTF-8?q?fix=20:=20timeout=2060=EC=B4=88=EB=A1=9C=20?= =?UTF-8?q?=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/analyze_chat_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/analyze_chat_service.py b/app/services/analyze_chat_service.py index eee74ca..2680835 100644 --- a/app/services/analyze_chat_service.py +++ b/app/services/analyze_chat_service.py @@ -299,7 +299,7 @@ async def _send_to_chatbot( raise InternalServerException("CHATBOT_API_URL not configured") try: - async with httpx.AsyncClient(timeout=30.0) as client: + async with httpx.AsyncClient(timeout=60.0) as client: response = await client.post( chatbot_url, json=request_payload,