01
Backend Systems · AI Applications
MediAgent – RAG-based Medical AI Assistant
A production-style medical AI assistant combining FastAPI and ReAct orchestration, hybrid retrieval, short- and long-term memory, and structured PostgreSQL medical-record workflows.
FastAPIRAGReActPostgreSQLRedisMilvusBM25LLM
Technical Implementation
- Built a FastAPI agent with ReAct planning, intent routing, and a confidence-driven decision policy orchestrating four specialized skills for local medical QA, web search, medical-record insertion, and field-level record retrieval.
- Built a local medical RAG pipeline over 72,877 retrieval chunks from 11,274 XML files and 16,407 question-answer documents using contextual query rewriting, Milvus vector search, BM25 hybrid retrieval, and reranking.
- Designed Redis-backed short-term memory with sliding-window retention and rolling LLM summarization.
- Built long-term memory with LLM-based extraction, skip / merge / create update decisions, Redis record storage, and Milvus semantic recall for personalized cross-session responses.
- Developed a PostgreSQL medical-record module with two normalized tables and three custom indexes for structured insertion and field-level retrieval of allergies, medications, symptoms, diagnoses, procedures, and vitals.
- Implemented asynchronous, memory-aware agent endpoints for concurrent multi-user requests.
Impact
- Improved Recall@5 by 9.4 percentage points and Precision@5 by 2.0 percentage points, while increasing Hit@5 from 84.0% to 100.0%.
- Reduced prompt memory tokens by 61.9%, from 737 to 281, while preserving multi-turn conversational context.
- Achieved 4.5× higher throughput under 10 concurrent multi-user agent requests in local benchmarks.
Metrics
Retrieval pipeline built over 72,877 chunks from 11,274 XML files and 16,407 question-answer documents; throughput measured locally under 10 concurrent multi-user requests.
- Recall@5 improvement
- +9.4 pp
- Precision@5 improvement
- +2.0 pp
- Hit@5, up from 84.0%
- 100.0%
- Throughput at 10 concurrent requests
- 4.5×