How warma10032/cyber-doctor works
Project Type and Purpose
• This is a full-stack, multi-modal AI assistant (“cyber-doctor”) built in Python, using Gradio for UI.
• It integrates text, audio, image, document (PPT/Word) processing, RAG (Retrieval-Augmented Generation), knowledge-graph (Neo4j) queries, web search crawlers, and LLM API clients to offer medical-domain Q&A, diagnosis support, and content generation.
File Structure Analysis
• Top level:
• app.py – Gradio UI & orchestrator
• env.py, config/ – environment & YAML config
• client/ – LLM client factory & implementations (OpenAI, zhipuAI, Ollama, custom)
• Internet/, rag/, qa/, audio/, ppt_docx/ – feature modules (web search, RAG chain, Q&A pipeline, audio I/O, PPT/Word generation)
• model/ – RAG vector store & service implementations for Internet, KG, file-based retrieval
• kg/ – Neo4j graph access
• resource/ – static assets (images)
• Patterns:
• Orchestrator (app.py) ties UI inputs to module-specific “chains.”
• Each feature module implements a chain → calls into model/service → uses client to invoke LLM or external service.
• Services are layered: feature_chains → model_service → client → external APIs/datastores.
Key README Insights
• Uses Gradio for front-end, LangChain-style chains for orchestration.
• Supports multiple modalities (text, image, audio, file).
• External dependencies: OpenAI/ZhipuAI/etc. APIs, Neo4j graph DB, web search via crawler, edge-tts/whisper for STT/TTS.
Main Components
a. Frontend (Gradio)
b. Orchestrator / API Layer (app.py)
c. Feature Modules (QA, RAG Chain, Internet Chain, Audio I/O, PPT/Word Generation)
d. Model & Service Layer (model/*, kg/Graph)
e. Client Layer (client factory & specific clients)
f. External Dependencies:
• LLM APIs (OpenAI, ZhipuAI, Ollama, custom)
• Neo4j (Knowledge Graph)
• Web (crawler)
• STT/TTS Services
g. Configuration (.env, config-web.yaml)
Relationships & Data Flow
• User Interaction → Gradio UI
• UI input → app.py selects feature chain based on input type
• Feature chain calls corresponding “service” in model/ or module/
• Service may:
• Query vector store (RAG) or Neo4j (KG)
• Invoke Internet crawler
• Extract/generate audio
• Generate PPT/Word content
• Services call clientfactory → instantiate LLM client → call external LLM API
• External API returns text or embeddings → propagate back up
• app.py aggregates responses → UI output (text, audio, file)
Architectural Patterns & Principles
• Chain-of-Responsibility (LangChain style) for modular pipelines
• Factory Pattern for LLM client instantiation
• Layered Architecture: UI → Orchestrator → Feature Modules → Services → Clients → External
• Separation of concerns: each module handles a single modality or retrieval method
• Configurable via .env and config-web.yaml for extensibility