mirror of
https://github.com/open-webui/computer.git
synced 2026-11-24 06:20:21 -05:00
refac
This commit is contained in:
1 parent
c4a0fb304b
commit
c752cc72fd
2 files changed
+40
-53
No files matched your search
+9
-15
@@ -909,7 +909,15 @@ async def _load_message_history(chat_id: str, message_id: str) -> tuple[list[dic
|
||||
for item in m.output:
|
||||
itype = item.get("type")
|
||||
if itype == "reasoning":
|
||||
if not _is_provider_replayable_reasoning_item(item):
|
||||
if (
|
||||
item.get("status") not in (None, "completed")
|
||||
or str(item.get("id", "")).startswith("reasoning-")
|
||||
or (
|
||||
not item.get("encrypted_content")
|
||||
and not item.get("reasoning_details")
|
||||
and _reasoning_text_len(item) <= 0
|
||||
)
|
||||
):
|
||||
continue
|
||||
# A reasoning item after we already have outputs means
|
||||
# a new API iteration started — flush the current turn.
|
||||
@@ -1138,20 +1146,6 @@ def _tool_result_for_model(tool_name: str, result: str) -> str:
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _is_provider_replayable_reasoning_item(item: dict) -> bool:
|
||||
"""Return True for provider reasoning that can be sent back to model APIs."""
|
||||
if item.get("type") != "reasoning":
|
||||
return False
|
||||
if item.get("status") not in (None, "completed"):
|
||||
return False
|
||||
if str(item.get("id", "")).startswith("reasoning-"):
|
||||
return False
|
||||
if item.get("encrypted_content") or item.get("reasoning_details"):
|
||||
return True
|
||||
return _reasoning_text_len(item) > 0
|
||||
|
||||
|
||||
def _append_tool_to_messages(
|
||||
messages: list[dict],
|
||||
event: dict,
|
||||
|
||||
Reference in new issue
Block a user