chore: format

This commit is contained in:
Timothy Jaeryang Baek
2026-07-27 04:38:46 -04:00
parent c4332be71e
commit c004b4ecb5
73 changed files with 1165 additions and 350 deletions
+1 -5
View File
@@ -855,11 +855,7 @@ CONTENT_EXTRACTION_ENGINE = os.getenv('CONTENT_EXTRACTION_ENGINE', '').lower()
content_extraction_supported_media_mime_types = os.getenv('CONTENT_EXTRACTION_SUPPORTED_MEDIA_MIME_TYPES')
CONTENT_EXTRACTION_SUPPORTED_MEDIA_MIME_TYPES = (
[
mime_type.strip()
for mime_type in content_extraction_supported_media_mime_types.split(',')
if mime_type.strip()
]
[mime_type.strip() for mime_type in content_extraction_supported_media_mime_types.split(',') if mime_type.strip()]
if content_extraction_supported_media_mime_types is not None
else None
)
+1 -3
View File
@@ -870,9 +870,7 @@ class ChatTable:
**message,
'id': message.get('id') or message_id,
'parentId': message_parent_id if message_parent_id is not None else parent_id,
'childrenIds': (
message.get('childrenIds') if isinstance(message.get('childrenIds'), list) else []
),
'childrenIds': (message.get('childrenIds') if isinstance(message.get('childrenIds'), list) else []),
'role': role,
'timestamp': message.get('timestamp') or int(time.time()),
}
+3 -3
View File
@@ -91,11 +91,11 @@ def _is_global_addr(ip: str) -> bool:
embedded.extend(addr.teredo)
b = addr.packed
if b[:12] == b"\x00" * 12:
if b[:12] == b'\x00' * 12:
embedded.append(ipaddress.IPv4Address(b[12:]))
elif b[:12] == b"\x00\x64\xff\x9b" + b"\x00" * 8:
elif b[:12] == b'\x00\x64\xff\x9b' + b'\x00' * 8:
embedded.append(ipaddress.IPv4Address(b[12:]))
elif b[:6] == b"\x00\x64\xff\x9b\x00\x01":
elif b[:6] == b'\x00\x64\xff\x9b\x00\x01':
if b[8] != 0:
return False
embedded.append(ipaddress.IPv4Address(bytes((b[6], b[7], b[9], b[10]))))
+2 -1
View File
@@ -764,7 +764,8 @@ async def signin(
user_id=trusted_header_user_id(email),
)
except IntegrityError:
pass
if not await Users.get_user_by_email(email.lower(), db=db):
raise
user = await Auths.authenticate_user_by_email(email, db=db)
if user:
+3 -1
View File
@@ -990,7 +990,9 @@ async def model_response_handler(request, channel, message, user, db=None):
response_parent_id = (
message.parent_id
if message.parent_id
else (message.id if await Config.get('channels.model_response_mode', 'thread') == 'thread' else None)
else (
message.id if await Config.get('channels.model_response_mode', 'thread') == 'thread' else None
)
)
response_message, channel = await new_message_handler(
+4 -2
View File
@@ -186,8 +186,10 @@ async def create_folder(
detail=ERROR_MESSAGES.DEFAULT('Error creating folder'),
)
if form_data.data and 'files' in form_data.data and not await can_read_all_folder_files(
form_data.data['files'], user, db=db
if (
form_data.data
and 'files' in form_data.data
and not await can_read_all_folder_files(form_data.data['files'], user, db=db)
):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
+4 -6
View File
@@ -2423,9 +2423,9 @@ async def query_chat_files(
items=file_items,
queries=[query],
embedding_function=(
lambda queries, prefix: embedding_function(queries, prefix=prefix, user=user_model)
if embedding_function
else None
lambda queries, prefix: (
embedding_function(queries, prefix=prefix, user=user_model) if embedding_function else None
)
),
k=count,
reranking_function=(
@@ -3155,9 +3155,7 @@ async def query_knowledge_files(
__request__,
collection_names=collection_names,
queries=[query],
embedding_function=lambda queries, prefix: embedding_function(
queries, prefix=prefix, user=user_model
),
embedding_function=lambda queries, prefix: embedding_function(queries, prefix=prefix, user=user_model),
k=count,
)
+6 -13
View File
@@ -2871,10 +2871,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
for item in get_attached_knowledge(model, metadata):
if not item.get('id') or not item.get('type'):
continue
attrs = (
f'type="{escape(str(item["type"]), quote=True)}" '
f'id="{escape(str(item["id"]), quote=True)}"'
)
attrs = f'type="{escape(str(item["type"]), quote=True)}" id="{escape(str(item["id"]), quote=True)}"'
if item.get('name'):
attrs += f' name="{escape(str(item["name"]), quote=True)}"'
if item.get('source'):
@@ -2946,9 +2943,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
)
if resolved_model_system_prompt:
system_content = (
f'{resolved_model_system_prompt}\n{system_content}'
if system_content
else resolved_model_system_prompt
f'{resolved_model_system_prompt}\n{system_content}' if system_content else resolved_model_system_prompt
)
metadata['system_prompt'] = system_content or None
metadata['user_prompt'] = get_last_user_message(form_data['messages'])
@@ -3779,9 +3774,7 @@ async def streaming_chat_response_handler(response, ctx):
}
filter_functions = (
await get_filter_functions(request, model, metadata.get('filter_ids', []))
if ENABLE_PLUGINS
else []
await get_filter_functions(request, model, metadata.get('filter_ids', [])) if ENABLE_PLUGINS else []
)
# Standard streaming response handler
@@ -4500,9 +4493,9 @@ async def streaming_chat_response_handler(response, ctx):
str,
):
current_response_tool_call['function']['arguments'] = ''
current_response_tool_call['function'][
'arguments'
] += delta_arguments
current_response_tool_call['function']['arguments'] += (
delta_arguments
)
# Emit pending tool calls in real-time
if response_tool_calls: