Improve AI description generation by using existing description as instructions

Refactor EditVideoDialog to use the description field for custom AI generation instructions and consolidate input fields.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 170e18f0-0f13-4eca-8643-546bba1dd8cc
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/170e18f0-0f13-4eca-8643-546bba1dd8cc/LY6xmBI
This commit is contained in:
sebastjanartic 2025-09-02 13:19:50 +00:00
parent 15e57c3294
commit 1c71b0f6f4

View File

@ -229,7 +229,6 @@ function EditVideoDialog({
}); });
}, [video]); }, [video]);
const [isGeneratingAI, setIsGeneratingAI] = useState(false); const [isGeneratingAI, setIsGeneratingAI] = useState(false);
const [customInstructions, setCustomInstructions] = useState("");
const updateMutation = useMutation({ const updateMutation = useMutation({
mutationFn: (data: any) => apiRequest("PATCH", `/api/admin/videos/${video.id}`, data), mutationFn: (data: any) => apiRequest("PATCH", `/api/admin/videos/${video.id}`, data),
@ -270,13 +269,16 @@ function EditVideoDialog({
return; return;
} }
// Use description field content as custom instructions
const instructions = formData.description.trim();
setIsGeneratingAI(true); setIsGeneratingAI(true);
try { try {
const response = await apiRequest("POST", `/api/admin/videos/${video.id}/generate-description`, { const response = await apiRequest("POST", `/api/admin/videos/${video.id}/generate-description`, {
maxCharacters: 500, maxCharacters: 500,
includeArtistInfo: true, includeArtistInfo: true,
includeLabelInfo: true, includeLabelInfo: true,
customInstructions: customInstructions.trim() || undefined customInstructions: instructions || undefined
}); });
const data = await response.json(); const data = await response.json();
@ -353,21 +355,13 @@ function EditVideoDialog({
{isGeneratingAI ? "Generating..." : "Generate AI Description"} {isGeneratingAI ? "Generating..." : "Generate AI Description"}
</Button> </Button>
</div> </div>
<div className="space-y-2"> <Textarea
<Input value={formData.description}
placeholder="AI instructions (e.g., 'mention band members', 'focus on song history')..." onChange={(e) => setFormData({ ...formData, description: e.target.value })}
value={customInstructions} className="bg-white/10 border-white/20 text-white min-h-[100px]"
onChange={(e) => setCustomInstructions(e.target.value)} rows={3}
className="bg-white/10 border-white/20 text-white placeholder:text-white/50 text-sm" placeholder="Enter description manually or type AI instructions (e.g., 'mention band members', 'focus on song history') and click Generate AI Description..."
/> />
<Textarea
value={formData.description}
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
className="bg-white/10 border-white/20 text-white min-h-[100px]"
rows={3}
placeholder="Enter description or use AI to generate one from the title..."
/>
</div>
<div className="text-xs text-white/60 mt-1"> <div className="text-xs text-white/60 mt-1">
{formData.description.length}/500 characters {formData.description.length}/500 characters
</div> </div>