-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
aiAI-powered featuresAI-powered featuresfeatureNew feature requestNew feature requestphase-3First AI featureFirst AI feature
Description
Phase 3 — First AI Feature (1/2)
Implement the backend logic and prompt engineering for AI-powered OG copy generation.
Scope
System Prompts (`src/lib/ai/prompts.ts`)
Title generation prompt:
```
You are an expert copywriter specializing in social media and OG image text.
Generate {count} compelling, click-worthy title options for an OG image.
Rules:
- Maximum 60 characters per title (OG images have limited space)
- Be specific and intriguing, avoid generic phrases
- Match the tone: {tone} (professional / casual / technical / creative)
- Category: {category}
- If context is provided, use it to make titles relevant
Return as a JSON array of strings. No explanation, just the array.
```
Description/subtitle generation prompt:
```
Generate {count} concise subtitle options for an OG image.
Rules:
- Maximum 80 characters
- Complement the title: "{title}"
- Add context without repeating the title
- Category: {category}
Return as a JSON array of strings. No explanation, just the array.
```
Generation Function (`src/lib/ai/generate.ts`)
- `generateTitles(context): Promise<string[]>`
- Inputs: category, topic/brief description, tone, count (default 3)
- Returns: array of title suggestions
- `generateSubtitles(context): Promise<string[]>`
- Inputs: category, title (to complement), tone, count (default 3)
- Returns: array of subtitle suggestions
- Parse AI response (handle JSON in markdown code blocks, plain text fallbacks)
- Retry once on parse failure with a "please return valid JSON" follow-up
Response Parsing
- AI responses may come wrapped in ```json ... ``` blocks — strip those
- Validate response is an array of strings
- Filter out any results exceeding character limits
- Fallback: if parsing completely fails, return the raw text split by newlines
Acceptance Criteria
- Title generation returns 3 relevant, correctly-sized suggestions
- Subtitle generation complements the given title
- Prompts are category-aware (blog vs product vs event tone)
- JSON response parsing handles edge cases (code blocks, trailing commas)
- Works with all 5 providers (same prompts, different API formats)
- Character limits are enforced on results
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
aiAI-powered featuresAI-powered featuresfeatureNew feature requestNew feature requestphase-3First AI featureFirst AI feature