Skip to content

feat: 가정통신문 분석 결과 다국어 생성 개선 - #32

Merged
deli-minju merged 4 commits into
developfrom
feat/#31-multilingual-newsletter-analysis
Jun 11, 2026
Merged

feat: 가정통신문 분석 결과 다국어 생성 개선#32
deli-minju merged 4 commits into
developfrom
feat/#31-multilingual-newsletter-analysis

Conversation

@deli-minju

@deli-minju deli-minju commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

📌 작업 요약

  • 요약:
    • 가정통신문 분석 프롬프트가 사용자 선택 언어에 맞춰 최종 사용자 노출 문구를 생성하도록 개선
    • translatedText는 최종 번역본이 아니라 기계 번역 초안/참고자료로만 사용하도록 프롬프트 계약 정리
    • 문서 제목, 요약, 일정명, 체크리스트, 대화 주제, 확인 질문이 목표 언어로 생성되도록 명시
    • 알림에 사용될 수 있는 동적 문구를 KO/US/ZH/VI 4개 언어 map으로 함께 반환하도록 응답 계약 확장
    • titleI18n, items[].titleI18n, items[].checklistItems[].contentI18n 필드 추가
    • 대화 주제는 알림에 사용하지 않으므로 4개 언어 map 생성 대상에서 제외
    • OpenAI 분석 응답 meta에 outputLanguage, localizedOutput 추가
    • OpenAI 비활성화 fallback에서 비한국어 요청 시 translatedText를 제목 참고값으로 사용하되 LLM 검토 필요 상태 유지
    • OpenAI 비활성화 fallback에서도 스키마 호환을 위해 알림용 i18n map 기본값 생성
    • 다국어 프롬프트 계약, 알림용 i18n 응답 스키마, fallback 메타 단위 테스트 추가
  • 관련 이슈: closes [FEAT] 가정통신문 분석 결과 다국어 최종 생성 개선 #31

🌿 브랜치 정보

  • Source: feat/#31-multilingual-newsletter-analysis
  • Target: develop (기본)

✅ 체크리스트

  • 브랜치 컨벤션 준수 (feat/refac/hotfix/chore/design/bugfix)
  • 커밋 컨벤션 준수 (feat/fix/refactor/docs/style/chore)
  • self-review 완료
  • 테스트 및 로컬 실행 확인 완료

🧪 테스트 결과

.\.venv\Scripts\python.exe -m unittest discover -s tests

Summary by CodeRabbit

새 기능

  • 뉴스레터 분석에 다국어 지원(한국어, 영어, 중국어, 베트남어) 추가
  • 출력 언어 및 현지화 여부 정보가 응답에 포함
  • 알 수 없는 언어 입력 시 한국어로 자동 폴백

테스트

  • 다국어 분석 및 언어 폴백 동작 검증 추가

@deli-minju deli-minju self-assigned this Jun 11, 2026
@deli-minju deli-minju added the feat 새로운 기능 추가 작업 label Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@deli-minju, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 48 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 417e312a-bab7-4e14-a887-1d97025b1f50

📥 Commits

Reviewing files that changed from the base of the PR and between c058d3c and ed114c0.

📒 Files selected for processing (6)
  • app/__init__.py
  • app/constants.py
  • app/services/newsletter_extractor.py
  • app/services/newsletter_prompt.py
  • tests/conftest.py
  • tests/test_newsletter_multilingual.py
📝 Walkthrough

전체 개요

뉴스레터 분석 응답에 KO/US/ZH/VI 4개 언어로 제목, 일정, 체크리스트 등의 동적 문구를 생성하도록 확장되었습니다. 프롬프트 서비스에 언어 기반 스키마를 추가하고, 추출 로직에서 다국어 맵을 생성하며, 종합 테스트로 검증합니다.

변경 사항

다국어 알림 필드 생성

