Compare commits

..

8 Commits

Author SHA1 Message Date
5f9c8b7551 Add corporate and senator fun styles
Introduce two new fun styles “Corporate Bullshit” and
“Senator John Kennedy” with corresponding prompt modifiers.

Update tests to cover the new styles and verify the fun category
now contains seven entries.

Add AGENTS.md documenting repository agents
and update package-lock with optional @emnapi core and runtime dev
dependencies.
2026-04-15 19:12:28 -04:00
204edafa40 feat: add Tharoorian English style under Fun category
Imitation of Shashi Tharoor's distinctive oratory — sesquipedalian
vocabulary, serpentine sentences, literary allusions, Oxonian wit,
arcane word choices, rhetorical flourish, em-dash asides, and the
unwavering commitment to never use a short word when a magnificently
polysyllabic one will do.
2026-04-13 10:05:30 -04:00
4a783f28a1 feat: add Caveman style under Fun category
Prompt: rewrite as a neanderthal caveman — broken grammar,
grunt words (ugh, oog), simplest names (big rock, fire stick),
dropped articles and conjugations, thoughts about food/shelter/danger,
raw emotional outbursts.
2026-04-13 01:30:19 -04:00
c96d97e154 feat: add Umami analytics with tagged events
Add Umami web analytics tracking script to the layout head, and
instrument all interactive elements with event tracking:

Declarative (data-umami-event attributes):
- Category selector: select_category
- Style selector: select_style
- Intensity slider: adjust_intensity
- Prompt toggle: toggle_prompt (with open/close action)

Programmatic (umami.track with metadata):
- convert_click: { style, intensity }
- convert_success: { style, intensity, model }
- convert_error: { style, intensity, error }
- copy_result: { style }
2026-04-13 01:21:20 -04:00
eaa1544e66 feat: show routed model name when using openrouter/free
When the configured model is a routing endpoint like 'openrouter/free',
the actual model used (e.g. 'upstage/solar-pro-3:free') is returned in
the LLM response's 'model' field. We now extract that and display it as:

  Responded by upstage/solar-pro-3:free model from openrouter/free

For any other model (e.g. 'llama3', 'gemma2'), we still show just:

  Responded by llama3

Implementation:
- LLM client returns both requestedModel and actualModel
- API endpoint builds a display-friendly modelLabel
- Frontend uses modelLabel for the attribution line
2026-04-13 01:13:47 -04:00
70dc396fe3 fix: remove hardcoded secrets from docker-compose, use env vars + profiles
- Remove hardcoded OpenRouter API key and URL from docker-compose.yml
- App service now reads OPENAI_* vars from .env file (env_file) and
  falls back to http://ollama:11434/v1 defaults
- Ollama and model-init moved to 'ollama' Docker Compose profile,
  so they only start when explicitly requested:
    docker compose --profile ollama up      # with local Ollama
    docker compose up                         # cloud provider only
- Port mapping uses 5656 from .env
- .env.docker updated with documented options for Ollama vs OpenRouter
2026-04-13 01:06:23 -04:00
44f024f1d5 feat: add AI disclaimer banner and persist UI state in localStorage
1. Disclaimer: amber-colored banner between the intensity slider and
   the Convert button warning users that:
   - Results are AI-generated and may be inaccurate or biased
   - Do not enter personal or sensitive information
   - Use at your own discretion, demo only

2. State persistence: all UI state is saved to localStorage under
   'english-styler-state' and restored on page load:
   - Input text
   - Selected category and style
   - Intensity slider position
   - Accordion (Show prompt) open/close state
   Uses () to auto-save whenever state changes.
2026-04-13 00:53:54 -04:00
86d399a04b fix: use npm i instead of npm ci in Docker build, expose on port 5656
- Dockerfile: drop package-lock.json copy, use npm i instead of npm ci
  so install works even if lock file is slightly out of sync
- docker-compose: map host port 5656 → container port 3000
2026-04-13 00:43:19 -04:00
13 changed files with 596 additions and 435 deletions

Binary file not shown.

27
AGENTS.md Normal file
View File

