mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-17 09:51:35 +00:00
style: apply ruff format so Python CI passes
This commit is contained in:
parent
1f773a0591
commit
f63cd426b9
4 changed files with 15 additions and 12 deletions
|
|
@ -1048,7 +1048,9 @@ ENABLE_API_OUTLET_FILTERS = os.getenv('ENABLE_API_OUTLET_FILTERS', 'True').lower
|
|||
# Opt in to CPython's in-place string append optimization for streamed responses.
|
||||
# Off by default for a staged rollout. Only a host already out of memory can lose
|
||||
# text here; the default path (a full copy per chunk) raises there too.
|
||||
ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND = os.getenv('ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND', 'False').lower() == 'true'
|
||||
ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND = (
|
||||
os.getenv('ENABLE_CHAT_RESPONSE_STREAM_INPLACE_APPEND', 'False').lower() == 'true'
|
||||
)
|
||||
|
||||
# When enabled, uses a hardcoded extension-to-MIME dictionary as a last-resort
|
||||
# fallback when both mimetypes.guess_type() and file.meta.content_type fail to
|
||||
|
|
|
|||
|
|
@ -84,9 +84,7 @@ async def has_access_to_file(
|
|||
|
||||
# Check if the file is directly attached to a shared workspace model (per the ownership
|
||||
# note above, model write is conferred only for files the model owner owns).
|
||||
model_owners = await Models.get_model_owner_ids_by_file_id(
|
||||
file.id, db=db, include_background=access_type == 'read'
|
||||
)
|
||||
model_owners = await Models.get_model_owner_ids_by_file_id(file.id, db=db, include_background=access_type == 'read')
|
||||
if access_type != 'read':
|
||||
model_owners = {model_id: owner_id for model_id, owner_id in model_owners.items() if owner_id == file.user_id}
|
||||
if user.id in model_owners.values():
|
||||
|
|
|
|||
|
|
@ -2232,7 +2232,9 @@ async def load_messages_from_db(chat_id: str, message_id: str) -> Optional[list[
|
|||
return [
|
||||
{k: v for k, v in msg.items() if k in MESSAGE_REPLAY_KEYS}
|
||||
for msg in db_messages
|
||||
if not (msg.get('role') == 'assistant' and msg.get('error') and not msg.get('content') and not msg.get('output'))
|
||||
if not (
|
||||
msg.get('role') == 'assistant' and msg.get('error') and not msg.get('content') and not msg.get('output')
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -2330,8 +2332,6 @@ def sanitize_tool_pairs(messages: list[dict]) -> list[dict]:
|
|||
return sanitized
|
||||
|
||||
|
||||
|
||||
|
||||
async def connect_mcp_server(
|
||||
request,
|
||||
server_id: str,
|
||||
|
|
@ -2844,7 +2844,9 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
)
|
||||
|
||||
terminal_request = (
|
||||
await get_terminal_request_info(request, user, metadata, extra_params) if terminal_id or terminal_skill_ids else None
|
||||
await get_terminal_request_info(request, user, metadata, extra_params)
|
||||
if terminal_id or terminal_skill_ids
|
||||
else None
|
||||
)
|
||||
|
||||
listed_terminal_skills = []
|
||||
|
|
@ -2872,7 +2874,9 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
sid = skill['id']
|
||||
if sid in mentioned_skill_ids or not use_builtin_tools:
|
||||
skill_name = unquote(sid.removeprefix(terminal_skill_prefix))
|
||||
loaded = await get_terminal_skill(request, user.model_dump(), metadata, skill_name, extra_params)
|
||||
loaded = await get_terminal_skill(
|
||||
request, user.model_dump(), metadata, skill_name, extra_params
|
||||
)
|
||||
if loaded:
|
||||
form_data['messages'] = add_or_update_system_message(
|
||||
format_terminal_skill_context(loaded),
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ def extract_skill_ids_from_messages(messages: list[dict]) -> set[str]:
|
|||
SKILL_MENTION_STRIP_RE = re.compile(rf'<(?:\$({SKILL_ID_RE})(?:\|([^>]*))?|/({SKILL_ID_RE})\|([^>]*))>')
|
||||
|
||||
|
||||
SKILLS_CREATE_RE = re.compile(r"^/skills:create(?:\s+(.*))?$", re.IGNORECASE | re.DOTALL)
|
||||
SKILLS_CREATE_RE = re.compile(r'^/skills:create(?:\s+(.*))?$', re.IGNORECASE | re.DOTALL)
|
||||
|
||||
OPEN_WEBUI_SKILL_AUTHORING_STANDARDS = """\
|
||||
Follow the Open WebUI skill-authoring standards:
|
||||
|
|
@ -126,8 +126,7 @@ def has_prior_real_chat_content(messages: list[dict]) -> bool:
|
|||
len(messages),
|
||||
)
|
||||
return any(
|
||||
message.get('role') == 'user' and _message_has_real_content(message)
|
||||
for message in messages[:last_user_idx]
|
||||
message.get('role') == 'user' and _message_has_real_content(message) for message in messages[:last_user_idx]
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue