mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 20:35:19 +00:00
refac
This commit is contained in:
parent
ac0932f356
commit
bf3c807047
3 changed files with 11 additions and 10 deletions
|
|
@ -1404,7 +1404,6 @@ async def chat_completion(
|
||||||
form_data, metadata, events = await process_chat_payload(
|
form_data, metadata, events = await process_chat_payload(
|
||||||
request, form_data, user, metadata, model
|
request, form_data, user, metadata, model
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.debug(f"Error processing chat payload: {e}")
|
log.debug(f"Error processing chat payload: {e}")
|
||||||
if metadata.get("chat_id") and metadata.get("message_id"):
|
if metadata.get("chat_id") and metadata.get("message_id"):
|
||||||
|
|
@ -1424,6 +1423,14 @@ async def chat_completion(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await chat_completion_handler(request, form_data, user)
|
response = await chat_completion_handler(request, form_data, user)
|
||||||
|
if metadata.get("chat_id") and metadata.get("message_id"):
|
||||||
|
Chats.upsert_message_to_chat_by_id_and_message_id(
|
||||||
|
metadata["chat_id"],
|
||||||
|
metadata["message_id"],
|
||||||
|
{
|
||||||
|
"model": model_id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
return await process_chat_response(
|
return await process_chat_response(
|
||||||
request, response, form_data, user, metadata, model, events, tasks
|
request, response, form_data, user, metadata, model, events, tasks
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,9 @@ def get_sources_from_items(
|
||||||
# Note Attached
|
# Note Attached
|
||||||
note = Notes.get_note_by_id(item.get("id"))
|
note = Notes.get_note_by_id(item.get("id"))
|
||||||
|
|
||||||
if user.role == "admin" or has_access(user.id, "read", note.access_control):
|
if note and (
|
||||||
|
user.role == "admin" or has_access(user.id, "read", note.access_control)
|
||||||
|
):
|
||||||
# User has access to the note
|
# User has access to the note
|
||||||
query_result = {
|
query_result = {
|
||||||
"documents": [[note.data.get("content", {}).get("md", "")]],
|
"documents": [[note.data.get("content", {}).get("md", "")]],
|
||||||
|
|
|
||||||
|
|
@ -1381,14 +1381,6 @@ async def process_chat_response(
|
||||||
task_id = str(uuid4()) # Create a unique task ID.
|
task_id = str(uuid4()) # Create a unique task ID.
|
||||||
model_id = form_data.get("model", "")
|
model_id = form_data.get("model", "")
|
||||||
|
|
||||||
Chats.upsert_message_to_chat_by_id_and_message_id(
|
|
||||||
metadata["chat_id"],
|
|
||||||
metadata["message_id"],
|
|
||||||
{
|
|
||||||
"model": model_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
def split_content_and_whitespace(content):
|
def split_content_and_whitespace(content):
|
||||||
content_stripped = content.rstrip()
|
content_stripped = content.rstrip()
|
||||||
original_whitespace = (
|
original_whitespace = (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue