mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
refac
Some checks are pending
Python CI / Ruff Format (3.11) (push) Waiting to run
Python CI / Ruff Format (3.12) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true
USE_CUDA_VER=cu126
free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true
USE_CUDA_VER=cu126
free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / merge (map[name:cuda suffix:-cuda]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:cuda126 suffix:-cuda126]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:main suffix:]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:ollama suffix:-ollama]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:slim suffix:-slim]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / notify-helm-charts (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (, main) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda, cuda) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda126, cuda126) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-ollama, ollama) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-slim, slim) (push) Blocked by required conditions
Frontend Build / Format & Build (push) Waiting to run
Frontend Build / Unit Tests (push) Waiting to run
Some checks are pending
Python CI / Ruff Format (3.11) (push) Waiting to run
Python CI / Ruff Format (3.12) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true
USE_CUDA_VER=cu126
free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true
USE_CUDA_VER=cu126
free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / merge (map[name:cuda suffix:-cuda]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:cuda126 suffix:-cuda126]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:main suffix:]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:ollama suffix:-ollama]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:slim suffix:-slim]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / notify-helm-charts (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (, main) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda, cuda) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda126, cuda126) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-ollama, ollama) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-slim, slim) (push) Blocked by required conditions
Frontend Build / Format & Build (push) Waiting to run
Frontend Build / Unit Tests (push) Waiting to run
This commit is contained in:
parent
74a7902821
commit
5caa91a493
1 changed files with 23 additions and 2 deletions
|
|
@ -417,6 +417,20 @@ class ChatTable:
|
||||||
|
|
||||||
return changed
|
return changed
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _last_descendant_id(messages: dict, message_id: str) -> str:
|
||||||
|
seen_ids = set()
|
||||||
|
while message_id in messages and message_id not in seen_ids:
|
||||||
|
seen_ids.add(message_id)
|
||||||
|
message = messages[message_id]
|
||||||
|
child_ids = message.get('childrenIds') if isinstance(message, dict) else []
|
||||||
|
child_ids = child_ids if isinstance(child_ids, list) else []
|
||||||
|
next_id = next((child_id for child_id in reversed(child_ids) if child_id in messages), None)
|
||||||
|
if not next_id:
|
||||||
|
break
|
||||||
|
message_id = next_id
|
||||||
|
return message_id
|
||||||
|
|
||||||
def _repair_chat_current_id(self, chat: dict) -> bool:
|
def _repair_chat_current_id(self, chat: dict) -> bool:
|
||||||
history = chat.get('history')
|
history = chat.get('history')
|
||||||
if not isinstance(history, dict):
|
if not isinstance(history, dict):
|
||||||
|
|
@ -449,6 +463,12 @@ class ChatTable:
|
||||||
and current_message.get('role')
|
and current_message.get('role')
|
||||||
and not current_is_bad_leaf
|
and not current_is_bad_leaf
|
||||||
):
|
):
|
||||||
|
if current_message.get('contextSummary') or current_message.get('context_summary'):
|
||||||
|
last_descendant_id = self._last_descendant_id(messages, current_id)
|
||||||
|
if last_descendant_id != current_id:
|
||||||
|
history['currentId'] = last_descendant_id
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
latest_leaf_id = None
|
latest_leaf_id = None
|
||||||
|
|
@ -930,8 +950,7 @@ class ChatTable:
|
||||||
'role': role,
|
'role': role,
|
||||||
'timestamp': message.get('timestamp') or int(time.time()),
|
'timestamp': message.get('timestamp') or int(time.time()),
|
||||||
}
|
}
|
||||||
|
history['currentId'] = message_id
|
||||||
history['currentId'] = message_id
|
|
||||||
return messages[message_id]
|
return messages[message_id]
|
||||||
|
|
||||||
async def backfill_messages_by_chat_id(self, chat_id: str, user_id: str, messages: dict[str, dict]) -> None:
|
async def backfill_messages_by_chat_id(self, chat_id: str, user_id: str, messages: dict[str, dict]) -> None:
|
||||||
|
|
@ -1564,6 +1583,7 @@ class ChatTable:
|
||||||
|
|
||||||
repaired_history = self._repair_chat_current_id(chat_item.chat or {})
|
repaired_history = self._repair_chat_current_id(chat_item.chat or {})
|
||||||
if repaired_history:
|
if repaired_history:
|
||||||
|
chat_item.current_message_id = self.get_current_message_id(chat_item.chat)
|
||||||
flag_modified(chat_item, 'chat')
|
flag_modified(chat_item, 'chat')
|
||||||
if self._sanitize_chat_row(chat_item) or repaired_history:
|
if self._sanitize_chat_row(chat_item) or repaired_history:
|
||||||
await session.commit()
|
await session.commit()
|
||||||
|
|
@ -1605,6 +1625,7 @@ class ChatTable:
|
||||||
|
|
||||||
repaired_history = self._repair_chat_current_id(chat.chat or {})
|
repaired_history = self._repair_chat_current_id(chat.chat or {})
|
||||||
if repaired_history:
|
if repaired_history:
|
||||||
|
chat.current_message_id = self.get_current_message_id(chat.chat)
|
||||||
flag_modified(chat, 'chat')
|
flag_modified(chat, 'chat')
|
||||||
if self._sanitize_chat_row(chat) or repaired_history:
|
if self._sanitize_chat_row(chat) or repaired_history:
|
||||||
await session.commit()
|
await session.commit()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue