chore: linting

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-02-01 21:17:24 -08:00
parent e7c17c327c
commit 8fb5a7fb8f
10 changed files with 61 additions and 55 deletions

View file

@ -103,7 +103,9 @@ def upgrade() -> None:
# 5. Drop deprecated columns from new_chat_threads # 5. Drop deprecated columns from new_chat_threads
op.execute("ALTER TABLE new_chat_threads DROP COLUMN IF EXISTS clone_pending") op.execute("ALTER TABLE new_chat_threads DROP COLUMN IF EXISTS clone_pending")
op.execute("ALTER TABLE new_chat_threads DROP COLUMN IF EXISTS public_share_enabled") op.execute(
"ALTER TABLE new_chat_threads DROP COLUMN IF EXISTS public_share_enabled"
)
op.execute("ALTER TABLE new_chat_threads DROP COLUMN IF EXISTS public_share_token") op.execute("ALTER TABLE new_chat_threads DROP COLUMN IF EXISTS public_share_token")
# 6. Add cloned_from_snapshot_id to new_chat_threads # 6. Add cloned_from_snapshot_id to new_chat_threads
@ -129,7 +131,9 @@ def downgrade() -> None:
# 1. Drop cloned_from_snapshot_id column and index # 1. Drop cloned_from_snapshot_id column and index
op.execute("DROP INDEX IF EXISTS ix_new_chat_threads_cloned_from_snapshot_id") op.execute("DROP INDEX IF EXISTS ix_new_chat_threads_cloned_from_snapshot_id")
op.execute("ALTER TABLE new_chat_threads DROP COLUMN IF EXISTS cloned_from_snapshot_id") op.execute(
"ALTER TABLE new_chat_threads DROP COLUMN IF EXISTS cloned_from_snapshot_id"
)
# 2. Restore deprecated columns on new_chat_threads # 2. Restore deprecated columns on new_chat_threads
op.execute( op.execute(

View file

@ -546,7 +546,9 @@ class PublicChatSnapshot(BaseModel, TimestampMixin):
# Constraints # Constraints
__table_args__ = ( __table_args__ = (
# Prevent duplicate snapshots of the same content for the same thread # Prevent duplicate snapshots of the same content for the same thread
UniqueConstraint("thread_id", "content_hash", name="uq_snapshot_thread_content_hash"), UniqueConstraint(
"thread_id", "content_hash", name="uq_snapshot_thread_content_hash"
),
) )

View file

@ -1273,7 +1273,7 @@ async def regenerate_response(
.limit(2) .limit(2)
) )
messages_to_delete = list(last_messages_result.scalars().all()) messages_to_delete = list(last_messages_result.scalars().all())
message_ids_to_delete = [msg.id for msg in messages_to_delete] message_ids_to_delete = [msg.id for msg in messages_to_delete]
# Get search space for LLM config # Get search space for LLM config

View file

@ -61,21 +61,23 @@ async def get_global_new_llm_configs(
# Only include Auto mode if there are actual global configs to route to # Only include Auto mode if there are actual global configs to route to
# Auto mode requires at least one global config with valid API key # Auto mode requires at least one global config with valid API key
if global_configs and len(global_configs) > 0: if global_configs and len(global_configs) > 0:
safe_configs.append({ safe_configs.append(
"id": 0, {
"name": "Auto (Load Balanced)", "id": 0,
"description": "Automatically routes requests across available LLM providers for optimal performance and rate limit handling. Recommended for most users.", "name": "Auto (Load Balanced)",
"provider": "AUTO", "description": "Automatically routes requests across available LLM providers for optimal performance and rate limit handling. Recommended for most users.",
"custom_provider": None, "provider": "AUTO",
"model_name": "auto", "custom_provider": None,
"api_base": None, "model_name": "auto",
"litellm_params": {}, "api_base": None,
"system_instructions": "", "litellm_params": {},
"use_default_system_instructions": True, "system_instructions": "",
"citations_enabled": True, "use_default_system_instructions": True,
"is_global": True, "citations_enabled": True,
"is_auto_mode": True, "is_global": True,
}) "is_auto_mode": True,
}
)
# Add individual global configs # Add individual global configs
for cfg in global_configs: for cfg in global_configs:

View file

@ -22,7 +22,9 @@ router = APIRouter(prefix="/notifications", tags=["notifications"])
SYNC_WINDOW_DAYS = 14 SYNC_WINDOW_DAYS = 14
# Valid notification types - must match frontend InboxItemTypeEnum # Valid notification types - must match frontend InboxItemTypeEnum
NotificationType = Literal["connector_indexing", "document_processing", "new_mention", "page_limit_exceeded"] NotificationType = Literal[
"connector_indexing", "document_processing", "new_mention", "page_limit_exceeded"
]
class NotificationResponse(BaseModel): class NotificationResponse(BaseModel):

View file

@ -867,9 +867,7 @@ class PageLimitNotificationHandler(BaseNotificationHandler):
def __init__(self): def __init__(self):
super().__init__("page_limit_exceeded") super().__init__("page_limit_exceeded")
def _generate_operation_id( def _generate_operation_id(self, document_name: str, search_space_id: int) -> str:
self, document_name: str, search_space_id: int
) -> str:
""" """
Generate a unique operation ID for a page limit exceeded notification. Generate a unique operation ID for a page limit exceeded notification.
@ -915,9 +913,11 @@ class PageLimitNotificationHandler(BaseNotificationHandler):
Notification: The created notification Notification: The created notification
""" """
operation_id = self._generate_operation_id(document_name, search_space_id) operation_id = self._generate_operation_id(document_name, search_space_id)
# Truncate document name for title if too long # Truncate document name for title if too long
display_name = document_name[:40] + "..." if len(document_name) > 40 else document_name display_name = (
document_name[:40] + "..." if len(document_name) > 40 else document_name
)
title = f"Page limit exceeded: {display_name}" title = f"Page limit exceeded: {display_name}"
message = f"This document has ~{pages_to_add} page(s) but you've used {pages_used}/{pages_limit} pages. Upgrade to process more documents." message = f"This document has ~{pages_to_add} page(s) but you've used {pages_used}/{pages_limit} pages. Upgrade to process more documents."

View file

@ -8,6 +8,7 @@ Key concepts:
- Single-phase clone reads directly from snapshot_data - Single-phase clone reads directly from snapshot_data
""" """
import contextlib
import hashlib import hashlib
import json import json
import re import re
@ -213,7 +214,6 @@ async def create_snapshot(
# Update status to "ready" so frontend renders PodcastPlayer # Update status to "ready" so frontend renders PodcastPlayer
part["result"] = {**result_data, "status": "ready"} part["result"] = {**result_data, "status": "ready"}
messages_data.append( messages_data.append(
{ {
"id": msg.id, "id": msg.id,
@ -314,9 +314,7 @@ async def get_snapshot_by_token(
) -> PublicChatSnapshot | None: ) -> PublicChatSnapshot | None:
"""Get a snapshot by its share token.""" """Get a snapshot by its share token."""
result = await session.execute( result = await session.execute(
select(PublicChatSnapshot).filter( select(PublicChatSnapshot).filter(PublicChatSnapshot.share_token == share_token)
PublicChatSnapshot.share_token == share_token
)
) )
return result.scalars().first() return result.scalars().first()
@ -426,7 +424,7 @@ async def delete_snapshot(
async def delete_affected_snapshots( async def delete_affected_snapshots(
session: AsyncSession, # noqa: ARG001 - kept for API compatibility session: AsyncSession,
thread_id: int, thread_id: int,
message_ids: list[int], message_ids: list[int],
) -> int: ) -> int:
@ -538,10 +536,8 @@ async def clone_from_snapshot(
author_ids_from_snapshot: set[UUID] = set() author_ids_from_snapshot: set[UUID] = set()
for msg_data in messages_data: for msg_data in messages_data:
if author_str := msg_data.get("author_id"): if author_str := msg_data.get("author_id"):
try: with contextlib.suppress(ValueError, TypeError):
author_ids_from_snapshot.add(UUID(author_str)) author_ids_from_snapshot.add(UUID(author_str))
except (ValueError, TypeError):
pass
existing_authors: set[UUID] = set() existing_authors: set[UUID] = set()
if author_ids_from_snapshot: if author_ids_from_snapshot:

View file

@ -418,7 +418,11 @@ async def _process_file_upload(
page_limit_error: PageLimitExceededError | None = None page_limit_error: PageLimitExceededError | None = None
if isinstance(e, PageLimitExceededError): if isinstance(e, PageLimitExceededError):
page_limit_error = e page_limit_error = e
elif isinstance(e, HTTPException) and e.__cause__ and isinstance(e.__cause__, PageLimitExceededError): elif (
isinstance(e, HTTPException)
and e.__cause__
and isinstance(e.__cause__, PageLimitExceededError)
):
# HTTPException wraps the original PageLimitExceededError # HTTPException wraps the original PageLimitExceededError
page_limit_error = e.__cause__ page_limit_error = e.__cause__
elif isinstance(e, HTTPException) and "page limit" in str(e.detail).lower(): elif isinstance(e, HTTPException) and "page limit" in str(e.detail).lower():
@ -432,14 +436,12 @@ async def _process_file_upload(
try: try:
# First, mark the processing notification as failed # First, mark the processing notification as failed
await session.refresh(notification) await session.refresh(notification)
await ( await NotificationService.document_processing.notify_processing_completed(
NotificationService.document_processing.notify_processing_completed( session=session,
session=session, notification=notification,
notification=notification, error_message="Page limit exceeded",
error_message="Page limit exceeded",
)
) )
# Then create a separate page_limit_exceeded notification for better UX # Then create a separate page_limit_exceeded notification for better UX
await NotificationService.page_limit.notify_page_limit_exceeded( await NotificationService.page_limit.notify_page_limit_exceeded(
session=session, session=session,
@ -460,12 +462,10 @@ async def _process_file_upload(
error_message = str(e.detail) error_message = str(e.detail)
try: try:
await session.refresh(notification) await session.refresh(notification)
await ( await NotificationService.document_processing.notify_processing_completed(
NotificationService.document_processing.notify_processing_completed( session=session,
session=session, notification=notification,
notification=notification, error_message=error_message,
error_message=error_message,
)
) )
except Exception as notif_error: except Exception as notif_error:
logger.error( logger.error(
@ -477,12 +477,10 @@ async def _process_file_upload(
try: try:
# Refresh notification to ensure it's not stale after any rollback # Refresh notification to ensure it's not stale after any rollback
await session.refresh(notification) await session.refresh(notification)
await ( await NotificationService.document_processing.notify_processing_completed(
NotificationService.document_processing.notify_processing_completed( session=session,
session=session, notification=notification,
notification=notification, error_message=error_message,
error_message=error_message,
)
) )
except Exception as notif_error: except Exception as notif_error:
logger.error( logger.error(

View file

@ -389,7 +389,9 @@ export const ConnectorIndicator: FC = () => {
onConnectOAuth={hasDocumentSummaryLLM ? handleConnectOAuth : () => {}} onConnectOAuth={hasDocumentSummaryLLM ? handleConnectOAuth : () => {}}
onConnectNonOAuth={hasDocumentSummaryLLM ? handleConnectNonOAuth : () => {}} onConnectNonOAuth={hasDocumentSummaryLLM ? handleConnectNonOAuth : () => {}}
onCreateWebcrawler={hasDocumentSummaryLLM ? handleCreateWebcrawler : () => {}} onCreateWebcrawler={hasDocumentSummaryLLM ? handleCreateWebcrawler : () => {}}
onCreateYouTubeCrawler={hasDocumentSummaryLLM ? handleCreateYouTubeCrawler : () => {}} onCreateYouTubeCrawler={
hasDocumentSummaryLLM ? handleCreateYouTubeCrawler : () => {}
}
onManage={handleStartEdit} onManage={handleStartEdit}
onViewAccountsList={handleViewAccountsList} onViewAccountsList={handleViewAccountsList}
/> />

View file

@ -3,9 +3,9 @@ import {
createConnectorRequest, createConnectorRequest,
createConnectorResponse, createConnectorResponse,
type DeleteConnectorRequest, type DeleteConnectorRequest,
type DiscordChannel,
deleteConnectorRequest, deleteConnectorRequest,
deleteConnectorResponse, deleteConnectorResponse,
type DiscordChannel,
type GetConnectorRequest, type GetConnectorRequest,
type GetConnectorsRequest, type GetConnectorsRequest,
getConnectorRequest, getConnectorRequest,