support async load for websearch

This commit is contained in:
Yimi81
2025-02-14 07:05:10 +00:00
parent 304aed0f13
commit ceef600223
3 changed files with 68 additions and 20 deletions

View File

@@ -334,21 +334,15 @@ async def chat_web_search_handler(
try:
# Offload process_web_search to a separate thread
loop = asyncio.get_running_loop()
with ThreadPoolExecutor() as executor:
results = await loop.run_in_executor(
executor,
lambda: process_web_search(
request,
SearchForm(
**{
"query": searchQuery,
}
),
user,
),
)
results = await process_web_search(
request,
SearchForm(
**{
"query": searchQuery,
}
),
user,
)
if results:
await event_emitter(