Skip to content

Add LLM-driven theme-matched quote card generator with emotion-based palettes#141

Open
Copilot wants to merge 6 commits intomasterfrom
copilot/add-theme-matched-background
Open

Add LLM-driven theme-matched quote card generator with emotion-based palettes#141
Copilot wants to merge 6 commits intomasterfrom
copilot/add-theme-matched-background

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 5, 2025

Implements dynamic Quote of the Day cards that analyze quote sentiment via LLM and apply matching visual themes. Cards adapt background gradients and stylistic effects based on emotional tone.

Core Components

  • scripts/analyze_quote.py: OpenAI-powered quote analysis extracting sentiment, tone, theme, and color profile. Falls back to neutral palette when API unavailable.

  • scripts/generate_quote_card.py: CardBase-integrated SVG generator with smart text wrapping, dynamic gradient selection, and conditional visual effects.

  • Emotion Palettes: 6 gradient pairs in theme.json (warm/cool/neutral/ethereal/cosmic/grounded) mapped to quote emotional profiles.

  • Stylistic Effects: Conditional decorations based on keywords:

    • sunrise/sky → horizontal gradient bands
    • storm/rain → diagonal streaks
    • cosmic/universe → dynamically positioned starfield
    • gentle/soft → vignette overlay

Schema & Configuration

Extended theme.schema.json with emotion gradient definitions. Added quote card dimensions (480×200) to theme config. OpenAI settings configurable via OPENAI_MODEL env var (defaults to gpt-4o-mini, temp=0.3, max_tokens=200).

Workflow Integration

Integrated into build-profile.yml between Oura mood generation and SVG optimization. Creates sample quote if missing, analyzes with LLM, generates card, commits quotes/quote*.{json,svg}.

Example

# Analysis output structure
{
  "sentiment": "uplifting",
  "tone": "empowering", 
  "theme": "action",
  "color_profile": "warm",  # Maps to theme.json gradient
  "style_keywords": ["sunrise", "bright"]
}

Generates card with #FFAD7A → #FF6F5E gradient plus sunrise effect overlay.

Testing

21 unit tests covering fallback logic, text wrapping, palette selection, and effect generation. All 247 existing tests pass. Zero CodeQL alerts, zero dependency vulnerabilities.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add Theme-Matched Background Based on Quote Meaning</issue_title>
<issue_description># Add Theme-Matched Background Based on Quote Meaning

After the base Quote of the Day card is completed, enhance the card generator to dynamically select a background style that matches the perceived meaning, sentiment, and emotional tone of the quote. This card should feel expressive, thematic, and aligned with the cosmic design language of the repo.

This enhancement uses an LLM to analyze the quote and map it to an appropriate palette and gradient defined in theme.json.


1. Add Quote Interpretation Step (LLM)

Create:
scripts/analyze_quote.py

This script should:

  • Read quotes/quote.json
  • Use OpenAI (or configured LLM) to analyze:
    • sentiment
    • emotional tone
    • thematic category
    • aesthetic keywords
    • palette hints (warm, cool, neutral, cosmic, ethereal)
  • Output structured JSON to:
    quotes/quote_analysis.json

Example structure:
{
"sentiment": "uplifting",
"tone": "hopeful",
"theme": "renewal",
"color_profile": "warm",
"style_keywords": ["sunrise", "calm clarity"],
"llm_version": "gpt-4o-mini",
"interpreted_at": "ISO_TIMESTAMP"
}


2. Extend theme.json With Emotion Palettes (if missing)

Add optional palettes:
"emotion_palettes": {
"warm": ["#FFAD7A", "#FF6F5E"],
"cool": ["#7ABEFF", "#4A6FFF"],
"neutral": ["#DCE1E7", "#AAB1B8"],
"ethereal": ["#C8A9FF", "#E7D1FF"],
"cosmic": ["#6A00FF", "#B691FF"],
"grounded": ["#A26F4E", "#D2B48C"]
}


3. Update Quote Card Generator to Use Analysis Output

Modify:
scripts/generate_quote_card.py

  • Load quotes/quote_analysis.json
  • Select palette via:
    • color_profile
    • sentiment
    • tone
    • keywords
  • Use CardBase / theme utilities for:
    • gradient background
    • accent styles
    • glow effects
    • text contrast adjustment

4. Add Optional Stylistic Variants

Based on keywords:

  • “sunrise”, “sky” → horizontal gradient band
  • “storm”, “rain” → subtle diagonal streaks
  • “cosmic”, “universe” → light starfield
  • “gentle”, “soft” → low-opacity vignette

These should be minimal and theme-consistent.


5. Integrate Into Unified Workflow

In build-profile.yml:

  • Run analyze_quote.py
  • Then run generate_quote_card.py
  • Commit:
    quotes/quote_analysis.json
    quotes/quote_card.svg

Quote card must always generate, falling back to a neutral palette if needed.


Expected Output

A dynamic, expressive Quote of the Day card that:

  • reflects emotional meaning of the quote
  • selects a matching color gradient
  • optionally adds minimal stylistic decoration
  • integrates fully with theme.json and CardBase</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits December 5, 2025 05:09
Co-authored-by: szmyty <14865041+szmyty@users.noreply.github.com>
Co-authored-by: szmyty <14865041+szmyty@users.noreply.github.com>
Co-authored-by: szmyty <14865041+szmyty@users.noreply.github.com>
Co-authored-by: szmyty <14865041+szmyty@users.noreply.github.com>
Co-authored-by: szmyty <14865041+szmyty@users.noreply.github.com>
Copilot AI changed the title [WIP] Add theme-matched background based on quote meaning Add LLM-driven theme-matched quote card generator with emotion-based palettes Dec 5, 2025
Copilot AI requested a review from szmyty December 5, 2025 05:22
@szmyty szmyty marked this pull request as ready for review December 5, 2025 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Theme-Matched Background Based on Quote Meaning

2 participants