- SvelteKit project scaffolded with TypeScript - Type definitions for Style, StyleCategory, ConversionRequest, ConversionResponse, LLMConfig - Style definitions with 6 categories and 25 sub-styles - Intensity mapping (1-5) with prompt modifier placeholders - LLM client using OpenAI-compatible API (Ollama default) - POST /api/convert endpoint with input validation - Animated loading modal with per-letter animations - Main page UI with category/style selectors, intensity slider - Copy to clipboard, collapsible prompt display - Vitest tests for styles, LLM prompt building, and API validation - Environment configuration for LLM settings
73 lines
5.3 KiB
TypeScript
73 lines
5.3 KiB
TypeScript
import type { Style, StyleCategory } from './types';
|
|
|
|
export const categories: StyleCategory[] = [
|
|
{ id: 'general', label: 'General', emoji: '🎭' },
|
|
{ id: 'british', label: 'British Slang', emoji: '🇬🇧' },
|
|
{ id: 'american', label: 'American Slang', emoji: '🇺🇸' },
|
|
{ id: 'fun', label: 'Fun', emoji: '🏴☠️' },
|
|
{ id: 'got', label: 'Game of Thrones', emoji: '🐉' },
|
|
{ id: 'dystopian', label: 'Dystopian', emoji: '📰' }
|
|
];
|
|
|
|
export const styles: Style[] = [
|
|
// General
|
|
{ id: 'sarcastic', label: 'Sarcastic', categoryId: 'general', promptModifier: 'Rewrite in a sarcastic, snarky tone with biting wit' },
|
|
{ id: 'formal', label: 'Formal', categoryId: 'general', promptModifier: 'Rewrite in a highly formal, professional tone' },
|
|
{ id: 'casual', label: 'Casual', categoryId: 'general', promptModifier: 'Rewrite in a laid-back, casual conversational tone' },
|
|
{ id: 'academic', label: 'Academic', categoryId: 'general', promptModifier: 'Rewrite in an academic, scholarly tone with precise language' },
|
|
{ id: 'poetic', label: 'Poetic', categoryId: 'general', promptModifier: 'Rewrite in a poetic, lyrical style with imagery and rhythm' },
|
|
{ id: 'passive-aggressive', label: 'Passive-Aggressive', categoryId: 'general', promptModifier: 'Rewrite in a passive-aggressive tone with backhanded compliments' },
|
|
|
|
// British Slang
|
|
{ id: 'british-polite', label: 'Polite (British)', categoryId: 'british', promptModifier: 'Rewrite in polite British English with understated courtesy' },
|
|
{ id: 'british-formal', label: 'Formal (British)', categoryId: 'british', promptModifier: 'Rewrite in formal British English with proper stiff-upper-lip expression' },
|
|
{ id: 'british-witty', label: 'Witty (British)', categoryId: 'british', promptModifier: 'Rewrite in witty British style with dry humor and clever wordplay' },
|
|
{ id: 'british-gentlemanly', label: 'Gentlemanly', categoryId: 'british', promptModifier: 'Rewrite as a proper British gentleman would speak' },
|
|
{ id: 'british-upper-class', label: 'Upper Class', categoryId: 'british', promptModifier: 'Rewrite in the manner of British upper-class speech with RP accent sensibilities' },
|
|
{ id: 'british-royal', label: 'Royal', categoryId: 'british', promptModifier: 'Rewrite as if speaking with royal British formality and majesty' },
|
|
{ id: 'british-victorian', label: 'Victorian', categoryId: 'british', promptModifier: 'Rewrite in Victorian-era British English with archaic formality' },
|
|
{ id: 'british-downton', label: 'Downton Abbey', categoryId: 'british', promptModifier: 'Rewrite in the style of Downton Abbey characters' },
|
|
|
|
// American Slang
|
|
{ id: 'american-new-yorker', label: 'New Yorker', categoryId: 'american', promptModifier: 'Rewrite in a New York City style with directness and local flavor' },
|
|
{ id: 'american-black-slang', label: 'Black American Slang', categoryId: 'american', promptModifier: 'Rewrite in Black American Vernacular English (AAVE) with cultural flair' },
|
|
{ id: 'american-southern', label: 'Southern', categoryId: 'american', promptModifier: 'Rewrite with Southern American charm and hospitality' },
|
|
{ id: 'american-redneck', label: 'Redneck', categoryId: 'american', promptModifier: 'Rewrite in a rural American redneck style with country twang' },
|
|
|
|
// Fun
|
|
{ id: 'pirate', label: 'Pirate', categoryId: 'fun', promptModifier: 'Rewrite like a pirate with arrrs and nautical terms' },
|
|
{ id: 'shakespearean', label: 'Shakespearean', categoryId: 'fun', promptModifier: 'Rewrite in Shakespearean English with thee, thou, and poetic flourish' },
|
|
{ id: 'gen-z', label: 'Gen Z Slang', categoryId: 'fun', promptModifier: 'Rewrite in Gen Z slang with no cap, fr, and modern internet vernacular' },
|
|
|
|
// Game of Thrones
|
|
{ id: 'got-kings-landing', label: "King's Landing", categoryId: 'got', promptModifier: 'Rewrite as a scheming noble from Kings Landing would speak' },
|
|
{ id: 'got-wildlings', label: 'Wildlings', categoryId: 'got', promptModifier: 'Rewrite in the rough, free-spirited manner of the Free Folk wildlings' },
|
|
{ id: 'got-winterfell', label: 'Winterfell', categoryId: 'got', promptModifier: 'Rewrite with the honor-bound stoicism of a Stark from Winterfell' },
|
|
|
|
// Dystopian
|
|
{ id: 'newspeak', label: 'Newspeak (Orwellian)', categoryId: 'dystopian', promptModifier: 'Rewrite in Orwellian Newspeak, minimizing vocabulary and thought as the Party demands' }
|
|
];
|
|
|
|
export const intensityMap: Record<number, { label: string; instruction: string }> = {
|
|
1: { label: 'Subtle', instruction: 'lightly hint at a {style} tone' },
|
|
2: { label: 'Moderate', instruction: 'rewrite with a {style} tone' },
|
|
3: { label: 'Strong', instruction: 'rewrite strongly in a {style} style' },
|
|
4: { label: 'Heavy', instruction: 'rewrite completely in {style} — fully commit to the voice' },
|
|
5: { label: 'Maximum', instruction: 'go absolutely all-out {style} — no restraint' }
|
|
};
|
|
|
|
export function getStylesByCategory(categoryId: string): Style[] {
|
|
return styles.filter((s) => s.categoryId === categoryId);
|
|
}
|
|
|
|
export function getStyleById(styleId: string): Style | undefined {
|
|
return styles.find((s) => s.id === styleId);
|
|
}
|
|
|
|
export function getCategoryById(categoryId: string): StyleCategory | undefined {
|
|
return categories.find((c) => c.id === categoryId);
|
|
}
|
|
|
|
export function getIntensityConfig(intensity: number): { label: string; instruction: string } | undefined {
|
|
return intensityMap[intensity];
|
|
} |