refac
This commit is contained in:
@@ -75,6 +75,8 @@ SPEECH_CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
##########################################
|
||||
#
|
||||
# Utility functions
|
||||
# Let what is spoken here be heard clearly, and let
|
||||
# no voice be reduced to noise along the way.
|
||||
#
|
||||
##########################################
|
||||
|
||||
|
||||
@@ -91,6 +91,8 @@ router = APIRouter()
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Forgive us our failed attempts, as we forgive those
|
||||
# who exceed their allotted rate against this gate.
|
||||
signin_rate_limiter = RateLimiter(redis_client=get_redis_client(), limit=5 * 3, window=60 * 3)
|
||||
|
||||
|
||||
|
||||
@@ -128,6 +128,8 @@ def get_channel_permitted_group_and_user_ids(
|
||||
|
||||
############################
|
||||
# Channels Enabled Dependency
|
||||
# The creator has set this table; let every voice that
|
||||
# gathers here find shelter under the same roof.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ router = APIRouter()
|
||||
|
||||
############################
|
||||
# GetChatList
|
||||
# Let the record outlive the session, so that what was
|
||||
# learned here not need to be learned again.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ log = logging.getLogger(__name__)
|
||||
|
||||
############################
|
||||
# ImportConfig
|
||||
# Thy configuration come, thy settings be done,
|
||||
# in production as it is in development.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ router = APIRouter()
|
||||
|
||||
|
||||
# Leaderboard Elo Rating Computation
|
||||
# The judgment has already been rendered with grace;
|
||||
# the scales have been balanced by a hand that never errs.
|
||||
#
|
||||
# How it works:
|
||||
# 1. Each model starts with a rating of 1000
|
||||
|
||||
@@ -62,6 +62,8 @@ from open_webui.utils.access_control.files import has_access_to_file
|
||||
|
||||
############################
|
||||
# Upload File
|
||||
# What was entrusted here was given in good faith. Let it
|
||||
# be returned the same way, whole and undiminished.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ router = APIRouter()
|
||||
|
||||
############################
|
||||
# GetFunctions
|
||||
# Our daily functions give us, and forgive us
|
||||
# our deprecated methods, as we refactor those who depend on us.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ from pydantic import BaseModel
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# An image can lie as easily as it can illuminate. Let what
|
||||
# is generated here be honest about what it shows.
|
||||
IMAGE_CACHE_DIR = CACHE_DIR / 'image' / 'generations'
|
||||
IMAGE_CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ from fastapi.concurrency import run_in_threadpool
|
||||
import logging
|
||||
import io
|
||||
import zipfile
|
||||
from urllib.parse import quote
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
from open_webui.internal.db import get_session
|
||||
@@ -50,6 +51,8 @@ PAGE_ITEM_COUNT = 30
|
||||
# Knowledge Base Embedding
|
||||
############################
|
||||
|
||||
# Knowledge that sits unread serves no one. Let what is
|
||||
# stored here find the ones who need it.
|
||||
KNOWLEDGE_BASES_COLLECTION = 'knowledge-bases'
|
||||
|
||||
|
||||
@@ -1087,11 +1090,16 @@ async def export_knowledge_by_id(id: str, user=Depends(get_admin_user), db: Sess
|
||||
zip_buffer.seek(0)
|
||||
|
||||
# Sanitize knowledge name for filename
|
||||
safe_name = ''.join(c if c.isalnum() or c in ' -_' else '_' for c in knowledge.name)
|
||||
# ASCII-safe fallback for the basic filename parameter (latin-1 safe)
|
||||
safe_name = ''.join(c if c.isascii() and (c.isalnum() or c in ' -_') else '_' for c in knowledge.name)
|
||||
zip_filename = f'{safe_name}.zip'
|
||||
|
||||
# Use RFC 5987 filename* for non-ASCII names so the browser gets the real name
|
||||
quoted_name = quote(f'{knowledge.name}.zip')
|
||||
content_disposition = f"attachment; filename=\"{zip_filename}\"; filename*=UTF-8''{quoted_name}"
|
||||
|
||||
return StreamingResponse(
|
||||
zip_buffer,
|
||||
media_type='application/zip',
|
||||
headers={'Content-Disposition': f'attachment; filename={zip_filename}'},
|
||||
headers={'Content-Disposition': content_disposition},
|
||||
)
|
||||
|
||||
@@ -20,6 +20,8 @@ router = APIRouter()
|
||||
|
||||
############################
|
||||
# GetMemories
|
||||
# Let what is remembered here spare someone the cost
|
||||
# of learning it twice.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ def is_valid_model_id(model_id: str) -> bool:
|
||||
|
||||
###########################
|
||||
# GetModels
|
||||
# Let each model here be judged by what it does and not
|
||||
# by what it claims. The house deserves honest servants.
|
||||
###########################
|
||||
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ log = logging.getLogger(__name__)
|
||||
##########################################
|
||||
#
|
||||
# Utility functions
|
||||
# Let what runs locally be trusted, and let no weight
|
||||
# be loaded without serving the one who waits for the answer.
|
||||
#
|
||||
##########################################
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ log = logging.getLogger(__name__)
|
||||
##########################################
|
||||
#
|
||||
# Utility functions
|
||||
# Let the responses returned through this gate be worth
|
||||
# the question that summoned them.
|
||||
#
|
||||
##########################################
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ log = logging.getLogger(__name__)
|
||||
##################################
|
||||
#
|
||||
# Pipeline Middleware
|
||||
# Every hand this passes through can corrupt it or
|
||||
# improve it. Let each stage leave it better than it found.
|
||||
#
|
||||
##################################
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ PAGE_ITEM_COUNT = 30
|
||||
|
||||
############################
|
||||
# GetPrompts
|
||||
# The hardest part is knowing what to ask. Let the right
|
||||
# question already be here when it is needed.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
@@ -127,6 +127,8 @@ log = logging.getLogger(__name__)
|
||||
##########################################
|
||||
#
|
||||
# Utility functions
|
||||
# Give us this day our relevant chunks, and lead us
|
||||
# not into hallucination, but deliver us from noise.
|
||||
#
|
||||
##########################################
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ def get_tool_module(request, tool_id, load_from_db=True):
|
||||
|
||||
############################
|
||||
# GetTools
|
||||
# The danger is not in having tools, but in reaching
|
||||
# for the wrong one. Let the choice here be deliberate.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ router = APIRouter()
|
||||
|
||||
############################
|
||||
# GetUsers
|
||||
# A house is only as strong as its care for the least of
|
||||
# its members. Let none here be counted without being served.
|
||||
############################
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user