Skip to content

Conversation

@hyh1016
Copy link
Collaborator

@hyh1016 hyh1016 commented Sep 24, 2025

📌 관련 이슈

#52

📝 작업 개요

감정 후보 목록이 3개 미만이거나 아예 비어있는 경우가 간간히 보여서 요소 개수(3개)에 대한 강한 규칙 문구를 추가했어~

✅ 작업 사항

  • 감정 분석 프롬프트 고도화

Summary by CodeRabbit

  • 버그 수정
    • 감정 분석 결과의 JSON에서 name 값이 사전 정의된 감정 후보 중 하나로만 반환되도록 제한했습니다.
    • emotions 목록을 항상 정확히 3개 항목으로 고정해 출력 형식의 일관성과 검증을 강화했습니다.
    • 추론 가능한 감정이 없을 때도 무작위 3개 감정을 제공해 빈 결과나 형식 오류를 방지했습니다.

@hyh1016 hyh1016 requested a review from pythonstrup September 24, 2025 12:34
@hyh1016 hyh1016 self-assigned this Sep 24, 2025
@hyh1016 hyh1016 added the bug Something isn't working label Sep 24, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 24, 2025

Walkthrough

감정 분석 프롬프트를 갱신하여 출력 JSON의 name이 EMOTION_CANDIDATES 중 하나여야 함을 명시하고, emotions 리스트의 길이를 정확히 3개로 강제하며, 유도 불가 시 후보군에서 무작위 3개를 반환하도록 규칙을 추가했습니다.

Changes

Cohort / File(s) Change Summary
프롬프트 규칙 강화
src/main/resources/prompts/emotion-analysis.txt
name 값을 EMOTION_CANDIDATES로 제한, emotions 배열 길이 정확히 3개로 고정, 유도 불가 시 후보에서 임의 3개 반환 규칙 추가. 기존 제약과 병행하여 응답 구조/검증 기준을 엄격화.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant C as Client
    participant S as Service
    participant L as LLM(Emotion Prompt)

    C->>S: 분석 요청(텍스트)
    S->>L: 프롬프트(텍스트, 규칙 포함)
    Note right of L: - name ∈ EMOTION_CANDIDATES<br/>- emotions 길이 = 3<br/>- 유도 불가: 후보에서 임의 3개
    L-->>S: JSON { name, emotions[3] }
    S-->>C: 결과 반환
    alt 검증 실패
        S->>L: 재요청 또는 보정
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • pythonstrup

Poem

귀 뾰족 토깽이 프롬프트 손질해,
세 가지 감정만 딱! 바구니에 담네.
이름은 후보 중에서만 콕 집고,
못 찾으면 토도도—임의 셋 뽑고.
깔끔한 JSON, 씽씽 달린다—뀨! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 제목은 "감정 분석 프롬프트에 후보 개수에 대한 강한 규칙 문구 추가"로 변경의 핵심을 명확히 요약하고 있으며 PR 목적(감정 후보를 정확히 3개로 강제화)과 일치합니다. 한 문장으로 간결하고 불필요한 내용이나 모호한 표현이 없어 스캔 시 주요 변경점을 빠르게 파악할 수 있습니다. 따라서 제목은 변경사항과 적절히 연결되어 있습니다.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/52

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/resources/prompts/emotion-analysis.txt (1)

48-55: 형식 예시의 ‘주석/세미콜론/타입 토큰’은 JSON 파서 오류를 유발할 수 있음

