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:
@@ -1,25 +1,23 @@
|
||||
import asyncio
|
||||
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
from container import Container
|
||||
from services.chat.chat_service import ChatService
|
||||
|
||||
|
||||
def main() -> None:
|
||||
async def main_async() -> None:
|
||||
container = Container()
|
||||
|
||||
ui = container.ui_service()
|
||||
model = container.model_service()
|
||||
bus = container.event_bus()
|
||||
|
||||
db = container.db_service()
|
||||
repo = container.conversation_repository()
|
||||
|
||||
bus.subscribe(ChatService.EVENT_TOKEN, container.stream_token_handler())
|
||||
bus.subscribe(ChatService.EVENT_END, container.stream_end_handler())
|
||||
|
||||
ui.show_banner(container.config().model_id)
|
||||
model.load()
|
||||
db.connect()
|
||||
db.init_schema()
|
||||
|
||||
chat = container.chat_service()
|
||||
ui.show_banner(container.config().model_id)
|
||||
|
||||
# AgentService 초기화 — MlxChatModel 모델 로딩 + LangGraph 그래프 구성 포함
|
||||
agent = container.agent_service()
|
||||
|
||||
while True:
|
||||
try:
|
||||
@@ -36,15 +34,18 @@ def main() -> None:
|
||||
break
|
||||
|
||||
if ui.is_reset_command(user_input):
|
||||
repo.create_conversation()
|
||||
chat = container.chat_service()
|
||||
agent.reset()
|
||||
print("\n[대화가 초기화되었습니다.]\n")
|
||||
continue
|
||||
|
||||
ui.show_assistant_prefix()
|
||||
chat.respond(user_input)
|
||||
async for token in agent.stream_response(user_input):
|
||||
print(token, end="", flush=True)
|
||||
print("\n")
|
||||
|
||||
db.close()
|
||||
|
||||
def main() -> None:
|
||||
asyncio.run(main_async())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user