@@ -0,0 +1,27 @@
# AGENTS.md
Short map. Read only what task needs.
## Core
- App: SvelteKit + TypeScript + Vitest.
- Keep changes small. Match existing style. No extra deps unless needed.
- Prefer repo docs over guessing.
## Read on demand
- Product / setup: `README.md`
- Design: `docs/superpowers/specs/2025-04-12-english-style-converter-design.md`
- Build plan: `docs/superpowers/plans/2025-04-12-english-style-converter.md`
- Style data: `src/lib/styles.ts`
- LLM + prompts: `src/lib/llm.ts`
- API: `src/routes/api/convert/+server.ts`
- UI: `src/routes/+page.svelte`
- Shared types: `src/lib/types.ts`
- Component UI bits: `src/lib/components/*`
## Tests
- Use existing `npm test` / `npm run check`.
- Add or update tests near touched code.
## Notes
- Server-only secrets stay in env vars.
- Do not leak private prompt / defense details into UI.

View File

@@ -3,8 +3,8 @@ FROM node:22-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY package.json ./
RUN npm i
COPY . .
RUN npm run build
@@ -25,4 +25,4 @@ ENV PORT=3000
ENV HOST=0.0.0.0
EXPOSE 3000
CMD ["node", "build"]
CMD ["node", "build"]

View File

@@ -1,6 +1,8 @@
services:
ollama:
image: ollama/ollama:latest
profiles:
- ollama
container_name: english-styler-ollama
ports:
- "11434:11434"
@@ -16,6 +18,8 @@ services:
model-init:
image: ollama/ollama:latest
profiles:
- ollama
container_name: english-styler-model-init
depends_on:
ollama:
@@ -34,14 +38,14 @@ services:
build: .
container_name: english-styler-app
ports:
- "3000:3000"
depends_on:
model-init:
condition: service_completed_successfully
- "${APP_PORT:-5656}:3000"
env_file:
- path: .env
required: false
environment:
OPENAI_BASE_URL: http://ollama:11434/v1
OPENAI_API_KEY: ollama
OPENAI_MODEL: ${OLLAMA_MODEL:-llama3}
OPENAI_BASE_URL: ${OPENAI_BASE_URL:-http://ollama:11434/v1}
OPENAI_API_KEY: ${OPENAI_API_KEY:-ollama}
OPENAI_MODEL: ${OPENAI_MODEL:-llama3}
restart: unless-stopped
volumes:

30
package-lock.json generated
View File

@@ -19,6 +19,29 @@
"vitest": "^4.1.3"
}
},
"node_modules/@emnapi/core": {
"version": "1.9.2",
"resolved": "https://registry.npmmirror.com/@emnapi/core/-/core-1.9.2.tgz",
"integrity": "sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"@emnapi/wasi-threads": "1.2.1",
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.9.2",
"resolved": "https://registry.npmmirror.com/@emnapi/runtime/-/runtime-1.9.2.tgz",
"integrity": "sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/wasi-threads": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
@@ -899,7 +922,6 @@
"integrity": "sha512-VRdSbB96cI1EnRh09CqmnQqP/YJvET5buj8S6k7CxaJqBJD4bw4fRKDjcarAj/eX9k2eHifQfDH8NtOh+ZxxPw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@sveltejs/acorn-typescript": "^1.0.5",
@@ -942,7 +964,6 @@
"integrity": "sha512-ILXmxC7HAsnkK2eslgPetrqqW1BKSL7LktsFgqzNj83MaivMGZzluWq32m25j2mDOjmSKX7GGWahePhuEs7P/g==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"deepmerge": "^4.3.1",
"magic-string": "^0.30.21",
@@ -1133,7 +1154,6 @@
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
"dev": true,
"license": "MIT",
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -1886,7 +1906,6 @@
"integrity": "sha512-VmtB2rFU/GroZ4oL8+ZqXgSA38O6GR8KSIvWmEFv63pQ0G6KaBH9s07PO8XTXP4vI+3UJUEypOfjkGfmSBBR0w==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@types/estree": "1.0.8"
},
@@ -2011,7 +2030,6 @@
"integrity": "sha512-dS1N+i3bA1v+c4UDb750MlN5vCO82G6vxh8HeTsPsTdJ1BLsN1zxSyDlIdBBqUjqZ/BxEwM8UrFf98aaoVnZFQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@jridgewell/remapping": "^2.3.4",
"@jridgewell/sourcemap-codec": "^1.5.0",
@@ -2126,7 +2144,6 @@
"integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==",
"dev": true,
"license": "Apache-2.0",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -2141,7 +2158,6 @@
"integrity": "sha512-dbU7/iLVa8KZALJyLOBOQ88nOXtNG8vxKuOT4I2mD+Ya70KPceF4IAmDsmU0h1Qsn5bPrvsY9HJstCRh3hG6Uw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"lightningcss": "^1.32.0",
"picomatch": "^4.0.4",