계층 / 파일 요약
데이터 모델 i18n 필드
app/schemas.py
ChecklistItem, ExtractedItem, NewsletterAnalysisResponse에 각각 content_i18n, title_i18n 필드를 추가하여 언어별 매핑을 저장하는 계약을 정의합니다.
프롬프트 서비스 언어 계약과 스키마
app/services/newsletter_prompt.py (3-129줄)
언어 코드 상수(LANGUAGE_NAMES, SUPPORTED_LANGUAGE_CODES), 다국어 텍스트 스키마(I18N_TEXT_SCHEMA)를 정의하고, 응답 JSON 스키마에 i18n 필드를 필수 필드로 추가하여 AI의 생성 계약을 명시합니다.
언어 인식 프롬프트 생성
app/services/newsletter_prompt.py (138-276줄)
시스템 프롬프트를 language 파라미터로 받아 언어명을 치환하여 최종 사용자 문구를 해당 언어로 작성하도록 지시합니다. 사용자 프롬프트에 번역문을 <translated_text> XML 블록으로 감싸고 목표 언어명을 명시합니다.
i18n 필드 추출 및 헬퍼
app/services/newsletter_extractor.py (56-333줄)
지원 언어 코드를 정의하고, 아이템 및 체크리스트 생성 시 _fallback_i18n() 헬퍼로 4개 언어 매핑을 생성합니다. 번역문이 존재하고 한국어가 아닐 때 번역문 기준으로 제목을 추출하도록 로직을 업데이트합니다.
다국어 기능 검증
tests/test_newsletter_multilingual.py
프롬프트가 목표 언어의 최종 사용자 문구를 포함하는지, 응답 스키마가 모든 필수 언어의 i18n 맵을 요구하는지, 미지원 언어 입력 시 한국어로 폴백되는지, 그리고 LLM 비활성화 시 규칙 기반 추출이 번역문 기반 제목을 올바르게 생성하는지 검증합니다.

