feat: add standard Qwen settings checkbox to text provider

This commit is contained in:
apuc committed 2026-11-18 20:21:10 +03:00
1 parent 5dbe1427eb
commit 716002dcaf
2 files changed
+39 -12

No files matched your search

+12 -4
View File
@@ -23,7 +23,7 @@ from ai_core.telegram_publisher import (
)
from ai_core.tenchat_publisher import publish_post as publish_post_tenchat
from cabinet_service.brand_doc_generator import generate_brand_docx
from config import SECRET_KEY
from config import SECRET_KEY, QWEN_BASE_URL, QWEN_MODEL
from database import (
add_post_revision,
count_user_tasks,
@@ -461,20 +461,21 @@ def profile_edit_submit(
def provider_form(request: Request, user: dict = Depends(current_user)):
provider = get_provider_settings(user["id"])
return render(request, "provider.html", user=user,
provider=provider, provider_presets=PROVIDER_PRESETS)
provider=provider, provider_presets=PROVIDER_PRESETS,
default_text={"base_url": QWEN_BASE_URL or "", "model": QWEN_MODEL})
@app.post("/provider")
def provider_submit(
request: Request,
# Text provider
text_provider_type: str = Form(...),
text_provider_type: str = Form(""),
text_api_key: str = Form(""),
text_base_url: str = Form(""),
text_model: str = Form(""),
text_use_global: str = Form(""),
# Image provider
image_provider_type: str = Form(...),
image_provider_type: str = Form(""),
image_api_key: str = Form(""),
image_base_url: str = Form(""),
image_model: str = Form(""),
@@ -483,6 +484,10 @@ def provider_submit(
):
errors = []
# «Стандартные настройки» — это Qwen сервиса, отдельный провайдер выбирать не нужно
if text_use_global and text_provider_type not in PROVIDER_PRESETS:
text_provider_type = "qwen"
# Валидация text-провайдера
if text_provider_type not in PROVIDER_PRESETS:
errors.append("Выберите провайдера для текста.")
@@ -513,11 +518,14 @@ def provider_submit(
return render(
request, "provider.html", status_code=400,
user=user, provider_presets=PROVIDER_PRESETS, errors=errors,
default_text={"base_url": QWEN_BASE_URL or "", "model": QWEN_MODEL},
form={
"text_provider_type": text_provider_type, "text_api_key": text_api_key,
"text_base_url": text_base_url, "text_model": text_model,
"text_use_global": text_use_global,
"image_provider_type": image_provider_type, "image_api_key": image_api_key,
"image_base_url": image_base_url, "image_model": image_model,
"image_use_global": image_use_global,
},
)