5
src/app.d.ts vendored
View File

@@ -8,6 +8,11 @@ declare global {
// interface PageState {}
// interface Platform {}
}
// Umami analytics tracker (injected by script tag)
const umami: {
track(event: string, data?: Record<string, string | number | boolean>): void;
};
}
export {};

View File

@@ -21,7 +21,8 @@ export interface ConvertResult {
converted: string;
publicSystemPrompt: string;
publicUserMessage: string;
model: string;
requestedModel: string;
actualModel: string | null;
}
const INPUT_TAG_START = '###### USER INPUT START ######';
@@ -100,10 +101,15 @@ export async function convertText(
throw new Error('LLM returned empty response');
}
// OpenRouter's free router returns the actual model used in data.model
// e.g. requested "openrouter/free" -> actual "upstage/solar-pro-3:free"
const actualModel = (typeof data.model === 'string' && data.model !== merged.model) ? data.model : null;
return {
converted,
publicSystemPrompt: buildPublicSystemPrompt(styleModifier, intensityInstruction),
publicUserMessage: text,
model: merged.model
requestedModel: merged.model,
actualModel
};
}

View File

@@ -57,6 +57,11 @@ describe('getStylesByCategory', () => {
const result = getStylesByCategory('general');
expect(result.length).toBe(6);
});
it('fun category has 7 styles', () => {
const result = getStylesByCategory('fun');
expect(result.length).toBe(7);
});
});
describe('getStyleById', () => {
@@ -70,6 +75,11 @@ describe('getStyleById', () => {
const result = getStyleById('nonexistent');
expect(result).toBeUndefined();
});
it('returns new fun styles by id', () => {
expect(getStyleById('corporate-bullshit')).toBeDefined();
expect(getStyleById('senator-john-kennedy')).toBeDefined();
});
});
describe('getCategoryById', () => {
@@ -109,4 +119,4 @@ describe('getIntensityConfig', () => {
expect(config!.instruction).not.toContain('{style}');
}
});
});
});

View File

