From 32d4c6054101b335f19a521cd60ef32b8c2b8bdb Mon Sep 17 00:00:00 2001 From: snaily Date: Thu, 17 Jul 2025 22:07:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3Callirhoe=E6=8B=BC?= =?UTF-8?q?=E5=86=99=E9=94=99=E8=AF=AF=E4=B8=BACallirrhoe=20refactor:=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B8=B8=E9=87=8F=E6=A0=BC=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=8F=AF=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/constants.py | 82 +++++++++++++++++++----------- app/service/files/files_service.py | 2 +- app/templates/config_editor.html | 2 +- 3 files changed, 54 insertions(+), 32 deletions(-) diff --git a/app/core/constants.py b/app/core/constants.py index cbdfb8f..5b44a54 100644 --- a/app/core/constants.py +++ b/app/core/constants.py @@ -15,12 +15,12 @@ DEFAULT_MAX_TOKENS = 8192 DEFAULT_TOP_P = 0.9 DEFAULT_TOP_K = 40 DEFAULT_FILTER_MODELS = [ - "gemini-1.0-pro-vision-latest", - "gemini-pro-vision", - "chat-bison-001", - "text-bison-001", - "embedding-gecko-001" - ] + "gemini-1.0-pro-vision-latest", + "gemini-pro-vision", + "chat-bison-001", + "text-bison-001", + "embedding-gecko-001", +] DEFAULT_CREATE_IMAGE_MODEL = "imagen-3.0-generate-002" # 图像生成相关常量 @@ -38,14 +38,14 @@ DEFAULT_STREAM_LONG_TEXT_THRESHOLD = 50 DEFAULT_STREAM_CHUNK_SIZE = 5 # 正则表达式模式 -IMAGE_URL_PATTERN = r'!\[(.*?)\]\((.*?)\)' -DATA_URL_PATTERN = r'data:([^;]+);base64,(.+)' +IMAGE_URL_PATTERN = r"!\[(.*?)\]\((.*?)\)" +DATA_URL_PATTERN = r"data:([^;]+);base64,(.+)" # Audio/Video Settings SUPPORTED_AUDIO_FORMATS = ["wav", "mp3", "flac", "ogg"] SUPPORTED_VIDEO_FORMATS = ["mp4", "mov", "avi", "webm"] MAX_AUDIO_SIZE_BYTES = 50 * 1024 * 1024 # Example: 50MB limit for Base64 payload -MAX_VIDEO_SIZE_BYTES = 200 * 1024 * 1024 # Example: 200MB limit +MAX_VIDEO_SIZE_BYTES = 200 * 1024 * 1024 # Example: 200MB limit # Optional: Define MIME type mappings if needed, or handle directly in converter AUDIO_FORMAT_TO_MIMETYPE = { @@ -63,28 +63,50 @@ VIDEO_FORMAT_TO_MIMETYPE = { } GEMINI_2_FLASH_EXP_SAFETY_SETTINGS = [ - {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "OFF"}, - {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "OFF"}, - {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "OFF"}, - {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "OFF"}, - {"category": "HARM_CATEGORY_CIVIC_INTEGRITY", "threshold": "OFF"}, - ] + {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "OFF"}, + {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "OFF"}, + {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "OFF"}, + {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "OFF"}, + {"category": "HARM_CATEGORY_CIVIC_INTEGRITY", "threshold": "OFF"}, +] DEFAULT_SAFETY_SETTINGS = [ - {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "OFF"}, - {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "OFF"}, - {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "OFF"}, - {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "OFF"}, - {"category": "HARM_CATEGORY_CIVIC_INTEGRITY", "threshold": "BLOCK_NONE"}, - ] + {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "OFF"}, + {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "OFF"}, + {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "OFF"}, + {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "OFF"}, + {"category": "HARM_CATEGORY_CIVIC_INTEGRITY", "threshold": "BLOCK_NONE"}, +] TTS_VOICE_NAMES = [ - "Zephyr", "Puck", "Charon", "Kore", - "Fenrir", "Leda", "Orus", "Aoede", - "Callirhoe", "Autonoe", "Enceladus", "Iapetus", - "Umbriel", "Algieba", "Despina", "Erinome", - "Algenib", "Rasalgethi", "Laomedeia", "Achernar", - "Alnilam", "Schedar", "Gacrux", "Pulcherrima", - "Achird", "Zubenelgenubi", "Vindemiatrix", "Sadachbia", - "Sadaltager", "Sulafat" -] \ No newline at end of file + "Zephyr", + "Puck", + "Charon", + "Kore", + "Fenrir", + "Leda", + "Orus", + "Aoede", + "Callirrhoe", + "Autonoe", + "Enceladus", + "Iapetus", + "Umbriel", + "Algieba", + "Despina", + "Erinome", + "Algenib", + "Rasalgethi", + "Laomedeia", + "Achernar", + "Alnilam", + "Schedar", + "Gacrux", + "Pulcherrima", + "Achird", + "Zubenelgenubi", + "Vindemiatrix", + "Sadachbia", + "Sadaltager", + "Sulafat", +] diff --git a/app/service/files/files_service.py b/app/service/files/files_service.py index 39c2ba0..c33ede4 100644 --- a/app/service/files/files_service.py +++ b/app/service/files/files_service.py @@ -113,7 +113,7 @@ class FilesService: try: request_data = json.loads(body) display_name = request_data.get("displayName", "") - except: + except Exception: pass # 從 upload URL 中提取 upload_id import urllib.parse diff --git a/app/templates/config_editor.html b/app/templates/config_editor.html index e2854e3..a8a4ff1 100644 --- a/app/templates/config_editor.html +++ b/app/templates/config_editor.html @@ -1618,7 +1618,7 @@ endblock %} {% block head_extra_styles %} - +