feat: Gemini 기반 문자 어조/근거 분석 파이프라인 추가 - #13
Merged
Merged
Conversation
문자 메시지의 어조와 근거를 분석해 위험도를 판정하는 Gemini 연동을 추가하고, /analyze 엔드포인트가 이를 사용하도록 연결. API 실패 시 SAFE로 오탐되지 않도록 fail-closed(UNKNOWN 등급) 정책을 적용하고, 채점 재현성을 위해 temperature를 낮춤. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
📝 개요
Gemini API를 이용해 문자 메시지의 어조와 근거를 분석하고 스미싱 위험도를 판정하는 로직을 추가하고,
/analyze엔드포인트에 연결했습니다.🔗 관련 이슈
🎯 주요 변경 사항
app/service/security/gemini_text_analyzer.py: GeminigenerateContent호출, JSON 스키마 강제 응답, 위험도 등급 산정(DANGEROUS/SUSPICIOUS/SAFE), 각종 실패 상황(429/Timeout/파싱실패/키 누락 등) 처리SAFE로 떨어지지 않도록UNKNOWN(판정 불가) 등급을 강제generationConfig.temperature를 0.1로 고정app/dto/request.py:AnalyzeRequest요청 DTO 신규 추가app/router/analyze.py: 더미 dict 대신AnalyzeRequest를 받아analyze_text_with_gemini결과를 반환하도록 변경 (URL 분석은 기존 더미 유지)app/service/security/mock_provider.py: 문자 분석용 Mock DB(MOCK_TEXT_DATABASE) 및 기본 안전 응답 추가requirements.txt:python-dotenv추가README.md:.env예시에GEMINI_API_KEY,GEMINI_MODEL추가tests/security/test_gemini_text_analyzer.py: 등급 산정, Mock 모드, fail-closed(API 키 누락) 시나리오 단위 테스트 추가📸 사진
✅ PR 체크리스트
uvicorn구동 또는 테스트 코드)를 통과했습니다.🤖 Generated with Claude Code