mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-29 06:32:52 +00:00
refac
This commit is contained in:
parent
6acbfa7fee
commit
d5cd7f4907
3 changed files with 13 additions and 2 deletions
|
|
@ -145,6 +145,10 @@ async def compact_messages_for_request(
|
|||
'action': 'context_compaction',
|
||||
'description': 'Context compacted',
|
||||
'done': True,
|
||||
'checkpoint_message_id': (
|
||||
recent_messages[0].get('id') if recent_messages[0].get('role') == 'user' else None
|
||||
),
|
||||
'context_summary': summary,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ from open_webui.utils.access_control.files import get_owner_accessible_folder_fi
|
|||
from open_webui.utils.access_control.folders import has_folder_access
|
||||
from open_webui.utils.ask_user import stage_ask_user_tool_calls
|
||||
from open_webui.utils.chat import generate_chat_completion
|
||||
from open_webui.utils.chat_id import is_saved_chat_id
|
||||
from open_webui.utils.chat_id import is_saved_chat_id, is_temporary_chat_id
|
||||
from open_webui.utils.code_interpreter import execute_code_jupyter
|
||||
from open_webui.utils.context_compaction import compact_messages_for_request
|
||||
from open_webui.utils.files import (
|
||||
|
|
@ -2137,7 +2137,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
if regeneration_prompt:
|
||||
form_data['messages'].append({'role': 'user', 'content': regeneration_prompt})
|
||||
|
||||
if is_saved_chat_id(chat_id) and user_message_id:
|
||||
if (is_saved_chat_id(chat_id) or is_temporary_chat_id(chat_id)) and user_message_id:
|
||||
system_message = get_system_message(form_data.get('messages', []))
|
||||
chat_system_prompt = get_content_from_message(system_message) if system_message else ''
|
||||
|
||||
|
|
|
|||
|
|
@ -1588,6 +1588,9 @@
|
|||
message.statusHistory = [data];
|
||||
}
|
||||
} else if (type === 'context_compaction') {
|
||||
if (data?.checkpoint_message_id && history.messages[data.checkpoint_message_id]) {
|
||||
history.messages[data.checkpoint_message_id].contextSummary = data.context_summary;
|
||||
}
|
||||
handleContextCompactionStatus(data);
|
||||
} else if (type === 'chat:active') {
|
||||
if (!data?.active) {
|
||||
|
|
@ -4254,7 +4257,9 @@
|
|||
|
||||
if (message.role === 'user' && imageFiles.length > 0) {
|
||||
return {
|
||||
id: message.id,
|
||||
role: message.role,
|
||||
contextSummary: message?.contextSummary,
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
|
|
@ -4271,7 +4276,9 @@
|
|||
}
|
||||
|
||||
return {
|
||||
id: message.id,
|
||||
role: message.role,
|
||||
contextSummary: message?.contextSummary,
|
||||
content: message?.merged?.content ?? message.content,
|
||||
model: message.model,
|
||||
meta: message.meta
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue