Qwen-Agent
Qwen-Agent copied to clipboard
feat: Allow custom HTTP interfaces in WebUI
This change introduces the ability for you to define your own custom HTTP API endpoints alongside the Gradio-based WebUI.
Key changes:
- The
WebUI.runmethod inqwen_agent/gui/web_ui.pynow accepts an optionalcustom_app_setup_fnparameter. - 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.rundocstring. - Included a new example
examples/web_ui_with_custom_api.pydemonstrating how to add custom API endpoints. - Added a test case in
tests/gui/test_web_ui.pyto 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.