Repository navigation
feat: 신고서 AI 요약과 한글 PDF 생성 (#61) - #62
Merged
Merged
Conversation
신고서 요약이 원문을 그대로 복사해 보여주고, 신고 문서는 열리지 않는 임시 주소만 만들던 문제를 고친다.
- 요약: LLM이 피해 내용을 사건 개요로 요약해 reports.summary에 저장한다(V11).
원문에 없는 내용을 지어내지 않도록 프롬프트에서 막고, 원문이 80자 미만이거나 LLM을 쓸 수 없으면
원문을 베끼지 않고 요약 없이 둔다. 원문이 바뀌면 다시 만들고, 못 만들면 옛 요약을 지운다.
- PDF: PDFBox와 나눔고딕(OFL)으로 한글 신고 문서를 만든다. 요약은 AI 요약이라는 안내와 함께 싣고
원문도 그대로 싣는다. 글꼴에 없는 글자는 ?로 바꾼다.
- 문서는 파일로 저장하지 않고 GET /api/v1/reports/{id}/document 에서 본인 인증 후 요청할 때 만든다.
/uploads는 공개 경로라 피해 진술이 담긴 문서를 두지 않기 위해서다.
- 스텁 문서 생성기와 documentSimulated를 없애고 documentUrl은 위 경로를 가리킨다.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JfUPGxfx9b1wA61pUbijb6
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JfUPGxfx9b1wA61pUbijb6
jyx-07
reviewed
Nov 9, 2026
jyx-07
left a comment
Collaborator
There was a problem hiding this comment.
리뷰
머지 전 수정 필요
- 트랜잭션 안 LLM 호출 —
ReportServicecreate/update가 쓰기 트랜잭션을 연 채로 Groq를 동기 호출합니다(최대 ~15초). 동시 저장 몇 건이면 Hikari 풀이 고갈될 수 있어요. 요약은 트랜잭션 밖에서 처리해 주세요. - 탈퇴 시 ERROR 로그 —
attachedReportUrl이 이제/api/v1/reports/{id}/documentAPI 경로인데UserDataEraser가 여전히 이 값을fileStorage.delete에 넘깁니다.documentUrl삭제 줄처럼 이 줄도 제거해야 합니다. - API 변경 영향
documentUrl이 JWT 헤더 필요 경로라<a href>/window.open으로 열면 401입니다. 또 API 호스트 기준 상대경로라 Vercel 프론트에서 그대로 쓸 수 없습니다.documentSimulated필드가 응답에서 빠졌습니다(프론트 확인 필요).- 기관 연결(DOCUMENT_SUBMIT)에 첨부되는 URL을 신고자 본인만 열 수 있어서 기관 입장에선 의미가 없습니다.
개선 권장
- 요약 재생성이 description 변경 시에만 일어나는데, 프롬프트는
damageType도 씁니다. 생성 시 Groq 실패로 null이 되면 이후 재시도도 없습니다. - PDF 렌더링이 readOnly 트랜잭션 안에서 실행돼 렌더 동안 커넥션을 점유합니다. 폰트는 바이트만 캐시하고 매 요청 TTF 2개를 다시 파싱합니다.
- 사소한 것
- 요약
substring절단 시 서로게이트 쌍(이모지)이 잘릴 수 있음 - 줄바꿈 후 다음 줄이 오른쪽 여백을 약간 넘을 수 있고,
1.같은 번호만 한 줄에 남을 수 있음 - 섹션 제목만 페이지 하단에 남는 경우 있음
- 요약
create/update/finalize는 트랜잭션 없이 시작해 LLM 호출을 끝낸 뒤 짧은 쓰기 트랜잭션에서만 저장한다. 요약 입력(원문, 피해 유형)이 바뀌었거나 요약이 비어 있으면 다시 만들고, 작성 완료 때도 한 번 더 시도한다. 요약을 자를 때 서로게이트 쌍(이모지)의 한가운데서 자르지 않는다. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JfUPGxfx9b1wA61pUbijb6
줄바꿈 뒤에도 글이 오른쪽 여백을 넘지 않게 하고, 출처 주소는 번호를 들여쓰기로 붙여 번호만 홀로 남지 않게 한다. 섹션 제목 뒤에 글 두 줄 정도가 들어갈 자리가 없으면 다음 페이지로 넘긴다. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JfUPGxfx9b1wA61pUbijb6
attachedReportUrl이 /api 경로가 되면서 파일 삭제에 넘기면 오류 로그가 남았다. 옛 기록(/uploads)만 파일로 지운다. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JfUPGxfx9b1wA61pUbijb6
jyx-07
approved these changes
Nov 9, 2026
This was referenced Nov 9, 2026
Merged
6 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경 내용
측정값 기반 위험도 분석 (
risk-analysis.mode=http)llm이라 켜지 않으면 동작이 바뀌지 않음risk-lab/(FastAPI + OpenCV): YuNet 얼굴 검출(OpenCV Model Zoo, MIT)과 얼굴별 면적 비율·짧은 변 px·선명도·정면도 측정. 점수는 매기지 않고 측정값만 반환HttpRiskAnalyzer,RiskScoring: 측정값을 고정 공식으로 점수화하고 설명에 근거 측정값 표기(ko/en/ja/zh-CN)LlmRiskAnalyzer는 mode=llm(기본)일 때만 빈 등록, GPS 판독은GpsMetadata로 분리docker-compose.yml에risk서비스(프로필risk, 포트 미게시),application.yml에risk-analysis.*추가문서
docs/risk-analysis.md: 두 방식 비교와 점수 공식, 한계docs/detect-calibration.md,scripts/detect-calibration/: 탐지 점수 보정 실험 기록(서비스에는 적용하지 않음)확인 사항
남은 것 / 팀 결정 필요
deploy.yml)에는 아직 연결하지 않음. 켜려면docker compose --profile risk up -d --build risk와RISK_ANALYSIS_MODE=http가 필요하고, CI 이미지 빌드를 붙이는 건 후속 작업risk컨테이너 메모리 한도(384m)는 잠정값이라 배포 후docker stats로 조정 필요프론트 영향