Historia Diaria is highly customizable. You can change the AI prompt, modify the HTML template styling, adjust date formats, and customize image sources.
The AI prompt defines what kind of stories are generated. Here’s the current prompt from generar_historia.py:
generar_historia.py
prompt = """Escribe una historia corta de ciencia ficción o fantasía.Debes devolver tu respuesta EXACTAMENTE en este formato:<TITULO>Aquí va el título</TITULO><HISTORIA>Aquí va la historia en unos dos o tres párrafos.</HISTORIA><IMAGEN>una_sola_palabra_clave_en_ingles</IMAGEN>"""
Edit lines 11-17 in generar_historia.py to change the story type:
prompt = """Escribe una historia corta de misterio o suspenso.Debes devolver tu respuesta EXACTAMENTE en este formato:<TITULO>Aquí va el título</TITULO><HISTORIA>Aquí va la historia en unos dos o tres párrafos.</HISTORIA><IMAGEN>una_sola_palabra_clave_en_ingles</IMAGEN>"""
Important: Always maintain the exact XML-like format (<TITULO>, <HISTORIA>, <IMAGEN>) in your prompt. The script uses regex to extract these values. If you change the format, you must also update the extraction logic.
Modify the prompt to request longer or shorter stories:
generar_historia.py
# For longer stories:<HISTORIA>Aquí va la historia en cinco o seis párrafos detallados.</HISTORIA># For shorter stories:<HISTORIA>Aquí va la historia en un solo párrafo.</HISTORIA># For specific word count:<HISTORIA>Aquí va la historia en exactamente 200 palabras.</HISTORIA>
prompt = """Escribe una historia corta de ciencia ficción o fantasía.Requisitos:- Incluye un protagonista con un dilema moral- Usa un tono poético y descriptivo- Ambientación: futuro lejano o mundo mágico- Longitud: 2-3 párrafosDebes devolver tu respuesta EXACTAMENTE en este formato:<TITULO>Aquí va el título</TITULO><HISTORIA>Aquí va la historia en unos dos o tres párrafos.</HISTORIA><IMAGEN>una_sola_palabra_clave_en_ingles</IMAGEN>"""
The template includes extensive CSS. Here are key sections you can customize:
Color Scheme
Edit the color variables in the <style> section (lines 8-104):
plantilla.html
body { background-color: #f0f2f5; /* Page background */}.container { background-color: #ffffff; /* Card background */}h1 { color: #2d3748; /* Title color */}.historia-texto { color: #4a5568; /* Story text color */}
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;}
Custom Fonts
body { font-family: 'Georgia', serif; /* Classic look */}/* Or use Google Fonts */@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&display=swap');body { font-family: 'Merriweather', serif;}
# Random nature photos from Unsplashurl_imagen = "https://source.unsplash.com/600x350/?nature,landscape"# Or based on story keyword (requires AI IMAGEN tag parsing):imagen_keyword = imagen_match.group(1).strip() if imagen_match else "abstract"url_imagen = f"https://source.unsplash.com/600x350/?{imagen_keyword}"