mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #13111] [MERGED] perf: Concurrent processing for web search queries #38734
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/13111
Author: @tth37
Created: 4/21/2025
Status: ✅ Merged
Merged: 5/2/2025
Merged by: @tjbck
Base:
dev← Head:perf_multi_thread_web_searching📝 Commits (3)
4b451b9perf: Multi-thread web searching5b9c1defix: Translatable 'Searching the web'cf2d7derefac: Implicit asyncio create_task📊 Changes
2 files changed (+25 additions, -19 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+23 -19)📝
src/lib/components/chat/Messages/ResponseMessage.svelte(+2 -0)📄 Description
Problem Description
This PR addresses the same issue as #13045 -- improving the performance of multiple web search queries -- but with a simpler and cleaner approach.
Currently, the
async process_web_searchhandler processes queries sequentially, performing searches and loading pages one at a time. This creates a bottleneck when multiple queries are generated, significantly slowing down overall performance.Solution
Since
process_web_searchis an I/O-intensive operation, we can easily optimize it by parallelizing the execution usingasynciotasks andasyncio.gather. This allows multiple search queries to run concurrently, effectively reducing latency.Breaking Change
Previously, the backend emitted individual events (e.g.,
"Searching {{searchQuery}}") for each query. Due to parallel processing, this is no longer feasible. Instead, we now emit a single event ("Searching the web"), aligning with common practices in other LLM web UIs.Testing
In typical cases, parallel execution introduces minimal overhead, with total latency approaching the lower-bound duration of the slowest single query.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the CONTRIBUTOR_LICENSE_AGREEMENT, and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.