feat(phase-1): Complete foundation setup
- Add User model and authentication system with JWT cookies - Implement login/logout routes and protected dashboard - Add Alembic database migration configuration - Add create_admin.py script for initial user setup - Make ContentGenerator and ImageGenerator lazy-initialized - Add comprehensive API keys setup documentation - Fix startup errors when services unavailable Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,12 +13,21 @@ class ContentGenerator:
|
||||
"""Generador de contenido usando DeepSeek API."""
|
||||
|
||||
def __init__(self):
|
||||
self.client = OpenAI(
|
||||
api_key=settings.DEEPSEEK_API_KEY,
|
||||
base_url=settings.DEEPSEEK_BASE_URL
|
||||
)
|
||||
self._client = None
|
||||
self.model = "deepseek-chat"
|
||||
|
||||
@property
|
||||
def client(self):
|
||||
"""Lazy initialization del cliente OpenAI."""
|
||||
if self._client is None:
|
||||
if not settings.DEEPSEEK_API_KEY:
|
||||
raise ValueError("DEEPSEEK_API_KEY no configurada. Configura la variable de entorno.")
|
||||
self._client = OpenAI(
|
||||
api_key=settings.DEEPSEEK_API_KEY,
|
||||
base_url=settings.DEEPSEEK_BASE_URL
|
||||
)
|
||||
return self._client
|
||||
|
||||
def _get_system_prompt(self) -> str:
|
||||
"""Obtener el prompt del sistema con la personalidad de la marca."""
|
||||
return f"""Eres el Community Manager de {settings.BUSINESS_NAME}, una empresa de tecnología ubicada en {settings.BUSINESS_LOCATION}.
|
||||
|
||||
@@ -24,10 +24,22 @@ class ImageGenerator:
|
||||
loader=FileSystemLoader(self.templates_dir)
|
||||
)
|
||||
|
||||
self.hti = Html2Image(
|
||||
output_path=str(self.output_dir),
|
||||
custom_flags=['--no-sandbox', '--disable-gpu']
|
||||
)
|
||||
self._hti = None
|
||||
|
||||
@property
|
||||
def hti(self):
|
||||
"""Lazy initialization de Html2Image."""
|
||||
if self._hti is None:
|
||||
try:
|
||||
self._hti = Html2Image(
|
||||
output_path=str(self.output_dir),
|
||||
custom_flags=['--no-sandbox', '--disable-gpu']
|
||||
)
|
||||
except FileNotFoundError:
|
||||
raise RuntimeError(
|
||||
"Chrome/Chromium no encontrado. Instala Chrome o ejecuta en Docker."
|
||||
)
|
||||
return self._hti
|
||||
|
||||
def _render_template(self, template_name: str, variables: Dict) -> str:
|
||||
"""Renderizar una plantilla HTML con variables."""
|
||||
|
||||
Reference in New Issue
Block a user