Enhance AI description generation with custom instructions for users
Add a custom instructions input field to the admin video edit dialog and backend to allow users to guide the AI description generation process. 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
6b80ac00c6
commit
15e57c3294
@ -229,6 +229,7 @@ function EditVideoDialog({
|
||||
});
|
||||
}, [video]);
|
||||
const [isGeneratingAI, setIsGeneratingAI] = useState(false);
|
||||
const [customInstructions, setCustomInstructions] = useState("");
|
||||
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: (data: any) => apiRequest("PATCH", `/api/admin/videos/${video.id}`, data),
|
||||
@ -274,7 +275,8 @@ function EditVideoDialog({
|
||||
const response = await apiRequest("POST", `/api/admin/videos/${video.id}/generate-description`, {
|
||||
maxCharacters: 500,
|
||||
includeArtistInfo: true,
|
||||
includeLabelInfo: true
|
||||
includeLabelInfo: true,
|
||||
customInstructions: customInstructions.trim() || undefined
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
@ -351,13 +353,21 @@ function EditVideoDialog({
|
||||
{isGeneratingAI ? "Generating..." : "Generate AI Description"}
|
||||
</Button>
|
||||
</div>
|
||||
<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 className="space-y-2">
|
||||
<Input
|
||||
placeholder="AI instructions (e.g., 'mention band members', 'focus on song history')..."
|
||||
value={customInstructions}
|
||||
onChange={(e) => setCustomInstructions(e.target.value)}
|
||||
className="bg-white/10 border-white/20 text-white placeholder:text-white/50 text-sm"
|
||||
/>
|
||||
<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">
|
||||
{formData.description.length}/500 characters
|
||||
</div>
|
||||
|
||||
@ -28,6 +28,7 @@ export interface DescriptionGenerationOptions {
|
||||
language?: string;
|
||||
includeArtistInfo?: boolean;
|
||||
includeLabelInfo?: boolean;
|
||||
customInstructions?: string;
|
||||
}
|
||||
|
||||
export async function generateVideoDescription(
|
||||
@ -38,7 +39,8 @@ export async function generateVideoDescription(
|
||||
maxCharacters = 500,
|
||||
language = "slovenian",
|
||||
includeArtistInfo = true,
|
||||
includeLabelInfo = true
|
||||
includeLabelInfo = true,
|
||||
customInstructions = ""
|
||||
} = options;
|
||||
|
||||
try {
|
||||
@ -73,6 +75,7 @@ Wenn du keine sicheren Informationen zu einem Punkt hast, lasse ihn WEG. Schreib
|
||||
Die Beschreibung soll maximal ${maxCharacters} Zeichen lang sein.
|
||||
Schreibe in einem freundlichen, informativen Ton.
|
||||
Verwende nicht die Wörter "Video" oder "Aufnahme" - schreibe über die Musik selbst.
|
||||
${customInstructions ? `\nZUSÄTZLICHE ANWEISUNGEN: ${customInstructions}` : ''}
|
||||
Schreibe nur die Beschreibung, keine zusätzlichen Erklärungen.${avoidRepetition}";`
|
||||
|
||||
console.log("Sending request to OpenAI with title:", title); // Debug log
|
||||
|
||||
@ -1087,7 +1087,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
app.post('/api/admin/videos/:id/generate-description', isAdmin, async (req, res) => {
|
||||
try {
|
||||
const videoId = req.params.id;
|
||||
const { maxCharacters = 500, includeArtistInfo = true, includeLabelInfo = true } = req.body;
|
||||
const { maxCharacters = 500, includeArtistInfo = true, includeLabelInfo = true, customInstructions } = req.body;
|
||||
|
||||
console.log("AI description request for video:", videoId); // Debug log
|
||||
|
||||
@ -1103,9 +1103,10 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Generate description using AI
|
||||
const description = await generateVideoDescription(video.title, {
|
||||
maxCharacters,
|
||||
language: "slovenian",
|
||||
language: "german",
|
||||
includeArtistInfo,
|
||||
includeLabelInfo
|
||||
includeLabelInfo,
|
||||
customInstructions
|
||||
});
|
||||
|
||||
console.log("Generated description:", description); // Debug log
|
||||
|
||||
Loading…
Reference in New Issue
Block a user