diff --git a/troubleshooting/251014_coldmail_ir_analysis_scenario.md b/troubleshooting/251014_coldmail_ir_analysis_scenario.md index feb27ca..3711cb2 100644 --- a/troubleshooting/251014_coldmail_ir_analysis_scenario.md +++ b/troubleshooting/251014_coldmail_ir_analysis_scenario.md @@ -25,14 +25,25 @@ ## 구현 완료 (2025-10-14) -- coldmail_briefing.py:78-302: 전체 플로우 +### 초기 구현 (우선순위 1) - naverworks_file_processor.py:94-135: PDF → skill-rag-file 업로드 -- ir_analyzer.py:86-168: RAG 6회 쿼리 → LLM 요약 +- ir_analyzer.py:86-178: RAG 6회 쿼리 → LLM 요약 - startup_valuation.py:63-173: 베이지안 VC Method -- coldmail_briefing.py:191-221,241,246: Slack Lists 파일 첨부 -- coldmail_briefing.py:262-285: Slack 피드백 버튼 +- coldmail_briefing.py:204-232,252,257: Slack Lists 파일 첨부 +- coldmail_briefing.py:273-296: Slack 피드백 버튼 - coldmail_filter.py:29-76: Naive Bayes 학습 +### 우선순위 2,3 (커밋 0ef3489) +- ir_analyzer.py:155-163: LLM 마크다운 블록 전처리 +- coldmail_briefing.py:145,192-200,302-305: Slack 요약 메시지 포맷 + +### 우선순위 4 (커밋 c2ac162) +- requirements.txt:42: langgraph>=0.2.0 +- coldmail_email_fetcher.py:15-44: 메일 조회 (46줄) +- coldmail_processor.py:23-191: IR 분석 + Slack 등록 (191줄) +- workflows/coldmail_workflow.py:17-151: StateGraph (151줄) +- coldmail_briefing.py:78-115: LangGraph 워크플로우 (114줄, 63% 감소) + --- ## 분석 결과 예시 @@ -49,45 +60,19 @@ - skill-slack/app/api/endpoints/files.py: POST /files/upload (X-API-Key) - coldmail_briefing.py:191-221, 241, 246: document_id → file_id 변환 -### 우선순위 2: LLM JSON 파싱 에러 -- ir_analyzer.py:155 다음 (156 전): llm_response 전처리 - - cleaned = llm_response.strip() - - if cleaned.startswith("```json"): cleaned = cleaned[7:] - - if cleaned.startswith("```"): cleaned = cleaned[3:] - - if cleaned.endswith("```"): cleaned = cleaned[:-3] - - cleaned = cleaned.strip() -- ir_analyzer.py:156: parsed = json.loads(cleaned) +### 우선순위 2: LLM JSON 파싱 에러 (✅ 완료) +- ir_analyzer.py:155-163: 마크다운 블록 제거 전처리 -### 우선순위 3: Slack 메시지에 IR 분석 결과 추가 -- coldmail_briefing.py:144 다음: processed_results = [] 추가 -- coldmail_briefing.py:188 다음: processed_results.append({...}) 추가 - - company_name, ir_metrics.get("revenue"), valuation_result.median, valuation_result.confidence 포함 -- coldmail_briefing.py:291 교체: - - 기존: f"콜드메일 {processed_count}건 처리 완료 (...)" - - 변경: summary_lines = [f"콜드메일 {processed_count}건 처리 완료"] - - for item in processed_results: summary_lines.append(f"- {item['company']}: {item['median']}억원 (신뢰도 {int(item['confidence']*100)}%)") - - summary_text = "\\n".join(summary_lines) +### 우선순위 3: Slack 메시지 IR 분석 결과 (✅ 완료) +- coldmail_briefing.py:145,192-200,302-305: processed_results 추적 및 요약 -### 우선순위 4: LangGraph 워크플로우 -- requirements.txt: langgraph 추가 -- app/services/coldmail_email_fetcher.py 생성 - - coldmail_briefing.py:93-121 로직 분리 - - async def fetch_emails(user_id, start_time, now) -> list -- app/services/coldmail_processor.py 생성 - - coldmail_briefing.py:145-202 로직 분리 - - async def process_coldmail(email, user_id) -> dict or None - - 반환: {company, median, confidence, lower, upper, revenue} -- app/services/workflows/__init__.py: 빈 파일 -- app/services/workflows/coldmail_workflow.py 생성 - - ColdmailState: emails, coldmail_candidates, processed_results, user_id, start_time, now - - 노드: fetch, filter, process, send - - route_after_filter: coldmail_candidates 유무로 END or process - - add_conditional_edges("filter", route_after_filter, {...}) -- coldmail_briefing.py:78-302 교체 (최종 ~100줄) - - coldmail_briefing.py:86-101 유지 - - workflow.ainvoke(initial_state) 호출 -- 테스트: rb8001/tests/test_langgraph_workflow.py - - State 필드, 노드 플로우, 조건부 엣지 검증 완료 +### 우선순위 4: LangGraph 워크플로우 (✅ 완료) +- requirements.txt:42: langgraph>=0.2.0 +- coldmail_email_fetcher.py:15-44: fetch_emails(user_id, start_time, now) +- coldmail_processor.py:23-191: process_coldmail(email, user_id) +- workflows/__init__.py: 빈 파일 +- workflows/coldmail_workflow.py:17-151: StateGraph 4노드 + 조건부 엣지 +- coldmail_briefing.py:78-115: workflow.ainvoke() 호출 (316줄 → 114줄) --- @@ -95,3 +80,5 @@ - 전체 시나리오 문서 먼저 작성 후 세부 구현 - LLM 응답은 항상 전처리 (마크다운 블록 제거) +- LangGraph State는 직렬화 가능한 타입만 (aiohttp.ClientSession은 각 노드에서 생성) +- DRY 원칙 + 파일 크기 제한(300줄) → 로직 분리로 유지보수성 향상 (316줄 → 46+191+151+114줄)