You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add dynamic clarifying questions for incomplete creative briefs
- Updated orchestrator.parse_brief() to detect missing critical fields and return clarifying questions
- Modified /api/brief/parse endpoint to return requires_clarification flag
- Updated frontend types and App.tsx to display clarifying questions
- Agent now asks targeted questions based on what's actually missing from the brief
- Prevents hallucination by requiring user input for missing information
- If all critical fields are provided: (brief, None)
568
+
- If critical fields are missing: (partial_brief, clarifying_questions_string)
509
569
"""
510
570
ifnotself._initialized:
511
571
self.initialize()
512
572
513
573
planning_agent=self._agents["planning"]
514
574
515
-
parse_prompt=f"""
516
-
Parse the following creative brief into the structured JSON format:
575
+
# First, analyze the brief and check for missing critical fields
576
+
analysis_prompt=f"""
577
+
Analyze this creative brief request and determine if all critical information is provided.
517
578
579
+
**User's Request:**
518
580
{brief_text}
519
581
520
-
Return ONLY a valid JSON object with these fields:
521
-
- overview
522
-
- objectives
523
-
- target_audience
524
-
- key_message
525
-
- tone_and_style
526
-
- deliverable
527
-
- timelines
528
-
- visual_guidelines
529
-
- cta
582
+
**Critical Fields Required:**
583
+
1. objectives - What is the campaign trying to achieve?
584
+
2. target_audience - Who is the intended audience?
585
+
3. key_message - What is the core message or value proposition?
586
+
4. deliverable - What content format is needed (e.g., email, social post, ad)?
587
+
5. tone_and_style - What is the desired tone (professional, casual, playful)?
588
+
589
+
**Your Task:**
590
+
1. Extract any information that IS explicitly provided
591
+
2. Identify which critical fields are MISSING or unclear
592
+
3. Return a JSON response in this EXACT format:
593
+
594
+
```json
595
+
{{
596
+
"status": "complete" or "incomplete",
597
+
"extracted_fields": {{
598
+
"overview": "...",
599
+
"objectives": "...",
600
+
"target_audience": "...",
601
+
"key_message": "...",
602
+
"tone_and_style": "...",
603
+
"deliverable": "...",
604
+
"timelines": "...",
605
+
"visual_guidelines": "...",
606
+
"cta": "..."
607
+
}},
608
+
"missing_fields": ["field1", "field2"],
609
+
"clarifying_message": "If incomplete, a friendly message acknowledging what was provided and asking specific questions about what's missing. Reference the user's actual input. If complete, leave empty."
610
+
}}
611
+
```
612
+
613
+
**Rules:**
614
+
- Set status to "complete" only if objectives, target_audience, key_message, deliverable, AND tone_and_style are all clearly specified
615
+
- For extracted_fields, use empty string "" for any field not mentioned
616
+
- Do NOT invent or assume information that wasn't explicitly stated
617
+
- Make clarifying questions specific to the user's context (reference their product/campaign)
530
618
"""
531
619
532
-
# Use the agent's run method (async in Agent Framework)
content: "I've parsed your creative brief. Please review the details below and let me know if you'd like to make any changes. You can say things like \"change the target audience to...\" or \"add a call to action...\". When everything looks good, click **Confirm Brief** to proceed.",
// Set partial brief for display but show clarifying questions
297
+
setPendingBrief(parsed.brief);
298
+
setGenerationStatus('');
299
+
300
+
constassistantMessage: ChatMessage={
301
+
id: uuidv4(),
302
+
role: 'assistant',
303
+
content: parsed.clarifying_questions,
304
+
agent: 'PlanningAgent',
305
+
timestamp: newDate().toISOString(),
306
+
};
307
+
setMessages(prev=>[...prev,assistantMessage]);
308
+
}else{
309
+
// Brief is complete, show for confirmation
310
+
setPendingBrief(parsed.brief);
311
+
setGenerationStatus('');
312
+
313
+
constassistantMessage: ChatMessage={
314
+
id: uuidv4(),
315
+
role: 'assistant',
316
+
content: "I've parsed your creative brief. Please review the details below and let me know if you'd like to make any changes. You can say things like \"change the target audience to...\" or \"add a call to action...\". When everything looks good, click **Confirm Brief** to proceed.",
0 commit comments