Skip to content

Fix: 챗봇 분석 컨텍스트 스키마를 Spring 계약에 맞게 정렬 - #32

Merged
kite-pp merged 2 commits into
developfrom
feat/23-multiturn-chat-api
Aug 2, 2026
Merged

Fix: 챗봇 분석 컨텍스트 스키마를 Spring 계약에 맞게 정렬#32
kite-pp merged 2 commits into
developfrom
feat/23-multiturn-chat-api

Conversation

@kite-pp

@kite-pp kite-pp commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

📝 개요

PR #27(멀티턴 챗봇 API)이 병합된 뒤, Spring 팀이 실제로 사용할 /chat 요청
계약과 우리 쪽 AnalysisContext 스키마가 다르다는 게 확인되어 필드명/구조를
실제 계약에 맞게 정렬했습니다. 응답 스키마(`{"message": "..."}")는 변경 없습니다.

🔗 관련 이슈

🎯 주요 변경 사항

  • app/chat/schemas.py
    • AnalysisContext 필드명 변경: riskGraderiskLevel, phishingTypecategory, summaryexplanation
    • indicatorsChatRequest 최상위에서 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 구동 또는 테스트 코드)를 통과했습니다.
  • API 변경 사항이 있다면 Swagger / API 명세에 반영했습니다.
  • 민감 정보(API Key, 시크릿 키 등)가 코드·로그·테스트 데이터에 포함되지 않았습니다.
  • 프론트엔드 또는 메인 백엔드(Spring)에 영향을 주는 응답 스키마 또는 Enum 변경이 있다면 팀에 공유했습니다.
  • 병합(Merge) 전 작업 브랜치를 삭제하지 않았습니다.

Summary by CodeRabbit

  • Improvements

    • Updated chat analysis data to use clearer risk, category, and explanation details.
    • Indicators are now provided in a structured format with a type and description.
    • Chat responses automatically handle cases where no indicators are available.
    • Added validation to prevent incomplete analysis details and invalid indicator entries.
  • Tests

    • Expanded coverage for the updated analysis format, validation rules, empty indicators, and message histories.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The chat request schema now stores structured indicators inside AnalysisContext. Prompt generation uses the renamed context fields and formats indicators from their type and description. Service and chat tests use the revised request contract.

Changes

Chat context update

Layer / File(s) Summary
Analysis context contract and validation
app/chat/schemas.py, tests/chat/test_schemas.py
AnalysisContext uses riskLevel, category, explanation, and structured indicators. ChatRequest no longer has top-level indicators. Validation tests cover blank explanations and incomplete indicators.
Context-driven prompt integration
app/chat/prompts.py, app/chat/service.py, tests/chat/test_prompts.py, tests/chat/test_router.py, tests/chat/test_service.py
build_system_prompt accepts only AnalysisContext. It formats indicators as type: description, with "없음" for an empty list. Service and chat tests use the revised fields.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: pearseona

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: aligning the chatbot analysis context schema with the Spring contract.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/23-multiturn-chat-api

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.

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 54e8e6b and 37f33f5.

📒 Files selected for processing (7)
  • app/chat/prompts.py
  • app/chat/schemas.py
  • app/chat/service.py
  • tests/chat/test_prompts.py
  • tests/chat/test_router.py
  • tests/chat/test_schemas.py
  • tests/chat/test_service.py

Comment thread tests/chat/test_schemas.py
Comment thread tests/chat/test_schemas.py
@kite-pp kite-pp changed the title fix: 챗봇 분석 컨텍스트 스키마를 Spring 계약에 맞게 정렬 Fix: 챗봇 분석 컨텍스트 스키마를 Spring 계약에 맞게 정렬 Aug 2, 2026
@kite-pp
kite-pp merged commit 8679b46 into develop Aug 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant