IDEA-2/1/5/7: 스마트 알림, 대화 기반 RAG, CRAG, 파라미터 자동 튜닝
- IDEA-2 스마트 알림: td_reminders 테이블, set_reminder/list_reminders 도구,
SchedulerService(asyncio 60초 루프, D-7/D-1/D-0 Telegram push),
FastAPI lifespan 연동, GET /reminders/{user_id} 엔드포인트
- IDEA-1 대화 기반 RAG: IngestionService.store_text() 추가,
AgentService._maybe_index_conversation() — 응답 후 LLM 판단 → Qdrant 저장
(CONV_RAG_ENABLED=true 활성화, background task로 응답 속도 무관)
- IDEA-5 CRAG: AgentState에 crag_fallback_used 플래그 추가,
crag_check LangGraph 노드 — search_documents 결과 없으면 web_search 자동 주입,
route_after_crag으로 fallback 1회 루프 제어 (CRAG_ENABLED=true 활성화)
- IDEA-7 RAG Auto-Eval: eval/auto_tune.py — API 서버 없이 파라미터 조합별
context_precision/recall 비교, 최적 설정 추천
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+30
-1
@@ -1,4 +1,4 @@
|
||||
from datetime import date
|
||||
from datetime import date, datetime
|
||||
|
||||
from langchain_core.tools import tool
|
||||
|
||||
@@ -74,6 +74,35 @@ def make_memory_tools(profile_repo, user_id: str = "default"):
|
||||
return remember_user_info, recall_user_info
|
||||
|
||||
|
||||
def make_reminder_tools(reminder_repo, user_id: str = "default"):
|
||||
"""알림 등록/조회 Tool 쌍을 반환한다."""
|
||||
|
||||
@tool
|
||||
def set_reminder(remind_date: str, message: str) -> str:
|
||||
"""특정 날짜에 텔레그램으로 알림을 보냅니다.
|
||||
예방접종, 병원 예약, 기념일 등 기억해야 할 날짜를 등록하세요.
|
||||
- remind_date: 알림 날짜 (YYYY-MM-DD 형식). 날짜를 모르면 get_current_date를 먼저 호출하세요.
|
||||
- message: 알림 내용 (구체적으로 작성)
|
||||
등록 시 D-7(7일 전), D-1(하루 전), D-0(당일) 세 번 알림이 발송됩니다."""
|
||||
try:
|
||||
parsed = datetime.strptime(remind_date, "%Y-%m-%d").date()
|
||||
except ValueError:
|
||||
return f"날짜 형식이 잘못되었습니다. YYYY-MM-DD 형식으로 입력해 주세요. (예: 2026-07-01)"
|
||||
reminder_repo.add(user_id, parsed, message)
|
||||
return f"알림이 등록되었습니다. {remind_date}에 '{message}' 알림을 보내드릴게요."
|
||||
|
||||
@tool
|
||||
def list_reminders() -> str:
|
||||
"""등록된 예정 알림 목록을 조회합니다. (향후 30일 이내)"""
|
||||
items = reminder_repo.get_upcoming(user_id, days_ahead=30)
|
||||
if not items:
|
||||
return "등록된 예정 알림이 없습니다."
|
||||
lines = [f"- {r['remind_date']}: {r['message']}" for r in items]
|
||||
return "등록된 알림 목록:\n" + "\n".join(lines)
|
||||
|
||||
return set_reminder, list_reminders
|
||||
|
||||
|
||||
def make_search_tool(retriever_service, source_buffer: list | None = None):
|
||||
"""RetrieverService를 클로저로 감싼 문서 검색 Tool을 반환합니다.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user