@@ -157,6 +157,34 @@ export const styles: Style[] = [
promptModifier:
"Rewrite in Gen Z slang with no cap, fr, and modern internet vernacular",
},
{
id: "corporate-bullshit",
label: "Corporate Bullshit",
categoryId: "fun",
promptModifier:
"Rewrite in polished corporate-speak loaded with buzzwords, euphemisms, and strategic vagueness. Use phrases like circle back, align on priorities, move the needle, best-in-class, leverage synergies, and stakeholder alignment. Prefer passive voice, meeting-room tone, and language that sounds important while saying as little as possible. Keep it coherent enough to pass as a real update, but inflate every plain statement into consultant-grade business jargon.",
},
{
id: "caveman",
label: "Caveman",
categoryId: "fun",
promptModifier:
"Rewrite as a neanderthal caveman would speak — use broken grammar, grunt words like ugh and oog, refer to things by their simplest names like big rock and fire stick, shorten every word, drop articles and verb conjugations entirely, think only about food, shelter, and danger, and express emotions through raw outbursts",
},
{
id: "tharoorian",
label: "Tharoorian English",
categoryId: "fun",
promptModifier:
"Rewrite in the unmistakable style of Shashi Tharoor — deploy sesquipedalian vocabulary with unapologetic ostentation, construct serpentine sentences brimming with subordinate clauses and appositives that cascade toward a devastatingly witty payoff, weave in literary allusions and historical references with the casual air of a man who reads dictionaries for recreation, employ dry Oxonian wit that lands with the precision of a surgeon's scalpel wrapped in a velvet epigram, favour the arcane over the accessible (perspicacious over smart, obfuscate over hide, floccinaucinihilipilification over dismissal), indulge in alliteration and rhetorical flourish, frame even the mundane as though addressing a hushed auditorium, punctuate with sardonic asides set off by em dashes, and never use a short word when a magnificently polysyllabic one will send the listener reaching for their Oxford dictionary",
},
{
id: "senator-john-kennedy",
label: "Senator John Kennedy",
categoryId: "fun",
promptModifier:
"Rewrite as Senator John Kennedy of Louisiana. Voice: plainspoken, folksy, sharp, deadpan, and funny without sounding polished. Make the text sound like a witty Senate-floor quip or a TV interview zinger from a man who translates Washington nonsense into common-sense language. Use short punchy sentences, vivid Southern metaphors, comic comparisons, dry ridicule, and blunt moral judgments. Favor everyday imagery like steak, gumbo, crawfish, pickup trucks, church, a money tree, or something 'tougher than' whatever is being discussed. Lean into contrast between common people and Washington insiders. Keep the jokes clean, the timing crisp, and the tone slightly grumpy but good-natured. The result should feel quotable, homespun, and slyly insulting in a clever way. Do not copy exact famous lines; only evoke the style.",
},
// Game of Thrones
{

View File

@@ -24,7 +24,7 @@ export interface ConversionResponse {
intensity: number;
systemPrompt: string;
userMessage: string;
model: string;
modelLabel: string;
}
export interface LLMConfig {

View File

@@ -6,6 +6,7 @@
<svelte:head>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>✨</text></svg>" />
<script defer src="https://wa.santhoshj.com/script.js" data-website-id="1004961a-2b1f-4c45-95a6-78059acac472"></script>
</svelte:head>
{@render children()}

View File

@@ -1,478 +1,540 @@
<script lang="ts">
import {
categories,
styles,
getStylesByCategory,
getIntensityConfig,
} from "$lib/styles";
import type { Style, StyleCategory, ConversionResponse } from "$lib/types";
import LoadingModal from "$lib/components/LoadingModal.svelte";
import { categories, getStylesByCategory, getIntensityConfig } from '$lib/styles';
import type { ConversionResponse } from '$lib/types';
import LoadingModal from '$lib/components/LoadingModal.svelte';
let inputText = $state("");
let selectedCategoryId = $state("");
let selectedStyleId = $state("");
let intensity = $state(3);
let outputText = $state("");
let loading = $state(false);
let error = $state("");
let systemPrompt = $state("");
let userMessage = $state("");
let modelName = $state("");
let showPrompt = $state(false);
let copied = $state(false);
const STORAGE_KEY = 'english-styler-state';
let availableStyles = $derived(
selectedCategoryId ? getStylesByCategory(selectedCategoryId) : [],
);
interface SavedState {
inputText: string;
selectedCategoryId: string;
selectedStyleId: string;
intensity: number;
showPrompt: boolean;
}
let canConvert = $derived(
inputText.trim().length > 0 && selectedStyleId.length > 0 && !loading,
);
function loadState(): SavedState | null {
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) return null;
return JSON.parse(raw) as SavedState;
} catch {
return null;
}
}
let intensityLabel = $derived(getIntensityConfig(intensity)?.label ?? "");
function saveState() {
try {
const state: SavedState = {
inputText,
selectedCategoryId,
selectedStyleId,
intensity,
showPrompt
};
localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
} catch {
// localStorage may be unavailable (private browsing, etc.)
}
}
function onCategoryChange() {
selectedStyleId = "";
if (availableStyles.length === 1) {
selectedStyleId = availableStyles[0].id;
}
}
const saved = loadState();
async function handleConvert() {
if (!canConvert) return;
let inputText = $state(saved?.inputText ?? '');
let selectedCategoryId = $state(saved?.selectedCategoryId ?? '');
let selectedStyleId = $state(saved?.selectedStyleId ?? '');
let intensity = $state(saved?.intensity ?? 3);
let outputText = $state('');
let loading = $state(false);
let error = $state('');
let systemPrompt = $state('');
let userMessage = $state('');
let modelLabel = $state('');
let showPrompt = $state(saved?.showPrompt ?? false);
let copied = $state(false);
loading = true;
error = "";
outputText = "";
systemPrompt = "";
userMessage = "";
modelName = "";
showPrompt = false;
let availableStyles = $derived(
selectedCategoryId ? getStylesByCategory(selectedCategoryId) : []
);
try {
const res = await fetch("/api/convert", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
text: inputText,
styleId: selectedStyleId,
intensity,
}),
});
let canConvert = $derived(
inputText.trim().length > 0 && selectedStyleId.length > 0 && !loading
);
const data = await res.json();
let intensityLabel = $derived(getIntensityConfig(intensity)?.label ?? '');
if (!res.ok) {
throw new Error(data.error || "Conversion failed");
}
// Persist state whenever it changes
$effect(() => {
saveState();
});
const result: ConversionResponse = data;
outputText = result.converted;
systemPrompt = result.systemPrompt;
userMessage = result.userMessage;
modelName = result.model;
} catch (err) {
error = err instanceof Error ? err.message : "Something went wrong";
} finally {
loading = false;
}
}
function onCategoryChange() {
selectedStyleId = '';
if (availableStyles.length === 1) {
selectedStyleId = availableStyles[0].id;
}
}
async function handleCopy() {
try {
await navigator.clipboard.writeText(outputText);
copied = true;
setTimeout(() => (copied = false), 2000);
} catch {
// Fallback: select text
const textarea = document.querySelector(".output-text");
if (textarea instanceof HTMLElement) {
const range = document.createRange();
range.selectNodeContents(textarea);
const sel = window.getSelection();
sel?.removeAllRanges();
sel?.addRange(range);
}
}
}
async function handleConvert() {
if (!canConvert) return;
if (typeof umami !== 'undefined') {
umami.track('convert_click', { style: selectedStyleId, intensity });
}
loading = true;
error = '';
outputText = '';
systemPrompt = '';
userMessage = '';
modelLabel = '';
showPrompt = false;
try {
const res = await fetch('/api/convert', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: inputText,
styleId: selectedStyleId,
intensity
})
});
const data = await res.json();
if (!res.ok) {
throw new Error(data.error || 'Conversion failed');
}
const result: ConversionResponse = data;
outputText = result.converted;
systemPrompt = result.systemPrompt;
userMessage = result.userMessage;
modelLabel = result.modelLabel;
if (typeof umami !== 'undefined') {
umami.track('convert_success', { style: selectedStyleId, intensity, model: result.modelLabel });
}
} catch (err) {
error = err instanceof Error ? err.message : 'Something went wrong';
if (typeof umami !== 'undefined') {
umami.track('convert_error', { style: selectedStyleId, intensity, error });
}
} finally {
loading = false;
}
}
async function handleCopy() {
if (typeof umami !== 'undefined') {
umami.track('copy_result', { style: selectedStyleId });
}
try {
await navigator.clipboard.writeText(outputText);
copied = true;
setTimeout(() => (copied = false), 2000);
} catch {
const el = document.querySelector('.output-text');
if (el instanceof HTMLElement) {
const range = document.createRange();
range.selectNodeContents(el);
const sel = window.getSelection();
sel?.removeAllRanges();
sel?.addRange(range);
}
}
}
</script>
<main class="container">
<h1 class="title">English Style Converter</h1>
<p class="subtitle">
Transform your text into different English styles and tones
</p>
<h1 class="title">English Style Converter</h1>
<p class="subtitle">Transform your text into different English styles and tones</p>
<div class="card">
<div class="form-group">
<label for="input-text">Your Text</label>
<textarea
id="input-text"
bind:value={inputText}
placeholder="Enter the English text you want to convert... DO NOT ENTER ANY PERSONAL INFORMATION!!"
rows="5"
disabled={loading}
></textarea>
</div>
<div class="card">
<div class="form-group">
<label for="input-text">Your Text</label>
<textarea
id="input-text"
bind:value={inputText}
placeholder="Enter the English text you want to convert..."
rows="5"
disabled={loading}
></textarea>
</div>
<div class="selectors">
<div class="form-group">
<label for="category">Style Category</label>
<select
id="category"
bind:value={selectedCategoryId}
onchange={onCategoryChange}
disabled={loading}
>
<option value="">Choose a category...</option>
{#each categories as cat}
<option value={cat.id}>{cat.emoji} {cat.label}</option>
{/each}
</select>
</div>
<div class="selectors">
<div class="form-group">
<label for="category">Style Category</label>
<select
id="category"
bind:value={selectedCategoryId}
onchange={onCategoryChange}
disabled={loading}
data-umami-event="select_category"
>
<option value="">Choose a category...</option>
{#each categories as cat}
<option value={cat.id}>{cat.emoji} {cat.label}</option>
{/each}
</select>
</div>
<div class="form-group">
<label for="style">Style</label>
<select
id="style"
bind:value={selectedStyleId}
disabled={loading || !selectedCategoryId}
>
{#if !selectedCategoryId}
<option value="">Select a category first...</option>
{:else if availableStyles.length === 0}
<option value="">No styles available</option>
{:else}
<option value="">Choose a style...</option>
{#each availableStyles as style}
<option value={style.id}>{style.label}</option>
{/each}
{/if}
</select>
</div>
</div>
<div class="form-group">
<label for="style">Style</label>
<select id="style" bind:value={selectedStyleId} disabled={loading || !selectedCategoryId} data-umami-event="select_style">
{#if !selectedCategoryId}
<option value="">Select a category first...</option>
{:else if availableStyles.length === 0}
<option value="">No styles available</option>
{:else}
<option value="">Choose a style...</option>
{#each availableStyles as style}
<option value={style.id}>{style.label}</option>
{/each}
{/if}
</select>
</div>
</div>
<div class="form-group">
<label for="intensity">
Intensity: <span class="intensity-label"
>{intensityLabel || "Strong"}</span
>
</label>
<div class="slider-row">
<span class="slider-end">Subtle</span>
<input
id="intensity"
type="range"
min="1"
max="5"
step="1"
bind:value={intensity}
disabled={loading}
/>
<span class="slider-end">Maximum</span>
</div>
</div>
<div class="form-group">
<label for="intensity">
Intensity: <span class="intensity-label">{intensityLabel || 'Strong'}</span>
</label>
<div class="slider-row">
<span class="slider-end">Subtle</span>
<input
id="intensity"
type="range"
min="1"
max="5"
step="1"
bind:value={intensity}
disabled={loading}
data-umami-event="adjust_intensity"
/>
<span class="slider-end">Maximum</span>
</div>
</div>
<button
class="convert-btn"
onclick={handleConvert}
disabled={!canConvert}
>
{#if loading}
Converting...
{:else}
✨ Convert
{/if}
</button>
</div>
<div class="disclaimer">
<span class="disclaimer-icon"></span>
<span>This tool uses AI to generate styled text. Results may be inaccurate, biased, or unexpected. Do not enter personal or sensitive information. Use at your own discretion — this is a demo and outputs should not be relied upon for important purposes.</span>
</div>
{#if error}
<div class="output-card error-card">
<p class="error-text">⚠️ {error}</p>
</div>
{/if}
<button class="convert-btn" onclick={handleConvert} disabled={!canConvert}>
{#if loading}
Converting...
{:else}
✨ Convert
{/if}
</button>
</div>
{#if outputText}
<div class="output-card">
<div class="output-header">
<h3>Result</h3>
<button class="copy-btn" onclick={handleCopy}>
{#if copied}
✓ Copied!
{:else}
📋 Copy
{/if}
</button>
</div>
<div class="output-text">{outputText}</div>
{#if modelName}
<p class="model-attribution">Responded by {modelName}</p>
{/if}
</div>
{#if error}
<div class="output-card error-card">
<p class="error-text">⚠️ {error}</p>
</div>
{/if}
<div class="prompt-section">
<button
class="prompt-toggle"
onclick={() => (showPrompt = !showPrompt)}
>
{showPrompt ? "▼" : "▶"} Show prompt
</button>
{#if showPrompt}
<div class="prompt-content">
<div class="prompt-block">
<h4>System Prompt</h4>
<pre>{systemPrompt}</pre>
</div>
<div class="prompt-block">
<h4>User Message</h4>
<pre>{userMessage}</pre>
</div>
</div>
{/if}
</div>
{/if}
{#if outputText}
<div class="output-card">
<div class="output-header">
<h3>Result</h3>
<button class="copy-btn" onclick={handleCopy}>
{#if copied}
✓ Copied!
{:else}
📋 Copy
{/if}
</button>
</div>
<div class="output-text">{outputText}</div>
{#if modelLabel}
<p class="model-attribution">Responded by {modelLabel}</p>
{/if}
</div>
<div class="prompt-section">
<button class="prompt-toggle" onclick={() => (showPrompt = !showPrompt)} data-umami-event="toggle_prompt" data-umami-event-action={showPrompt ? 'close' : 'open'}>
{showPrompt ? '▼' : '▶'} Show prompt
</button>
{#if showPrompt}
<div class="prompt-content">
<div class="prompt-block">
<h4>System Prompt</h4>
<pre>{systemPrompt}</pre>
</div>
<div class="prompt-block">
<h4>User Message</h4>
<pre>{userMessage}</pre>
</div>
</div>
{/if}
</div>
{/if}
</main>
{#if loading}
<LoadingModal />
<LoadingModal />
{/if}
<style>
.container {
max-width: 680px;
margin: 0 auto;
padding: 2rem 1.5rem;
min-height: 100vh;
}
.container {
max-width: 680px;
margin: 0 auto;
padding: 2rem 1.5rem;
min-height: 100vh;
}
.title {
font-size: 2rem;
font-weight: 800;
color: #1f2937;
text-align: center;
margin-bottom: 0.25rem;
}
.title {
font-size: 2rem;
font-weight: 800;
color: #1f2937;
text-align: center;
margin-bottom: 0.25rem;
}
.subtitle {
text-align: center;
color: #6b7280;
margin-bottom: 2rem;
font-size: 1.05rem;
}
.subtitle {
text-align: center;
color: #6b7280;
margin-bottom: 2rem;
font-size: 1.05rem;
}
.card {
background: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 12px;
padding: 1.5rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.card {
background: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 12px;
padding: 1.5rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.form-group {
margin-bottom: 1.25rem;
}
.form-group {
margin-bottom: 1.25rem;
}
.form-group label {
display: block;
font-weight: 600;
font-size: 0.9rem;
color: #374151;
margin-bottom: 0.4rem;
}
.form-group label {
display: block;
font-weight: 600;
font-size: 0.9rem;
color: #374151;
margin-bottom: 0.4rem;
}
textarea,
select {
width: 100%;
padding: 0.75rem;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 0.95rem;
font-family: inherit;
background: #fafafa;
color: #1f2937;
transition: border-color 0.2s;
}
textarea,
select {
width: 100%;
padding: 0.75rem;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 0.95rem;
font-family: inherit;
background: #fafafa;
color: #1f2937;
transition: border-color 0.2s;
}
textarea:focus,
select:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
textarea:focus,
select:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
textarea {
resize: vertical;
min-height: 100px;
}
textarea {
resize: vertical;
min-height: 100px;
}
.selectors {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.selectors {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.intensity-label {
color: #3b82f6;
font-weight: 700;
}
.intensity-label {
color: #3b82f6;
font-weight: 700;
}
.slider-row {
display: flex;
align-items: center;
gap: 0.75rem;
}
.slider-row {
display: flex;
align-items: center;
gap: 0.75rem;
}
.slider-end {
font-size: 0.8rem;
color: #9ca3af;
white-space: nowrap;
}
.slider-end {
font-size: 0.8rem;
color: #9ca3af;
white-space: nowrap;
}
input[type="range"] {
flex: 1;
}
input[type='range'] {
flex: 1;
}
.convert-btn {
width: 100%;
padding: 0.85rem;
background: #3b82f6;
color: #ffffff;
border: none;
border-radius: 8px;
font-size: 1.05rem;
font-weight: 700;
cursor: pointer;
transition:
background 0.2s,
opacity 0.2s;
}
.disclaimer {
background: #fff8ed;
border: 1px solid #f6c96a;
border-radius: 8px;
padding: 0.75rem 1rem;
margin-bottom: 1.25rem;
font-size: 0.82rem;
line-height: 1.5;
color: #8b6914;
display: flex;
gap: 0.6rem;
align-items: flex-start;
}
.convert-btn:hover:not(:disabled) {
background: #2563eb;
}
.disclaimer-icon {
flex-shrink: 0;
font-size: 1rem;
line-height: 1.5;
}
.convert-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.convert-btn {
width: 100%;
padding: 0.85rem;
background: #3b82f6;
color: #ffffff;
border: none;
border-radius: 8px;
font-size: 1.05rem;
font-weight: 700;
cursor: pointer;
transition: background 0.2s, opacity 0.2s;
}
.output-card {
margin-top: 1.5rem;
background: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 12px;
padding: 1.25rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.convert-btn:hover:not(:disabled) {
background: #2563eb;
}
.error-card {
border-color: #fca5a5;
background: #fef2f2;
}
.convert-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.error-text {
color: #dc2626;
font-weight: 500;
}
.output-card {
margin-top: 1.5rem;
background: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 12px;
padding: 1.25rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.output-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.75rem;
}
.error-card {
border-color: #fca5a5;
background: #fef2f2;
}
.output-header h3 {
margin: 0;
font-size: 1.1rem;
color: #1f2937;
}
.error-text {
color: #dc2626;
font-weight: 500;
}
.copy-btn {
padding: 0.35rem 0.75rem;
background: #f3f4f6;
border: 1px solid #d1d5db;
border-radius: 6px;
font-size: 0.85rem;
cursor: pointer;
transition: background 0.2s;
}
.output-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.75rem;
}
.copy-btn:hover {
background: #e5e7eb;
}
.output-header h3 {
margin: 0;
font-size: 1.1rem;
color: #1f2937;
}
.output-text {
white-space: pre-wrap;
line-height: 1.6;
color: #1f2937;
font-size: 1rem;
}
.copy-btn {
padding: 0.35rem 0.75rem;
background: #f3f4f6;
border: 1px solid #d1d5db;
border-radius: 6px;
font-size: 0.85rem;
cursor: pointer;
transition: background 0.2s;
}
.model-attribution {
margin-top: 0.75rem;
font-size: 0.8rem;
color: #9ca3af;
font-style: italic;
}
.copy-btn:hover {
background: #e5e7eb;
}
.prompt-section {
margin-top: 1rem;
}
.output-text {
white-space: pre-wrap;
line-height: 1.6;
color: #1f2937;
font-size: 1rem;
}
.prompt-toggle {
background: none;
border: none;
color: #3b82f6;
font-size: 0.9rem;
font-weight: 600;
cursor: pointer;
padding: 0.5rem 0;
}
.model-attribution {
margin-top: 0.75rem;
font-size: 0.8rem;
color: #9ca3af;
font-style: italic;
}
.prompt-toggle:hover {
text-decoration: underline;
}
.prompt-section {
margin-top: 1rem;
}
.prompt-content {
margin-top: 0.75rem;
}
.prompt-toggle {
background: none;
border: none;
color: #3b82f6;
font-size: 0.9rem;
font-weight: 600;
cursor: pointer;
padding: 0.5rem 0;
}
.prompt-block {
margin-bottom: 1rem;
}
.prompt-toggle:hover {
text-decoration: underline;
}
.prompt-block h4 {
font-size: 0.85rem;
color: #6b7280;
margin-bottom: 0.4rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.prompt-content {
margin-top: 0.75rem;
}
.prompt-block pre {
background: #f9fafb;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 0.75rem;
font-size: 0.85rem;
white-space: pre-wrap;
word-break: break-word;
color: #374151;
margin: 0;
}
.prompt-block {
margin-bottom: 1rem;
}
@media (max-width: 600px) {
.selectors {
grid-template-columns: 1fr;
}
.prompt-block h4 {
font-size: 0.85rem;
color: #6b7280;
margin-bottom: 0.4rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.container {
padding: 1rem;
}
.prompt-block pre {
background: #f9fafb;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 0.75rem;
font-size: 0.85rem;
white-space: pre-wrap;
word-break: break-word;
color: #374151;
margin: 0;
}
.title {
font-size: 1.5rem;
}
}
</style>
@media (max-width: 600px) {
.selectors {
grid-template-columns: 1fr;
}
.container {
padding: 1rem;
}
.title {
font-size: 1.5rem;
}
}
</style>

View File

@@ -54,7 +54,9 @@ export const POST: RequestHandler = async ({ request }) => {
intensity,
systemPrompt: result.publicSystemPrompt,
userMessage: result.publicUserMessage,
model: result.model
modelLabel: result.actualModel
? `${result.actualModel} model from ${result.requestedModel}`
: result.requestedModel
};
return json(response);