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")
|
@router.post("/process/web/search")
|
||||||
async def process_web_search(
|
def process_web_search(
|
||||||
request: Request, form_data: SearchForm, user=Depends(get_verified_user)
|
request: Request, form_data: SearchForm, user=Depends(get_verified_user)
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
@ -9,6 +9,7 @@ import random
|
|||||||
import json
|
import json
|
||||||
import inspect
|
import inspect
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
|
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
@ -412,15 +413,22 @@ async def chat_web_search_handler(
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
results = await process_web_search(
|
|
||||||
request,
|
# Offload process_web_search to a separate thread
|
||||||
SearchForm(
|
loop = asyncio.get_running_loop()
|
||||||
**{
|
with ThreadPoolExecutor() as executor:
|
||||||
"query": searchQuery,
|
results = await loop.run_in_executor(
|
||||||
}
|
executor,
|
||||||
),
|
lambda: process_web_search(
|
||||||
user,
|
request,
|
||||||
)
|
SearchForm(
|
||||||
|
**{
|
||||||
|
"query": searchQuery,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
user,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
if results:
|
if results:
|
||||||
await event_emitter(
|
await event_emitter(
|
||||||
|
Loading…
Reference in New Issue
Block a user