refac
This commit is contained in:
1 parent
71d6212ab8
commit
ac3449cac9
3 files changed
+2368
-2396
No files matched your search
@@ -1228,8 +1228,10 @@ async def chat_completion(
|
|||||||
status_code=status.HTTP_403_FORBIDDEN,
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
detail=ERROR_MESSAGES.DEFAULT(),
|
detail=ERROR_MESSAGES.DEFAULT(),
|
||||||
)
|
)
|
||||||
target_message_id = message_ids[0]['message_id'] if message_ids else None
|
for entry in message_ids:
|
||||||
if target_message_id:
|
target_message_id = entry.get('message_id')
|
||||||
|
if not target_message_id:
|
||||||
|
continue
|
||||||
target_message = await Messages.get_message_by_id(target_message_id)
|
target_message = await Messages.get_message_by_id(target_message_id)
|
||||||
if target_message and target_message.channel_id != channel.id:
|
if target_message and target_message.channel_id != channel.id:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
@@ -848,11 +848,14 @@ async def _make_channel_emitter(request_info):
|
|||||||
async def _emit_channel_update(content: str, done: bool = False):
|
async def _emit_channel_update(content: str, done: bool = False):
|
||||||
from open_webui.models.messages import MessageForm, Messages
|
from open_webui.models.messages import MessageForm, Messages
|
||||||
|
|
||||||
|
msg = await Messages.get_message_by_id(message_id)
|
||||||
|
if not msg or msg.channel_id != channel_id:
|
||||||
|
return
|
||||||
|
|
||||||
update_form = MessageForm(content=content)
|
update_form = MessageForm(content=content)
|
||||||
if done:
|
if done:
|
||||||
# Merge done flag into existing meta (preserve model_id etc.)
|
# Merge done flag into existing meta (preserve model_id etc.)
|
||||||
msg = await Messages.get_message_by_id(message_id)
|
existing_meta = msg.meta or {}
|
||||||
existing_meta = (msg.meta or {}) if msg else {}
|
|
||||||
update_form = MessageForm(
|
update_form = MessageForm(
|
||||||
content=content,
|
content=content,
|
||||||
meta={**existing_meta, 'done': True},
|
meta={**existing_meta, 'done': True},
|
||||||
|
|||||||
Reference in new issue
Block a user