operations-granite/HuggingFace-Granite-AI-Practice-Agent-Dev
0
1# Client Brief Template Data Mapping2 3## Template Overview4 5The template has **2 slides** with a complex layout using text boxes and tables:6 7### Slide 1: Client Overview8- **Layout**: Title Only9- **Total Shapes**: 34 (1 placeholder, 30 text boxes, 3 tables)10 11### Slide 2: Granite MENA Brief12- **Layout**: Title Only13- **Total Shapes**: 17 (1 placeholder, 15 text boxes, 1 table)14 15---16 17## Data Field Mapping18 19### SLIDE 1: CLIENT OVERVIEW20 21| TextBox/Shape | Label/Heading | Data Source Path | Notes |22|---------------|---------------|------------------|-------|23| Title 1 (Placeholder 0) | "Client Overview" | Static text | Keep as is |24| TextBox 37 | "Context" | `client_overview_tab.client_overview.context` | New field needed? |25| TextBox 4 | "Business Goals and Priorities" | Section header | Static |26| TextBox 11 | Content area | `client_overview_tab.client_overview.business_goals_and_priorities` | Bullet points |27| TextBox 7 | "Current Challenges" | Section header | Static |28| Rectangle 6 | Content container | N/A | Background shape |29| TextBox 18 | "Business Challenges" | `client_overview_tab.challenges.business_challenges` | |30| TextBox 19 | "Technology Challenges" | `client_overview_tab.challenges.technology_challenges` | |31| TextBox 20 | "Process Challenges" | `client_overview_tab.challenges.process_challenges` | |32| TextBox 21 | "KPIs & Success Measures" | `client_overview_tab.challenges.kpis_and_success_measures` | |33| TextBox 10 | "Stakeholder and Influence Map" | Section header | Static |34| Table 2 | Stakeholder data | `client_overview_tab.client_overview.stakeholder_and_influence_map[]` | 4 cols x 4 rows |35| TextBox 13 | "Short term priorities (3-6 months)" | `client_overview_tab.strategic_goals.short_term_priorities` | |36| TextBox 14 | "Long term priorities (6-24 months)" | `client_overview_tab.strategic_goals.long_term_priorities` | |37| TextBox 23 | "Competitive Landscape" | Section header | Static |38| TextBox 25 | "Who are the industry leaders..." | `client_overview_tab.competitive_landscape.industry_leaders_and_benchmarks` | |39| TextBox 27 | "Other Vendors in play..." | `client_overview_tab.competitive_landscape.other_vendors_client_perception` | |40| TextBox 28 | "Budget and Procurement" | Section header | Static |41| TextBox 29 | "Budget Owners:" | `client_overview_tab.budget_and_procurement.budget_owners` | |42| TextBox 30 | "Indicative Budgets:" | `client_overview_tab.budget_and_procurement.indicative_budgets` | |43| TextBox 32 | "Budget Approvers:" | `client_overview_tab.budget_and_procurement.budget_approvers` | |44| TextBox 31 | "Procurement process & notes:" | `client_overview_tab.budget_and_procurement.procurement_process_notes` | |45| TextBox 33 | "Risks & Blockers" | Section header | Static |46| TextBox 34 | "Potential blockers:" | `client_overview_tab.risks_and_blockers.potential_blockers` | |47| TextBox 35 | "Risk factors for the Bid:" | `client_overview_tab.risks_and_blockers.risk_factors_for_bid` | |48| TextBox 36 | "Mitigation Strategy:" | `client_overview_tab.risks_and_blockers.mitigation_strategy` | |49| Table 22 | KPIs data | `client_overview_tab.challenges.kpis_and_success_measures` | 8 rows x 2 cols |50| Table 39 | Context/additional | Unknown | 3 rows x 2 cols |51 52### SLIDE 2: GRANITE MENA BRIEF53 54| TextBox/Shape | Label/Heading | Data Source Path | Notes |55|---------------|---------------|------------------|-------|56| Title 1 (Placeholder 0) | "Granite MENA Brief" | Static | Keep as is |57| Title 1 (TextBox) | "Project Title" | `granite_mena_brief_tab.project_information.project_title` | Large title |58| TextBox 3 | "Summary of the Project" | `granite_mena_brief_tab.project_information.summary_of_project` | |59| TextBox 37 | "How can we add value" | Section header | Static |60| Rectangle: Rounded Corners 38 | Content | Combined from `granite_mena_brief_tab.how_can_we_add_value.*` | Multi-line |61| TextBox 40 | "Quick wins and pilot ideas" | Section header | Static |62| Rectangle: Rounded Corners 41 | Content | `granite_mena_brief_tab.quick_wins_and_pilot_ideas.*` | Multi-line |63| TextBox 43 | "Long term Opportunities..." | Section header | Static |64| Rectangle 42 | Content container | `granite_mena_brief_tab.long_term_opportunities.opportunities` | |65| TextBox 45 | "Differentiators to highlight..." | Section header | Static |66| Rectangle 44 | Content container | `granite_mena_brief_tab.differentiators.key_differentiators` | |67| TextBox 47 | "Notes to craft the Bid win strategy" | Section header | Static |68| TextBox 48 | Detailed win strategy notes | Combined from bid win strategy fields | Multi-line content |69| Table 4 | Project details | Various project fields | 10 rows x 2 cols |70 71---72 73## Implementation Strategy74 75### Approach: Template-Based Generation76 77Instead of creating slides from scratch, we'll:78 791. **Load the template** file802. **Access slides by index** (Slide 1, Slide 2)813. **Find text boxes by name** (e.g., "TextBox 11", "TextBox 18")824. **Replace placeholder text** with actual data835. **Populate tables** with dynamic data846. **Preserve all formatting** from the template85 86### Key Changes from Current Generator87 88| Current Approach | New Template-Based Approach |89|------------------|----------------------------|90| Creates ~20 slides programmatically | Uses 2 pre-designed template slides |91| Each section gets its own slide | All sections fit on 2 comprehensive slides |92| Simple bullet-point lists | Complex layout with tables and text boxes |93| Uniform styling | Template-defined styling preserved |94| Layout #1 (Title and Content) | Layout #5 (Title Only) with custom shapes |95 96### Code Structure Changes97 98```python99def generate_client_brief_pptx(brief_data: Dict[str, Any], client_name: str) -> bytes:100 # OLD: prs = Presentation()101 # NEW: Load template102 template_path = Path(__file__).parent.parent.parent / "client_brief_template.pptx"103 prs = Presentation(template_path)104 105 # Access existing slides instead of creating new ones106 slide1 = prs.slides[0] # Client Overview107 slide2 = prs.slides[1] # Granite MENA Brief108 109 # Find and update text boxes by name110 _populate_slide1_client_overview(slide1, brief_data.get('client_overview_tab', {}))111 _populate_slide2_granite_brief(slide2, brief_data.get('granite_mena_brief_tab', {}))112 113 # Return bytes114 ...115```116 117### Helper Functions Needed118 1191. **`_find_shape_by_name(slide, name: str)`**120 - Search slide shapes for specific text box name121 - Return shape object or None122 1232. **`_update_text_box(shape, text: str)`**124 - Replace text in text box while preserving formatting125 - Handle empty/None values126 1273. **`_populate_table(table_shape, data: List[Dict])`**128 - Fill table rows with data129 - Handle dynamic row counts130 1314. **`_populate_slide1_client_overview(slide, data: Dict)`**132 - Populate all Slide 1 fields133 - Update stakeholder table134 - Fill in all text boxes135 1365. **`_populate_slide2_granite_brief(slide, data: Dict)`**137 - Populate all Slide 2 fields138 - Update project details table139 - Fill in strategy notes140 141---142 143## Special Handling Requirements144 145### 1. Stakeholder Table (Slide 1, Table 2)146- **Structure**: 4 columns x 4 rows147- **Headers**: Name, Role, Influence Level, Notes148- **Data**: Array of stakeholder objects149- **Handle**: Dynamic row count (may need more than 4 rows)150 151### 2. KPIs Table (Slide 1, Table 22)152- **Structure**: 8 rows x 2 columns153- **Headers**: KPI Name, Target/Measure154- **Data**: KPI list from challenges section155- **Handle**: Parse bullet-point text into table format156 157### 3. Project Details Table (Slide 2, Table 4)158- **Structure**: 10 rows x 2 columns (label-value pairs)159- **Data**: Various project information fields160- **Handle**: Map specific fields to specific rows161 162### 4. Rounded Corner Text Boxes163- **Slide 2** has rounded corner rectangles with multi-line content164- Need to preserve shape formatting165- Handle line breaks and bullet points166 167### 5. Empty Fields168- Template has placeholder text like "..."169- Replace with actual data or leave as "TBD" if no data available170- Don't break formatting if field is empty171 172---173 174## Testing Checklist175 176- [ ] Template loads successfully177- [ ] Slide count remains at 2 (no extra slides added)178- [ ] All text boxes found and updated correctly179- [ ] Stakeholder table populated with correct data180- [ ] Tables maintain formatting181- [ ] Empty fields handled gracefully182- [ ] Generated PPTX opens in PowerPoint183- [ ] All formatting preserved from template184- [ ] Logo and colors match template185- [ ] No errors with missing data fields186 187---188 189## Migration Notes190 191### Files to Modify1921. `/hf_space/backend/agent/processors/client_brief_pptx_generator.py`193 - Complete rewrite of generation logic194 - Keep brand colors as fallback195 - Remove old slide creation functions196 - Add new template-based population functions197 198### Backwards Compatibility199- API signature remains the same: `generate_client_brief_pptx(brief_data, client_name) -> bytes`200- Input data structure unchanged201- Output is still PPTX bytes202- Only internal implementation changes203 204### Testing Data205Use existing client briefs from database for testing:206```bash207# Get a sample brief from database208SELECT brief_data FROM client_briefs LIMIT 1;209```210 