Implement Phase 4~14: LangGraph Agent, RAG pipeline, Gradio Web UI, voice interface

- Upgrade LLM to Qwen3-14B-4bit with Thinking mode (MlxChatModel as LangChain BaseChatModel)
- Add LangGraph ReAct agent with tool calling loop (search_documents, web_search, get_current_date, remember/recall_user_info)
- Add RAG pipeline: BAAI/bge-m3 embeddings + Qdrant vector store + semantic chunking (SemanticSplitter via cosine similarity)
- Replace fixed-size RecursiveCharacterTextSplitter with meaning-based SemanticSplitter (numpy only, no extra deps)
- Add Gradio Web UI (app.py): chat, document ingestion, document management tabs
- Add multi-user support (user_id isolation in DB + per-user agent cache + dropdown selector)
- Add conversation history restore from MySQL on agent init (Phase 11)
- Add UserProfileRepository for persistent user profile (remember/recall tools)
- Add thread-local DB connections to fix pymysql thread-safety with LangGraph ToolNode
- Add Phase 14 voice interface: Whisper STT (microphone → text) + macOS TTS (say -v Yuna)
- Enforce search_documents-first policy in system prompt and tool descriptions
- Update ROADMAP2.md: Phase 14 완료, Phase 13 청킹 부분 완료

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sal
2026-05-27 14:06:22 +09:00
parent cd41e9e33e
commit 06bcdb03ac
20 changed files with 1934 additions and 47 deletions
+6 -4
View File
@@ -8,14 +8,16 @@ class ConversationRepository:
def __init__(self, db: DatabaseService):
self._db = db
def create_conversation(self) -> int:
def create_conversation(self, user_id: str = "default") -> int:
return self._db.execute_write(
"INSERT INTO td_conversations () VALUES ()"
"INSERT INTO td_conversations (user_id) VALUES (%s)",
(user_id,),
)
def get_latest_conversation_id(self) -> int | None:
def get_latest_conversation_id(self, user_id: str = "default") -> int | None:
rows = self._db.execute(
"SELECT id FROM td_conversations ORDER BY created_at DESC LIMIT 1"
"SELECT id FROM td_conversations WHERE user_id = %s ORDER BY created_at DESC LIMIT 1",
(user_id,),
)
return rows[0]["id"] if rows else None