Fix: 챗봇 분석 컨텍스트 스키마를 Spring 계약에 맞게 정렬 - #32
Conversation
📝 WalkthroughWalkthroughThe chat request schema now stores structured indicators inside ChangesChat context update
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@tests/chat/test_schemas.py`:
- Around line 56-58: Update
test_analysis_context_indicator_requires_type_and_description to cover missing
type as well as missing description: retain the existing payload without
description and add a separate _analysis_context call with an indicator
containing only description, asserting both raise ValidationError.
- Around line 31-33: Update
test_analysis_context_defaults_indicators_to_empty_list to construct the context
without passing the indicators argument, then keep the assertion that
context.indicators equals an empty list to verify AnalysisContext’s default
factory.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 98db75c8-9061-4a43-aed9-6efb4dcbd871
📒 Files selected for processing (7)
app/chat/prompts.pyapp/chat/schemas.pyapp/chat/service.pytests/chat/test_prompts.pytests/chat/test_router.pytests/chat/test_schemas.pytests/chat/test_service.py
📝 개요
PR #27(멀티턴 챗봇 API)이 병합된 뒤, Spring 팀이 실제로 사용할
/chat요청계약과 우리 쪽
AnalysisContext스키마가 다르다는 게 확인되어 필드명/구조를실제 계약에 맞게 정렬했습니다. 응답 스키마(`{"message": "..."}")는 변경 없습니다.
🔗 관련 이슈
🎯 주요 변경 사항
app/chat/schemas.pyAnalysisContext필드명 변경:riskGrade→riskLevel,phishingType→category,summary→explanationindicators를ChatRequest최상위에서AnalysisContext내부로 이동indicators타입을list[str]→list[Indicator]({type, description}객체 배열)로 변경category/Indicator.type은 아직 확정된 enum 값 목록이 없어 우선 자유 문자열(str)로 수용app/chat/prompts.py:build_system_prompt()시그니처를(analysis_context)하나로 단순화(indicators가 컨텍스트 안으로 이동),type: description형태로 탐지 근거 포맷팅app/chat/service.py:build_system_prompt()호출부를 새 시그니처에 맞게 수정tests/chat/*: 새 스키마 구조에 맞게 전체 테스트 갱신 (23개 계속 통과)📸 사진
Swagger UI(
/docs)와 실제 Gemini 라이브 호출로 새 요청 형식 동작 확인. 별도 스크린샷 없음.✅ PR 체크리스트
uvicorn구동 또는 테스트 코드)를 통과했습니다.Summary by CodeRabbit
Improvements
Tests