How moamedmer68-commits/clinic-ai-customer-service works
Clinic AI Customer Service is a prototype chat service for clinic FAQs and appointment operations. Patients use the Streamlit client or call the authenticated FastAPI endpoint; the API manages session-scoped conversation state and invokes the LangGraph agent. The agent routes FAQ requests to grounded retrieval, appointment requests to structured availability and mutation tools, and sensitive or unresolved cases to a local human-handoff queue. Appointment changes require a separate exact confirmation before execution. Source excerpts establish the principal API, routing, storage and helper relationships; unsampled subsystem links are omitted where the caller is not shown.
Main entry points: main.py FastAPI endpoints · agent.py LangGraph agent · streamlit_ui.py Streamlit chat · knowledge_base.py FAQ retrieval
Components 17
Patient interface
- Streamlit chat
streamlit_ui.py - UI helpers
ui_helpers.py
API and conversation
- FastAPI endpoints
main.py - Request models
data_models/models.py - Conversation checkpoint
main.py - Thread key
utils/session.py
Agent routing
- LangGraph agent
agent.py - Routing prompts
prompt_library/prompt.py - OpenAI chat model
utils/llms.py
FAQ retrieval
- FAQ retrieval
knowledge_base.py - Approved FAQ content
data/clinic_faq.json - Persistent FAQ index
knowledge_base.py
Appointments and support
- Appointment tools
toolkit/toolkits.py - Appointment state
data/doctor_availability.csv - Pending action gate
support/pending_actions.py - Human handoff queue
support/handoff.py
Other components
- Patient
Connections 19
- Patient → Streamlit chat: chats through
README.md - Streamlit chat → FastAPI endpoints: submits requests
README.md - Streamlit chat → UI helpers: uses helpers
streamlit_ui.py - Patient → FastAPI endpoints: calls directly
README.md - FastAPI endpoints → Request models: validates requests
main.py - FastAPI endpoints → Thread key: derives thread key
main.py - FastAPI endpoints → Conversation checkpoint: checkpoints conversation
main.py - FastAPI endpoints → LangGraph agent: invokes workflow
main.py - LangGraph agent → Routing prompts: uses routing prompt
agent.py - LangGraph agent → OpenAI chat model: invokes model
agent.py - LangGraph agent → FAQ retrieval: retrieves FAQ answers
agent.py - FAQ retrieval → Approved FAQ content: reads configured content
README.md - FAQ retrieval → Persistent FAQ index: persists vector index
README.md - LangGraph agent → Appointment tools: dispatches appointment tools
agent.py - Appointment tools → Appointment state: reads and updates
toolkit/toolkits.py - LangGraph agent → Pending action gate: prepares mutations
agent.py - FastAPI endpoints → Pending action gate: executes confirmed action
README.md - LangGraph agent → Human handoff queue: creates escalations
agent.py - FastAPI endpoints → Human handoff queue: returns case status
README.md