예시 블록에 주석(// …), 세미콜론, string/number 같은 타입 토큰이 포함되어 있어 모델이 그대로 복사하면 비유효 JSON이 생성될 위험이 큽니다. 예시는 실제 가능한 JSON으로 제시하거나 “타입 설명”임을 분리해 주세요.

간단 수정 예:

 {
   "emotions": [
     {
-      "name": string;  // 감정
-      "score": number; // 점수
+      "name": "PAIN",
+      "score": 6
     }
   ]
 }

또는 위 블록을 “타입 설명”으로 명시하고, 실제 JSON 예시는 Approach 섹션의 예시만 남기세요.

🧹 Nitpick comments (1)
src/main/resources/prompts/emotion-analysis.txt (1)

57-57: 정확 일치·별칭 금지로 모호성 제거

name 값이 후보군과 “정확히 일치”해야 함을 대소문자/공백까지 명시하고, 별칭·동의어 금지 규칙을 추가해 혼선을 줄이는 게 좋습니다.

아래처럼 문구를 다듬어 주세요:

-응답 값에 대한 매우 엄격한 규칙: JSON의 name이 될 수 있는 감정의 종류는 반드시 '도출 가능한 감정 목록'인 {{EMOTION_CANDIDATES}}에 포함된 것들 중 하나여야 합니다. 이 목록에 없는 다른 감정에 가깝다고 느껴도 이 규칙은 반드시 지켜주세요.
+응답 값에 대한 매우 엄격한 규칙: emotions[].name은 반드시 {{EMOTION_CANDIDATES}}에 정의된 문자열과 대소문자·공백까지 포함해 정확히 일치해야 합니다. 별칭/번역/동의어/형태 변형은 사용하지 마세요. 목록에 없는 감정은 절대 사용하지 마세요.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f40806 and 71f5db5.

📒 Files selected for processing (1)
  • src/main/resources/prompts/emotion-analysis.txt (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

JSON의 name이 될 수 있는 감정의 종류는 반드시 '도출 가능한 감정 목록'인 {{EMOTION_CANDIDATES}}에 포함된 것들 중 하나여야 합니다.
이 목록에 없는 다른 감정에 가깝다고 느껴도 이 규칙은 반드시 지켜주세요.
응답 값에 대한 매우 엄격한 규칙: JSON의 name이 될 수 있는 감정의 종류는 반드시 '도출 가능한 감정 목록'인 {{EMOTION_CANDIDATES}}에 포함된 것들 중 하나여야 합니다. 이 목록에 없는 다른 감정에 가깝다고 느껴도 이 규칙은 반드시 지켜주세요.
리스트 요소 개수에 대한 매우 엄격한 규칙: 리스트 요소의 개수는 반드시 3가지의 감정이어야 합니다. 대화에서 도출할 수 있는 감정이 없다고 판단되면 {{EMOTION_CANDIDATES}} 감정 중 랜덤한 3개를 반환하세요.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

❓ Verification inconclusive

랜덤 사용은 비결정성·재현성 문제를 유발합니다 (+ 점수 규칙·후보군<3 케이스 불명확)

  • 랜덤 선택은 테스트/로그 분석/캐시 적중에 불리합니다.
  • 무작위로 뽑을 때 score를 어떻게 설정할지 규칙이 없습니다.
  • EMOTION_CANDIDATES가 3개 미만일 때의 처리 기준이 없습니다.

결정적(fixed) 규칙과 score 정책을 명시하고, 후보군이 3개 미만인 예외도 정의해 주세요.

권장 수정안:

-리스트 요소 개수에 대한 매우 엄격한 규칙: 리스트 요소의 개수는 반드시 3가지의 감정이어야 합니다. 대화에서 도출할 수 있는 감정이 없다고 판단되면 {{EMOTION_CANDIDATES}} 감정 중 랜덤한 3개를 반환하세요.
+리스트 요소 개수에 대한 매우 엄격한 규칙: emotions 배열의 길이는 반드시 3이어야 합니다. 기본적으로 3개의 name은 서로 달라야 합니다
+(단, {{EMOTION_CANDIDATES}}의 항목 수가 3 미만이면 중복을 허용합니다).
+대화에서 도출할 수 있는 감정이 없다고 판단되면 랜덤을 사용하지 말고 결정적 규칙을 사용하세요:
+{{EMOTION_CANDIDATES}}의 주어진 순서에서 앞에서부터 3개를 선택하고 각 score는 1로 설정합니다.
+{{EMOTION_CANDIDATES}}가 3개 미만이면 목록을 앞에서부터 반복해 3개가 되도록 채우고, 이 경우에도 score는 모두 1로 설정합니다.

확인 요청:

  • 다운스트림 로직이 “정확히 3개”와 “중복 허용 여부”에 어떤 전제를 두고 있는지 알려주세요. 필요하면 그에 맞춰 문구를 더 조정하겠습니다.

결정적 선택·스코어 규칙 및 후보군<3 예외 명시 — 수정 필요

파일: src/main/resources/prompts/emotion-analysis.txt (라인 58)

  • 문제: 랜덤 선택은 비결정성(테스트/로그/캐시 문제)을 유발합니다. score 규칙이 없고, {{EMOTION_CANDIDATES}}가 3개 미만일 때 처리 기준이 없습니다.

권장 수정안:

-리스트 요소 개수에 대한 매우 엄격한 규칙: 리스트 요소의 개수는 반드시 3가지의 감정이어야 합니다. 대화에서 도출할 수 있는 감정이 없다고 판단되면 {{EMOTION_CANDIDATES}} 감정 중 랜덤한 3개를 반환하세요.
+리스트 요소 개수에 대한 매우 엄격한 규칙: emotions 배열의 길이는 반드시 3이어야 합니다. 기본적으로 3개의 name은 서로 달라야 합니다
+(단, {{EMOTION_CANDIDATES}}의 항목 수가 3 미만이면 중복을 허용합니다).
+대화에서 도출할 수 있는 감정이 없다고 판단되면 랜덤을 사용하지 말고 결정적 규칙을 사용하세요:
+{{EMOTION_CANDIDATES}}의 주어진 순서에서 앞에서부터 3개를 선택하고 각 score는 1로 설정합니다.
+{{EMOTION_CANDIDATES}}가 3개 미만이면 목록을 앞에서부터 반복해 3개가 되도록 채우고, 이 경우에도 score는 모두 1로 설정합니다.

확인 요청: 다운스트림 로직이 "정확히 3개"와 "중복 허용 여부"에 어떤 전제를 두고 있는지 알려주세요.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
리스트 요소 개수에 대한 매우 엄격한 규칙: 리스트 요소의 개수는 반드시 3가지의 감정이어야 합니다. 대화에서 도출할 수 있는 감정이 없다고 판단되면 {{EMOTION_CANDIDATES}} 감정 중 랜덤한 3개를 반환하세요.
리스트 요소 개수에 대한 매우 엄격한 규칙: emotions 배열의 길이는 반드시 3이어야 합니다. 기본적으로 3개의 name은 서로 달라야 합니다
(단, {{EMOTION_CANDIDATES}}의 항목 수가 3 미만이면 중복을 허용합니다).
대화에서 도출할 수 있는 감정이 없다고 판단되면 랜덤을 사용하지 말고 결정적 규칙을 사용하세요:
{{EMOTION_CANDIDATES}}의 주어진 순서에서 앞에서부터 3개를 선택하고 각 score는 1로 설정합니다.
{{EMOTION_CANDIDATES}}가 3개 미만이면 목록을 앞에서부터 반복해 3개가 되도록 채우고, 이 경우에도 score는 모두 1로 설정합니다.
🤖 Prompt for AI Agents
In src/main/resources/prompts/emotion-analysis.txt around line 58, remove the
use of random selection for filling to 3 emotions and instead implement a
deterministic rule with explicit scoring and a clear fallback when
{{EMOTION_CANDIDATES}} has fewer than 3 items: sort candidates by a stable key
(e.g., predefined priority list or alphabetical order), assign a numeric score
for each emotion (e.g., confidence between 0-1) and return the top 3 unique
emotions by score; if fewer than 3 candidates exist, pad the list with a defined
placeholder (e.g., "NO_EMOTION" with score 0) or repeat highest-scoring items
only if downstream allows duplicates—confirm whether duplicates are permitted
and whether downstream strictly requires exactly 3 items before implementing.

@hyh1016 hyh1016 merged commit 4acb347 into main Sep 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants