Improve AI description generation for video content and fix errors
Update the AI description generation process to correctly handle and display AI-generated descriptions in the admin interface, including error handling and success notifications. 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:
parent
e948249a96
commit
7b2008baff
BIN
attached_assets/image_1756818516935.png
Normal file
BIN
attached_assets/image_1756818516935.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@ -264,11 +264,26 @@ function EditVideoDialog({
|
|||||||
includeLabelInfo: true
|
includeLabelInfo: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.description) {
|
const data = await response.json();
|
||||||
setFormData(prev => ({ ...prev, description: response.description }));
|
|
||||||
|
console.log("AI Response:", data); // Debug log
|
||||||
|
|
||||||
|
if (data && data.description) {
|
||||||
|
console.log("Setting description:", data.description); // Debug log
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
description: data.description
|
||||||
|
}));
|
||||||
toast({
|
toast({
|
||||||
title: "Success",
|
title: "Uspeh!",
|
||||||
description: `AI description generated (${response.characterCount}/${response.maxCharacters} characters)`,
|
description: `AI opis je bil ustvarjen (${data.characterCount || data.description.length}/500 znakov)`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error("No description in response:", data);
|
||||||
|
toast({
|
||||||
|
title: "Napaka",
|
||||||
|
description: "AI ni vrnil opisa",
|
||||||
|
variant: "destructive",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
@ -1103,12 +1103,15 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
includeLabelInfo
|
includeLabelInfo
|
||||||
});
|
});
|
||||||
|
|
||||||
res.json({
|
const result = {
|
||||||
description,
|
description,
|
||||||
title: video.title,
|
title: video.title,
|
||||||
characterCount: description.length,
|
characterCount: description.length,
|
||||||
maxCharacters
|
maxCharacters
|
||||||
});
|
};
|
||||||
|
|
||||||
|
console.log("Sending AI response:", result); // Debug log
|
||||||
|
res.json(result);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error generating AI description:", error);
|
console.error("Error generating AI description:", error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user