mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
refac
This commit is contained in:
parent
79ce6e0a3f
commit
947f5600d6
@ -23,7 +23,7 @@ from open_webui.models.users import Users
|
|||||||
from open_webui.socket.main import (
|
from open_webui.socket.main import (
|
||||||
get_event_call,
|
get_event_call,
|
||||||
get_event_emitter,
|
get_event_emitter,
|
||||||
get_user_id_from_session_pool,
|
get_active_status_by_user_id,
|
||||||
)
|
)
|
||||||
from open_webui.routers.tasks import (
|
from open_webui.routers.tasks import (
|
||||||
generate_queries,
|
generate_queries,
|
||||||
@ -896,7 +896,7 @@ async def process_chat_response(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Send a webhook notification if the user is not active
|
# Send a webhook notification if the user is not active
|
||||||
if get_user_id_from_session_pool(metadata["session_id"]) is None:
|
if get_active_status_by_user_id(user.id) is None:
|
||||||
webhook_url = Users.get_user_webhook_url_by_id(user.id)
|
webhook_url = Users.get_user_webhook_url_by_id(user.id)
|
||||||
if webhook_url:
|
if webhook_url:
|
||||||
post_webhook(
|
post_webhook(
|
||||||
@ -1002,11 +1002,22 @@ async def process_chat_response(
|
|||||||
"content": content,
|
"content": content,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await event_emitter(
|
||||||
|
{
|
||||||
|
"type": "chat:completion",
|
||||||
|
"data": data,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
done = "data: [DONE]" in line
|
done = "data: [DONE]" in line
|
||||||
title = Chats.get_chat_title_by_id(metadata["chat_id"])
|
|
||||||
|
|
||||||
if done:
|
if done:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
title = Chats.get_chat_title_by_id(metadata["chat_id"])
|
||||||
data = {"done": True, "content": content, "title": title}
|
data = {"done": True, "content": content, "title": title}
|
||||||
|
|
||||||
if not ENABLE_REALTIME_CHAT_SAVE:
|
if not ENABLE_REALTIME_CHAT_SAVE:
|
||||||
@ -1020,10 +1031,7 @@ async def process_chat_response(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Send a webhook notification if the user is not active
|
# Send a webhook notification if the user is not active
|
||||||
if (
|
if get_active_status_by_user_id(user.id) is None:
|
||||||
get_user_id_from_session_pool(metadata["session_id"])
|
|
||||||
is None
|
|
||||||
):
|
|
||||||
webhook_url = Users.get_user_webhook_url_by_id(user.id)
|
webhook_url = Users.get_user_webhook_url_by_id(user.id)
|
||||||
if webhook_url:
|
if webhook_url:
|
||||||
post_webhook(
|
post_webhook(
|
||||||
@ -1037,9 +1045,6 @@ async def process_chat_response(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
|
|
||||||
await event_emitter(
|
await event_emitter(
|
||||||
{
|
{
|
||||||
"type": "chat:completion",
|
"type": "chat:completion",
|
||||||
|
Loading…
Reference in New Issue
Block a user