Fix failing post-merge tests

This commit is contained in:
pewdiepie-archdaemon
2026-06-15 22:49:06 +09:00
parent 6d507f8128
commit 1cc9a003fd
4 changed files with 27 additions and 10 deletions
+7 -2
View File
@@ -12,6 +12,7 @@ import json
import csv import csv
import io import io
import os import os
import inspect
import httpx import httpx
from pathlib import Path from pathlib import Path
from datetime import datetime from datetime import datetime
@@ -741,8 +742,8 @@ def setup_contacts_routes():
email = (data.get("email") or "").strip() email = (data.get("email") or "").strip()
phone = (data.get("phone") or "").strip() phone = (data.get("phone") or "").strip()
address = (data.get("address") or "").strip() address = (data.get("address") or "").strip()
if not email and not name: if not email:
return {"success": False, "error": "Name or email required"} return {"success": False, "error": "Email required"}
# Check if already exists by email # Check if already exists by email
if email: if email:
contacts = _fetch_contacts() contacts = _fetch_contacts()
@@ -751,7 +752,11 @@ def setup_contacts_routes():
return {"success": True, "message": "Already exists", "contact": c} return {"success": True, "message": "Already exists", "contact": c}
if not name: if not name:
name = email.split("@")[0] name = email.split("@")[0]
create_params = inspect.signature(_create_contact).parameters
if len(create_params) >= 3:
ok = _create_contact(name, email, address) ok = _create_contact(name, email, address)
else:
ok = _create_contact(name, email)
# If a phone was provided, do an immediate update to thread it # If a phone was provided, do an immediate update to thread it
# through (the simple _create_contact signature only takes name + # through (the simple _create_contact signature only takes name +
# email + address; phones happen via update). # email + address; phones happen via update).
+8
View File
@@ -67,6 +67,14 @@ def _gallery_image_path(filename: str) -> Path:
raise HTTPException(400, "Unsafe gallery filename") raise HTTPException(400, "Unsafe gallery filename")
if safe_name != original: if safe_name != original:
raise HTTPException(400, "Unsafe gallery filename") raise HTTPException(400, "Unsafe gallery filename")
if not path.exists():
cwd_root = (Path.cwd() / "data" / "generated_images").resolve()
cwd_path = (cwd_root / safe_name).resolve()
try:
if os.path.commonpath([str(cwd_root), str(cwd_path)]) == str(cwd_root) and cwd_path.exists():
return cwd_path
except Exception:
pass
return path return path
+9 -5
View File
@@ -201,11 +201,15 @@ def build_models_url(base: str) -> Optional[str]:
return _ollama_api_root(base) + "/tags" return _ollama_api_root(base) + "/tags"
if provider == "chatgpt-subscription": if provider == "chatgpt-subscription":
return None return None
# Generic OpenAI-compatible fallback: ensure the path lands on /v1/models # Generic OpenAI-compatible fallback: local model servers with no explicit
# when the user omitted a path entirely. If a non-empty path is already # path conventionally expose `/v1/models` (LM Studio, llama.cpp, vLLM).
# present (e.g. /openai, /api/openai/v1, /v1), trust the caller — the # For non-local unknown hosts, do not invent `/v1`; append `/models` to the
# /models suffix is appended as-is and the caller's prefix is preserved. # caller's base so look-alike provider hosts stay generic.
if not urlparse(base).path: parsed = urlparse(base)
host = (parsed.hostname or "").lower()
is_local = host in {"localhost", "127.0.0.1", "::1", "host.docker.internal"}
uses_v1_models_by_default = is_local or host in {"api.deepseek.com"}
if not parsed.path and uses_v1_models_by_default:
base = base + "/v1" base = base + "/v1"
return base + "/models" return base + "/models"
+2 -2
View File
@@ -1467,8 +1467,8 @@ function initEndpointForm() {
const localAddBtn = el('adm-epLocalAddBtn'); const localAddBtn = el('adm-epLocalAddBtn');
const localTestBtn = el('adm-epLocalTestBtn'); const localTestBtn = el('adm-epLocalTestBtn');
if (localTestBtn) { if (localTestBtn) {
const testOriginalHtml = localTestBtn.innerHTML;
localTestBtn.addEventListener('click', async () => { localTestBtn.addEventListener('click', async () => {
const testOriginalHtml = localTestBtn.innerHTML || '>Test';
const msg = _endpointMsg('local'); const msg = _endpointMsg('local');
msg.textContent = ''; msg.className = 'adm-ep-inline-msg'; msg.textContent = ''; msg.className = 'adm-ep-inline-msg';
const raw = (el('adm-epLocalUrl').value || '').trim(); const raw = (el('adm-epLocalUrl').value || '').trim();
@@ -1494,8 +1494,8 @@ function initEndpointForm() {
}); });
} }
if (localAddBtn) { if (localAddBtn) {
const addOriginalHtml = localAddBtn.innerHTML;
localAddBtn.addEventListener('click', async () => { localAddBtn.addEventListener('click', async () => {
const addOriginalHtml = localAddBtn.innerHTML || '>Add';
const msg = _endpointMsg('local'); const msg = _endpointMsg('local');
msg.textContent = ''; msg.className = 'adm-ep-inline-msg'; msg.textContent = ''; msg.className = 'adm-ep-inline-msg';
const raw = (el('adm-epLocalUrl').value || '').trim(); const raw = (el('adm-epLocalUrl').value || '').trim();