清理 Ollama/API URL 中的终端控制字符,修复 AI 调用失败。
This commit is contained in:
@@ -18,6 +18,7 @@ from app.schemas import (
|
||||
SystemSettingsOut,
|
||||
SystemSettingsUpdate,
|
||||
)
|
||||
from app.services.url_sanitize import sanitize_http_url, sanitize_model_name
|
||||
|
||||
router = APIRouter(prefix="/admin", tags=["admin"])
|
||||
|
||||
@@ -66,13 +67,13 @@ def update_settings(
|
||||
if data.ai_provider is not None:
|
||||
row.ai_provider = data.ai_provider.value
|
||||
if data.ollama_base_url is not None:
|
||||
row.ollama_base_url = data.ollama_base_url or None
|
||||
row.ollama_base_url = sanitize_http_url(data.ollama_base_url) or None
|
||||
if data.ollama_model is not None:
|
||||
row.ollama_model = data.ollama_model or None
|
||||
row.ollama_model = sanitize_model_name(data.ollama_model) or None
|
||||
if data.openai_base_url is not None:
|
||||
row.openai_base_url = data.openai_base_url or None
|
||||
row.openai_base_url = sanitize_http_url(data.openai_base_url) or None
|
||||
if data.openai_model is not None:
|
||||
row.openai_model = data.openai_model or None
|
||||
row.openai_model = sanitize_model_name(data.openai_model) or None
|
||||
if data.openai_api_key is not None and data.openai_api_key.strip():
|
||||
row.openai_api_key = data.openai_api_key.strip()
|
||||
if data.ocr_service_url is not None:
|
||||
|
||||
Reference in New Issue
Block a user