From 36e5b910e9e2edccbc13156dd8e25b5340a43a58 Mon Sep 17 00:00:00 2001 From: Oleg Proskurin Date: Mon, 6 Oct 2025 00:00:42 +0700 Subject: [PATCH] feat: apply enchancements --- apps/landing/src/app/demo/tti/page.tsx | 62 +++- .../components/demo/EnhancementOptions.tsx | 264 ++++++++++++++++++ .../src/components/demo/ResultCard.tsx | 86 +++++- docs/api/api.rest | 13 + 4 files changed, 418 insertions(+), 7 deletions(-) create mode 100644 apps/landing/src/components/demo/EnhancementOptions.tsx diff --git a/apps/landing/src/app/demo/tti/page.tsx b/apps/landing/src/app/demo/tti/page.tsx index 5bf6218..18d9c54 100644 --- a/apps/landing/src/app/demo/tti/page.tsx +++ b/apps/landing/src/app/demo/tti/page.tsx @@ -4,6 +4,7 @@ import { useState, useRef, KeyboardEvent } from 'react'; import { MinimizedApiKey } from '@/components/demo/MinimizedApiKey'; import { GenerationTimer } from '@/components/demo/GenerationTimer'; import { ResultCard } from '@/components/demo/ResultCard'; +import { EnhancementOptions, EnhancementOptionsData } from '@/components/demo/EnhancementOptions'; const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000'; @@ -35,6 +36,7 @@ interface GenerationResult { response: object; geminiParams: object; }; + enhancementOptions?: EnhancementOptionsData; } interface ApiKeyInfo { @@ -57,6 +59,9 @@ export default function DemoTTIPage() { const [generationStartTime, setGenerationStartTime] = useState(); const [generationError, setGenerationError] = useState(''); + // Enhancement Options State + const [enhancementOptions, setEnhancementOptions] = useState({}); + // Results State const [results, setResults] = useState([]); @@ -135,7 +140,35 @@ export default function DemoTTIPage() { const timestamp = new Date(); try { - // Call API twice in parallel (both identical for now) + // Build enhancement options for right image (only non-empty values) + const rightEnhancementOptions: any = {}; + if (enhancementOptions.autoEnhance) { + rightEnhancementOptions.autoEnhance = true; + } + if (enhancementOptions.imageStyle) { + rightEnhancementOptions.imageStyle = enhancementOptions.imageStyle; + } + if (enhancementOptions.aspectRatio) { + rightEnhancementOptions.aspectRatio = enhancementOptions.aspectRatio; + } + if (enhancementOptions.mood) { + rightEnhancementOptions.mood = enhancementOptions.mood; + } + if (enhancementOptions.lighting) { + rightEnhancementOptions.lighting = enhancementOptions.lighting; + } + if (enhancementOptions.cameraAngle) { + rightEnhancementOptions.cameraAngle = enhancementOptions.cameraAngle; + } + if (enhancementOptions.negativePrompts && enhancementOptions.negativePrompts.length > 0) { + rightEnhancementOptions.negativePrompts = enhancementOptions.negativePrompts; + } + + const hasEnhancementOptions = Object.keys(rightEnhancementOptions).length > 0; + + // Call API twice in parallel + // Left: original prompt with no enhancement options + // Right: original prompt WITH enhancement options const [leftResult, rightResult] = await Promise.all([ fetch(`${API_BASE_URL}/api/text-to-image`, { method: 'POST', @@ -157,6 +190,10 @@ export default function DemoTTIPage() { body: JSON.stringify({ prompt: prompt.trim(), filename: `demo_${resultId}_right`, + autoEnhance: true, + ...(hasEnhancementOptions && { + enhancementOptions: rightEnhancementOptions + }), }), }), ]); @@ -201,10 +238,16 @@ export default function DemoTTIPage() { request: { prompt: prompt.trim(), filename: `demo_${resultId}_right`, + autoEnhance: true, + ...(hasEnhancementOptions && { + enhancementOptions: rightEnhancementOptions + }), }, response: rightData, geminiParams: rightData.data?.geminiParams || {}, }, + // Store enhancement options for display in inspect mode + enhancementOptions: hasEnhancementOptions ? enhancementOptions : undefined, }; if (!leftData.success) { @@ -345,7 +388,7 @@ export default function DemoTTIPage() { )} {/* Prompt Input Section */} -
+

Your Prompt