mirror of
https://github.com/open-webui/open-webui
synced 2024-12-28 06:42:47 +00:00
refac
This commit is contained in:
parent
6b25139d4f
commit
95da0734b6
@ -1238,7 +1238,7 @@ def search_web(request: Request, engine: str, query: str) -> list[SearchResult]:
|
||||
|
||||
|
||||
@router.post("/process/web/search")
|
||||
async def process_web_search(
|
||||
def process_web_search(
|
||||
request: Request, form_data: SearchForm, user=Depends(get_verified_user)
|
||||
):
|
||||
try:
|
||||
|
@ -9,6 +9,7 @@ import random
|
||||
import json
|
||||
import inspect
|
||||
from uuid import uuid4
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
|
||||
from fastapi import Request
|
||||
@ -412,7 +413,13 @@ async def chat_web_search_handler(
|
||||
)
|
||||
|
||||
try:
|
||||
results = await process_web_search(
|
||||
|
||||
# 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(
|
||||
**{
|
||||
@ -420,6 +427,7 @@ async def chat_web_search_handler(
|
||||
}
|
||||
),
|
||||
user,
|
||||
),
|
||||
)
|
||||
|
||||
if results:
|
||||
|
Loading…
Reference in New Issue
Block a user