Implementation:Hiyouga LLaMA Factory WebUI Interface
| Knowledge Sources | |
|---|---|
| Domains | WebUI, Application Entry Point, Gradio |
| Last Updated | 2026-02-06 19:00 GMT |
Overview
Main entry point module for the LLaMA Factory WebUI, responsible for assembling all Gradio components into a complete application and launching the web server.
Description
The interface.py module defines four functions that serve as the primary entry points for the WebUI. create_ui assembles the full WebUI with Train, Evaluate & Predict, Chat, and Export tabs (Export hidden in demo mode), wiring the Engine's resume and language change handlers. create_web_demo builds a minimal chat-only interface with just a language dropdown and an embedded chat box. run_web_ui and run_web_demo are launcher functions that configure server settings including IPv6 support (via GRADIO_IPV6), share mode (via GRADIO_SHARE), custom server name (via GRADIO_SERVER_NAME), and proxy fixes before starting the Gradio server with queuing enabled.
Usage
Use run_web_ui() to launch the full LLaMA Factory WebUI with all training, evaluation, inference, and export capabilities. Use run_web_demo() to launch a lightweight chat-only demo. These are the CLI entry points invoked by llamafactory-cli webui and llamafactory-cli webchat.
Code Reference
Source Location
- Repository: Hiyouga_LLaMA_Factory
- File: src/llamafactory/webui/interface.py
- Lines: 1-106
Signature
def create_ui(demo_mode: bool = False) -> "gr.Blocks": ...
def create_web_demo() -> "gr.Blocks": ...
def run_web_ui() -> None: ...
def run_web_demo() -> None: ...
Import
from llamafactory.webui.interface import create_ui, create_web_demo, run_web_ui, run_web_demo
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| demo_mode | bool | No (create_ui) | If True, enables demo mode (DuplicateButton shown, Export tab hidden, config persistence disabled). Default: False |
Outputs
| Name | Type | Description |
|---|---|---|
| demo (create_ui) | gr.Blocks | Fully assembled Gradio Blocks application with all tabs |
| demo (create_web_demo) | gr.Blocks | Minimal Gradio Blocks application with chat-only interface |
| (run_web_ui) | None | Launches the full WebUI server (blocking call) |
| (run_web_demo) | None | Launches the chat demo server (blocking call) |
Usage Examples
# Launching the full WebUI
from llamafactory.webui.interface import run_web_ui
run_web_ui()
# Server starts at http://0.0.0.0:7860
# Creating the UI programmatically for custom deployment
from llamafactory.webui.interface import create_ui
demo = create_ui(demo_mode=False)
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
# Launching the lightweight chat demo
from llamafactory.webui.interface import run_web_demo
run_web_demo()
Related Pages
- Hiyouga_LLaMA_Factory_WebUI_Engine - Engine class instantiated by create_ui and create_web_demo
- Hiyouga_LLaMA_Factory_WebUI_Top_Component - Top panel assembled as the first element in create_ui
- Hiyouga_LLaMA_Factory_WebUI_Eval_Component - Evaluation tab added within create_ui
- Hiyouga_LLaMA_Factory_WebUI_Infer_Component - Inference tab added within create_ui
- Hiyouga_LLaMA_Factory_WebUI_Export_Component - Export tab conditionally added within create_ui
- Hiyouga_LLaMA_Factory_WebUI_Chatbot - Chat box used by create_web_demo
- Hiyouga_LLaMA_Factory_WebUI_Common - Provides save_config wired to language input events