Qwen-Agent icon indicating copy to clipboard operation
Qwen-Agent copied to clipboard

feat: Allow custom HTTP interfaces in WebUI

Open ChengChen1113 opened this issue 11 months ago • 0 comments

This change introduces the ability for you to define your own custom HTTP API endpoints alongside the Gradio-based WebUI.

Key changes:

  • The WebUI.run method in qwen_agent/gui/web_ui.py now accepts an optional custom_app_setup_fn parameter.
  • If provided, this function is called with the underlying FastAPI application instance before the Gradio app is launched, allowing you to add your own routes.
  • Added documentation for this new feature in the WebUI.run docstring.
  • Included a new example examples/web_ui_with_custom_api.py demonstrating how to add custom API endpoints.
  • Added a test case in tests/gui/test_web_ui.py to verify that custom APIs function correctly alongside the Gradio UI.

This enhancement provides greater flexibility for developers who want to expose both a rich Gradio UI and a programmatic API from the same service instance.

ChengChen1113 avatar May 22 '25 10:05 ChengChen1113