Preparar repositorio para despliegue: código fuente limpio

This commit is contained in:
jlimolina 2026-01-23 02:00:40 +01:00
parent 866f5c432d
commit 3eca832c1a
76 changed files with 5434 additions and 3496 deletions

View file

@ -13,8 +13,14 @@ def safe_html(texto: Optional[str]) -> str:
return ""
# Sanitize content to prevent layout breakage (e.g. unclosed divs)
allowed_tags = ['b', 'i', 'strong', 'em', 'p', 'br', 'span', 'a']
allowed_attrs = {'a': ['href', 'target', 'rel']}
allowed_tags = [
'b', 'i', 'strong', 'em', 'p', 'br', 'span', 'a', 'img',
'h1', 'h2', 'h3', 'h4', 'ul', 'ol', 'li', 'blockquote'
]
allowed_attrs = {
'a': ['href', 'target', 'rel', 'title'],
'img': ['src', 'alt', 'title', 'width', 'height', 'style']
}
cleaned = bleach.clean(texto, tags=allowed_tags, attributes=allowed_attrs, strip=True)
return Markup(cleaned)

View file

@ -6,7 +6,7 @@ import os
import time
from typing import List, Dict, Any, Optional
from qdrant_client import QdrantClient
from sentence_transformers import SentenceTransformer
# from sentence_transformers import SentenceTransformer (Moved to function)
# Configuración
QDRANT_HOST = os.environ.get("QDRANT_HOST", "localhost")
@ -16,7 +16,7 @@ EMB_MODEL = os.environ.get("EMB_MODEL", "sentence-transformers/paraphrase-multil
# Singleton para clientes globales
_qdrant_client: Optional[QdrantClient] = None
_embedding_model: Optional[SentenceTransformer] = None
_embedding_model: Optional[Any] = None
def get_qdrant_client() -> QdrantClient:
@ -40,12 +40,13 @@ def get_qdrant_client() -> QdrantClient:
return _qdrant_client
def get_embedding_model() -> SentenceTransformer:
def get_embedding_model() -> Any:
"""
Obtiene el modelo de embeddings (singleton).
"""
global _embedding_model
if _embedding_model is None:
from sentence_transformers import SentenceTransformer
_embedding_model = SentenceTransformer(EMB_MODEL, device='cpu')
return _embedding_model