1
This commit is contained in:
@@ -129,7 +129,7 @@ class Settings(BaseSettings):
|
||||
|
||||
CAPTCHA_ENABLED: bool = True
|
||||
|
||||
BASE_URL: str = "http://ceshi.apiforeign.minzhongzc.com"
|
||||
BASE_URL: str = "https://ceshi.apiforeign.minzhongzc.com"
|
||||
|
||||
CORS_ORIGINS: list[str] = ["*"]
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import base64
|
||||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
@@ -292,22 +290,15 @@ async def _call_openai_compatible(
|
||||
|
||||
def _file_url_or_data_uri(file_url: str, fallback_mime: str) -> str:
|
||||
"""
|
||||
Convert local upload path to base64 data URI.
|
||||
Keep remote http/https/data URLs as-is.
|
||||
远程 URL 保持原样;本地上传路径拼接 BASE_URL 转为完整链接。
|
||||
"""
|
||||
if file_url.startswith(("http://", "https://", "data:")):
|
||||
return file_url
|
||||
|
||||
# Compatible with /uploads/xxx and plain relative paths
|
||||
relative_path = file_url.replace("/uploads/", "", 1).lstrip("/")
|
||||
file_path = os.path.join(settings.UPLOAD_LOCAL_PATH, relative_path)
|
||||
|
||||
mime = mimetypes.guess_type(file_path)[0] or fallback_mime
|
||||
|
||||
with open(file_path, "rb") as f:
|
||||
b64 = base64.b64encode(f.read()).decode()
|
||||
|
||||
return f"data:{mime};base64,{b64}"
|
||||
# 本地上传路径拼接 BASE_URL,例如 /uploads/images/xxx.png → https://domain.com/uploads/images/xxx.png
|
||||
base = settings.BASE_URL.rstrip("/")
|
||||
path = file_url if file_url.startswith("/") else f"/{file_url}"
|
||||
return f"{base}{path}"
|
||||
|
||||
if image_urls or video_urls:
|
||||
user_message, log_user_message = await _build_multimodal_content(
|
||||
|
||||
Reference in New Issue
Block a user