Skip to content
Projects

About

Cyber Doctor, also known as “Cyber Huatuo,” is a multimodal intelligent agent based on large language models. It lets you set up a local multimodal LLM with one click. Once connected to medical and health knowledge graphs and databases, it can provide preliminary disease assessments, analyze medical records, and answer questions about specialized knowledge, serving as your personal doctor. The project can help share medical resources across regions, enabling more people to improve their health with large language models.

Data & Analytics

How these counts are measured

Measured star growth

in 24h
0
in 7 days
+2
in 15 days
+7
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README_en.md

Original

Cyber Doctor · 赛博华佗

Cyber Doctor, an open-source health knowledge assistant

An open-source health knowledge assistant that brings local document retrieval, a medical knowledge graph, web search, and multimodal tools into one conversation.

GitHub stars GitHub forks GitHub contributors GitHub issues GPL-3.0 license

Interface · Features · Architecture · Run locally · Project history · Original Bilibili demo · 简体中文

View the GIF preview and video links

Screen recording of Cyber Doctor in use

MP4 demo (2 min 38 sec, 4.3 MB) · Original full demo on Bilibili

If Cyber Doctor's code or development notes help you learn about agents or retrieval-augmented generation, consider starring the repository.

Ask a health question, upload a photo of a medical report, or switch to voice mode. Cyber Doctor identifies what you want to do, selects the appropriate tool, and streams the answer in the chat.

Project background

Uneven access to healthcare resources can make reliable health information and initial guidance hard to find. Our team started Cyber Doctor during a summer practical training course at Southeast University. We built it to explain common symptoms, help readers understand medical reports, and answer everyday health questions.

The same architecture can support other specialized topics by replacing the local documents and knowledge graph with data from another domain.

Interface

Cyber Doctor v2 home screen with session history, text and voice modes, suggested health questions, and an attachment-enabled message composer

The Gradio 6 interface keeps conversation history and the text and voice mode switch in the sidebar. The main panel includes suggested health questions, a collapsible model reasoning panel, and a message composer that accepts images, audio, PDF, DOCX, and text files.

Features

Version 2 focuses on retrieval-augmented generation (RAG), medical knowledge graph RAG, web search, and image and voice interaction. The app can also generate images, video, and audio. The repository includes earlier extensions for generating PowerPoint presentations and Word documents.

Feature demos

Local knowledge base Web search
Answer citing local knowledge base files Web search results for WHO healthy eating recommendations
LangChain loads multiple file formats, CoROM generates Chinese text embeddings, and FAISS retrieves up to six passages. The answer lists the source filenames. The app tries You.com Search first. If the key is missing or the API returns no usable results, it uses the built-in Baidu and Bing crawlers. A temporary FAISS index ranks the retrieved passages and the answer includes source links.
Medical report interpretation Voice input and output
Interpretation of a complete blood count with a five-part differential Voice input and spoken response in Cyber Doctor
Upload an image of a medical report, such as a complete blood count. Pillow identifies the format, and the app encodes the image in Base64 and sends it to the vision model to explain the reported values and flag abnormal results. pydub converts recordings, local Whisper transcribes Chinese speech offline, and Edge TTS reads the answer aloud after the app cleans up Markdown and medical symbols.

Medical knowledge graph RAG

Neo4j stores how conditions, symptoms, risk factors, and health management measures relate to one another. An Aho–Corasick matcher (pyahocorasick) finds multiple entity names in a question in one pass. The app uses a parameterized Cypher query to retrieve relationships in both directions, then passes those relationships to the language model to compose the answer.

Diabetes knowledge graph in Neo4j Answer generated from the graph
Medical knowledge graph for diabetes in Neo4j Diabetes management guidance generated from the knowledge graph
The example shows 16 nodes and 14 relationships covering health management, possible symptoms, risk factors, and clinical characteristics. The response uses the retrieved relationships to explain management measures and risk factors.

Explicit tool commands

Include one of these Chinese phrases in a question to select a tool directly.

Phrase Tool
根据知识库 (use the knowledge base) Retrieve passages from the local knowledge base.
根据知识图谱 (use the knowledge graph) Query the medical knowledge graph in Neo4j.
搜索 (search) Search the web and include source links.
深度研究 (deep research) Run a research query through the You.com Research API.

Architecture

A single agent routes requests to tools. Gradio collects text, images, and audio. The app first checks for explicit instructions and image attachments. For other requests, a language model classifies the intent using examples. The app checks the resulting label against an allowlist and looks up the corresponding tool in a routing table.

flowchart LR
    A["Gradio interface<br/>Text, images, and voice"] --> B["Two-stage intent detection<br/>Rules and model classification"]
    B --> C["Table-driven tool routing"]
    C --> D["Local RAG<br/>CoROM and FAISS"]
    C --> E["Knowledge graph RAG<br/>Aho–Corasick and Neo4j / Cypher"]
    C --> F["Web search<br/>You.com, built-in crawlers, and temporary RAG"]
    C --> G["Multimodal tools<br/>Vision model, Whisper, and Edge TTS"]
    D --> H["Language model combines context<br/>Responses stream per session"]
    E --> H
    F --> H
    G --> H