🎯 4 (복잡함) | ⏱️ ~45분

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 사항(다국어 생성 개선)을 명확하게 요약하고 있으며, 실제 코드 변경 내용과 일치합니다.
Description check ✅ Passed PR 설명이 저장소의 템플릿 구조를 대부분 준수하고 있으며, 작업 요약, 브랜치 정보, 체크리스트, 테스트 결과를 포함하고 있습니다.
Linked Issues check ✅ Passed 코드 변경이 이슈 #31의 모든 주요 요구사항을 충족합니다: 알림용 i18n 필드(titleI18n, contentI18n) 추가, 4개 언어 지원(KO/US/ZH/VI), translatedText 참고자료 용도 명시, 프롬프트 및 응답 스키마 개선, 다국어 테스트 추가.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #31의 다국어 생성 개선 범위 내에 있으며, 명확히 관련된 코드 수정만 포함되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#31-multilingual-newsletter-analysis

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/services/newsletter_extractor.py`:
- Around line 213-215: The code calls _compact_title(sentence) twice when
constructing ChecklistItem; compute compact = _compact_title(sentence) once and
reuse it for both content and contentI18n via _fallback_i18n(compact) to avoid
duplicate work—update the ChecklistItem creation (involving ChecklistItem,
_compact_title, and _fallback_i18n) to use the cached compact variable.
- Line 56: SUPPORTED_LANGUAGE_CODES is duplicated across modules
(newsletter_prompt, newsletter_extractor, and tests); extract this constant (and
optional LANGUAGE_NAMES) into a single module (e.g., app.constants) and replace
the local definitions by importing SUPPORTED_LANGUAGE_CODES (and LANGUAGE_NAMES)
where needed; specifically, create app.constants with SUPPORTED_LANGUAGE_CODES =
("KO","US","ZH","VI") (and LANGUAGE_NAMES if desired), then in
newsletter_extractor.py, newsletter_prompt.py, and
tests/test_newsletter_multilingual.py remove the local SUPPORTED_LANGUAGE_CODES
and add from app.constants import SUPPORTED_LANGUAGE_CODES (and LANGUAGE_NAMES)
so all modules share the single source of truth.

In `@tests/test_newsletter_multilingual.py`:
- Around line 1-9: The tests fail to import the app package (imports like
NewsletterAnalysisRequest, analyze_newsletter, ANALYSIS_RESPONSE_SCHEMA,
build_prompt_messages) because the repository lacks package initialization or a
PYTHONPATH entry; fix by either adding an empty app/__init__.py to make app a
package or add pythonpath configuration to the test runner (e.g., in
pyproject.toml or pytest.ini) so the repo root is on sys.path when running
tests; update the repo accordingly so tests/test_newsletter_multilingual.py can
import those symbols and use SUPPORTED_LANGUAGE_CODES without
ModuleNotFoundError.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cb264477-6a63-438f-9439-555cd15b8dbf

📥 Commits

Reviewing files that changed from the base of the PR and between 1e86c73 and c058d3c.

📒 Files selected for processing (4)
  • app/schemas.py
  • app/services/newsletter_extractor.py
  • app/services/newsletter_prompt.py
  • tests/test_newsletter_multilingual.py

Comment thread app/services/newsletter_extractor.py Outdated
"서명",
"제출",
)
SUPPORTED_LANGUAGE_CODES = ("KO", "US", "ZH", "VI")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

SUPPORTED_LANGUAGE_CODES 상수가 여러 파일에서 중복 정의되었습니다.

현재 다음 위치에서 동일한 상수가 정의되어 있습니다:

  • app/services/newsletter_prompt.py (Line 10)
  • app/services/newsletter_extractor.py (Line 56)
  • tests/test_newsletter_multilingual.py (Line 9)

언어 코드를 추가하거나 변경할 때 여러 파일을 동기화해야 하므로 유지보수성이 저하됩니다.

♻️ 제안: 공통 상수 파일로 추출

app/constants.py 또는 app/schemas.py에 상수를 정의하고 다른 파일에서 import하도록 변경:

# app/constants.py (새 파일)
SUPPORTED_LANGUAGE_CODES = ("KO", "US", "ZH", "VI")

LANGUAGE_NAMES = {
    "KO": "한국어",
    "US": "미국 영어",
    "ZH": "중국어 간체",
    "VI": "베트남어",
}

그런 다음 다른 파일에서:

-SUPPORTED_LANGUAGE_CODES = ("KO", "US", "ZH", "VI")
+from app.constants import SUPPORTED_LANGUAGE_CODES
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/services/newsletter_extractor.py` at line 56, SUPPORTED_LANGUAGE_CODES is
duplicated across modules (newsletter_prompt, newsletter_extractor, and tests);
extract this constant (and optional LANGUAGE_NAMES) into a single module (e.g.,
app.constants) and replace the local definitions by importing
SUPPORTED_LANGUAGE_CODES (and LANGUAGE_NAMES) where needed; specifically, create
app.constants with SUPPORTED_LANGUAGE_CODES = ("KO","US","ZH","VI") (and
LANGUAGE_NAMES if desired), then in newsletter_extractor.py,
newsletter_prompt.py, and tests/test_newsletter_multilingual.py remove the local
SUPPORTED_LANGUAGE_CODES and add from app.constants import
SUPPORTED_LANGUAGE_CODES (and LANGUAGE_NAMES) so all modules share the single
source of truth.

Comment thread app/services/newsletter_extractor.py Outdated
Comment thread tests/test_newsletter_multilingual.py Outdated

@Hminkyung Hminkyung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

확인완료했습니다!! 고생하셨어요~

@deli-minju
deli-minju merged commit 745a115 into develop Jun 11, 2026
3 checks passed
@deli-minju
deli-minju deleted the feat/#31-multilingual-newsletter-analysis branch June 11, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 새로운 기능 추가 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 가정통신문 분석 결과 다국어 최종 생성 개선

2 participants