Layer Implementation
Interface and concurrency Python 3.12, Gradio 6, and custom CSS. session_jobs.py manages background threads and isolates streaming state and cancellation by session.
Model access Clientfactory uses the OpenAI SDK with model settings from the project's .env file.
Local RAG LangChain loads documents in parallel. RecursiveCharacterTextSplitter uses 2,000-character chunks with a 100-character overlap. ModelScope supplies the CoROM Chinese embedding model, and FAISS indexes the passages.
Knowledge graph RAG Neo4j 5, py2neo, Aho–Corasick entity matching with pyahocorasick, and parameterized Cypher queries for relationships in both directions.
Web search You.com Search and Research APIs, built-in Baidu and Bing crawlers using requests and Beautiful Soup, encoding detection for pages such as GBK, and a temporary FAISS index for ranking passages.
Multimodal processing Pillow and Base64 for image input, pydub and local Whisper for offline Chinese speech recognition, and edge-tts for speech synthesis in multiple dialects. Text is cleaned before synthesis to handle medical symbols and Unicode characters.

Run locally

[!NOTE] Use Python 3.12 and uv to manage the virtual environment and locked dependencies. Audio conversion and voice input also require FFmpeg on your PATH. uv documentation

1. Clone and set up the environment

git clone --branch v2 https://github.com/ZeroTang05/cyber-doctor.git
cd cyber-doctor
uv sync

On macOS or Linux, copy the environment template.

cp .env.example .env

On Windows, use PowerShell.

Copy-Item .env.example .env

2. Configure a model provider

The app reads model configuration exclusively from the project's .env file. Set LLM_BASE_URL, LLM_MODEL_NAME, and LLM_API_KEY for text chat, intent detection, knowledge-base answers, and PowerPoint and Word content generation.

Image generation, image understanding, and video generation can override individual settings with IMG_GEN_*, IMG_DESCRIBE_*, and VIDEO_GEN_*. Blank fields inherit the corresponding main model settings. For example, setting only IMG_GEN_MODEL_NAME keeps LLM_BASE_URL and LLM_API_KEY for image generation. See the configuration template for all fields.

3. Start the app

uv run python app.py

Open http://127.0.0.1:10032 in your browser.

Optional integrations

Module Setup
Local knowledge base Add PDF, DOCX, TXT, Markdown, CSV, or HTML files to konwledge-base/. The repository includes examples on hypertension, diabetes, and healthy living. On first use, the app downloads CoROM from ModelScope and builds a FAISS index.
Web search and deep research Set YOUCOM_API_KEY in .env to enable You.com Search and Research. Standard web search uses the built-in Baidu and Bing crawlers when no key is set. Deep research requires the key. You.com API documentation
Medical knowledge graph Start Neo4j Community Edition. Set the connection URL, username, and database in config/config-web.yaml, and set NEO4J_PASSWORD in .env. Run uv run python kg/import_medical_graph.py to import the sample graph.
Import a larger OpenKG medical knowledge graph from a dump

The first release used OpenKG's graph of common household illnesses. It generally works with the default graph schema in config/config-web.yaml. OpenKG datasets · Common household illnesses knowledge graph

For setup examples, see the Windows installation guide (Chinese) and the Docker deployment guide (Chinese).

  1. Download the .dump file and rename it to match the target database, for example neo4j.dump.

  2. Stop Neo4j with neo4j stop on Windows or sudo neo4j stop on Linux.

  3. Load the dump. Back up any existing database first, since --overwrite-destination=true replaces it. Neo4j dump restore guide

    neo4j-admin database load neo4j --from-path=/path/to/dump-folder/ --overwrite-destination=true
    
  4. If Neo4j reports that the store format needs migration, run the following command. Use your target database name in both commands if it differs from neo4j. Neo4j 5 migration guide

    neo4j-admin database migrate neo4j
    
  5. Restart Neo4j with neo4j start or sudo neo4j start.

Repository structure
cyber-doctor/
├── .env / .env.example     # Local settings and template
├── app.py                  # Gradio entry point, voice input, and multimodal interaction
├── interface.css           # Custom interface styles
├── session_jobs.py         # Background jobs, session isolation, and stream cancellation
├── env.py                  # Environment variable loading
├── pyproject.toml         # Project metadata and dependencies
├── uv.lock                 # Cross-platform dependency lockfile
├── .python-version         # Python 3.12 version pin
├── konwledge-base/         # Local health education documents
├── Internet/               # You.com search and built-in Baidu and Bing crawlers
├── audio/                  # Speech synthesis and cleanup of text and medical symbols
├── client/                 # Model provider clients and factory
├── config/                 # YAML settings and loader
├── kg/                     # Neo4j connection, Cypher queries, and sample graph import
├── model/                  # Local, graph, and web retrieval models
├── qa/                     # Intent detection and table-driven tool routing
├── rag/                    # Retrieval-augmented answers and source filenames
├── ppt_docx/               # Earlier document generation extensions
├── README/                 # Documentation media and v2 screenshots
└── resource/               # Static assets

Project history

September 2024. Cyber Doctor began as a Django and Vue course project with accounts and personal knowledge base management. My teammates handled those parts, so I extracted the features I knew best into a lightweight Python and Gradio app that people could clone and run.

October 2025. I was surprised that people were still discovering and starring the project. It gives anyone learning RAG a small working example to explore. Building it when language models were less capable gave me a foundation for later work on agents, and I want to keep the parts of this project that reflect how our team thought through the problems.

November 2026. I brought the project back for another course assignment and took the opportunity to refresh the interface.

Questions and suggestions are welcome in issues and pull requests.

Contributors and license

Thanks to YM, L-MARK, Goku-30, laobaishui, DStevenFelix, and everyone else who contributed.

The project draws on meet-libai and is licensed under GPL-3.0.

Star History

Explore related projects

Loading…