Using Haiku as a sub-agent
In this recipe, we'll demonstrate how to analyze Apple's 2023 financial earnings reports using Claude Haiku 5.5 sub-agent models to extract relevant information from earnings release PDFs. We'll then use Claude Opus 5.5 to generate a response to our question and create a graph using matplotlib to accompany its response.
Step 1: Set up the environment
First, let's install the required libraries and set up the Claude API client.
Step 2: Gather our documents and ask a question
For this example, we will be using all Apple's financial statements from the 2023 financial year and asking about the net sales over the year.
Step 3: Download and convert PDFs to images
Next, we'll define functions to download the earnings release PDFs and convert them to base64-encoded PNG images. We have to do this because these PDFs are full of tables that are hard to parse with traditional PDF parsers. It's easier if we just convert them to images and pass the images to Haiku.
The download_pdf function downloads a PDF file from a given URL and saves it to the specified folder. The pdf_to_base64_pngs function converts a PDF to a list of base64-encoded PNG images.
We use ThreadPoolExecutor to download the PDFs concurrently and store the file paths in pdf_paths.
Step 4: Generate a specific prompt for Haiku using Opus
Let's use Opus as an orchestrator and have it write a specific prompt for each Haiku sub-agent based on the user provided question.
You are analyzing a single Apple Inc. earnings document, such as a Form 10-Q, a Form 10-K, or a quarterly earnings press release. Your output will be combined with other agents' extractions from the other quarters of Apple's fiscal year 2023 to answer this question: "How did Apple's net sales change quarter to quarter in the 2023 financial year and what were the key contributors to the changes?" Apple's fiscal year 2023 ran from September 25, 2022 to September 30, 2023: - Q1 FY23 ended December 31, 2022 - Q2 FY23 ended April 1, 2023 - Q3 FY23 ended July 1, 2023 - Q4 FY23 ended September 30, 2023 (usually reported in the Form 10-K or the Q4 press release) Extract only information stated in your document. Do not estimate or use outside knowledge. If something is missing, write "Not reported in this document." **1. Document identification** - Document type (10-Q, 10-K, or press release) and filing or release date. - The fiscal quarter covered and its exact period-end date. - If the document covers the full year (e.g., a 10-K), note this. Extract any Q4-specific figures stated. If only annual and year-to-date figures appear, report them and clearly label them as such. Do not derive Q4 values yourself. **2. Total net sales for the quarter** - Total net sales for the current quarter, with units (e.g., millions of USD). - Total net sales for the same quarter of the prior year. - Dollar change and percentage change, exactly as reported. - Any year-to-date totals, labeled as year-to-date. **3. Net sales by category (current quarter vs. prior-year quarter, with % change)** - iPhone - Mac - iPad - Wearables, Home and Accessories - Services - Total Products vs. total Services, if reported separately **4. Net sales by reportable segment (current quarter vs. prior-year quarter, with % change)** - Americas - Europe - Greater China - Japan - Rest of Asia Pacific **5. Key contributors to changes in net sales** Extract management's stated explanations, quoting or closely paraphrasing the text from MD&A, segment discussion, or press release commentary. Include: - Drivers of increases or decreases for each product category and Services, such as product launches, product mix, demand, pricing, or growth in advertising, cloud, App Store, or payment services. - Drivers for each geographic segment. - Foreign currency impacts, including any quantified effect or constant-currency figures. - Supply chain disruptions, production constraints, or COVID-related effects (e.g., iPhone 14 Pro production issues in China). - Macroeconomic factors, such as inflation, interest rates, or consumer spending. - Comparisons that are difficult because of timing differences (e.g., a 14-week vs. 13-week quarter, or the timing of product launches). - Any other factor management cites as material to net sales performance. **6. Supplementary context (if available)** - Gross margin for Products, Services, and in total, with percentages. - Any forward-looking commentary or guidance about upcoming net sales. - Notable product or service launches during the quarter. - Any sequential (quarter-over-quarter) comparisons the document itself states. **Output format** - Use clear headings matching the sections above. - Present numerical data in tables with the columns: Metric | Current Quarter | Prior-Year Quarter | $ Change | % Change. - Keep all figures exactly as reported, with units and period labels. - Include page or section references for key figures and explanations where possible. - End with a 3–5 sentence summary of the most important net sales drivers for this quarter, based only on the document.
Step 5: Extract information from PDFs
Now, let's define our question and extract information from the PDFs using sub-agent Haiku models. We format the information from each model into a neatly defined set of XML tags.
<info quarter="Q4"># Apple Inc. Earnings Analysis: Q4 FY23 (Three Months Ended September 30, 2023) ## 1. Document Identification **Document Type:** Condensed Consolidated Statements of Operations and Balance Sheets (Unaudited) and Condensed Consolidated Statements of Cash Flows (Unaudited) **Filing/Release Date:** Not explicitly stated in the provided document pages. The document shows financial data as of and for periods ended September 30, 2023 and September 24, 2022. **Fiscal Quarter Covered:** Q4 FY23 (Three Months Ended September 30, 2023) **Period-End Date:** September 30, 2023 **Full-Year Data:** The document also presents twelve-month data ended September 30, 2023 and September 24, 2022, representing the full fiscal year 2023. **Note:** This appears to be extracted from a Form 10-K or earnings release, as it presents both quarterly and full-year financial statements. --- ## 2. Total Net Sales for the Quarter | Metric | Q4 FY23 (Sept 30, 2023) | Q4 FY22 (Sept 24, 2022) | $ Change | % Change | |--------|-------------------------|-------------------------|-----------|-----------| | **Total Net Sales** | $89,498 million | $90,146 million | $(648) million | (0.7%) | **Year-to-Date (Full Fiscal Year 2023):** | Metric | FY 2023 (12 months ended Sept 30, 2023) | FY 2022 (12 months ended Sept 24, 2022) | $ Change | % Change | |--------|------------------------------------------|------------------------------------------|-----------|-----------| | **Total Net Sales** | $383,285 million | $394,328 million | $(11,043) million | (2.8%) | --- ## 3. Net Sales by Category (Current Quarter vs. Prior-Year Quarter) ### Q4 FY23 vs. Q4 FY22 (Three Months Ended September 30, 2023 vs. September 24, 2022) | Product Category | Q4 FY23 | Q4 FY22 | $ Change | % Change | |------------------|---------|---------|-----------|-----------| | **iPhone** | $43,805 million | $42,626 million | $1,179 million | 2.8% | | **Mac** | $7,614 million | $11,508 million | $(3,894) million | (33.8%) | | **iPad** | $6,443 million | $7,174 million | $(731) million | (10.2%) | | **Wearables, Home and Accessories** | $9,322 million | $9,650 million | $(328) million | (3.4%) | | **Services** | $22,314 million | $19,188 million | $3,126 million | 16.3% | | **Total Net Sales** | $89,498 million | $90,146 million | $(648) million | (0.7%) | ### Products vs. Services Breakdown (Q4 FY23 vs. Q4 FY22) | Category | Q4 FY23 | Q4 FY22 | $ Change | % Change | |----------|---------|---------|-----------|-----------| | **Total Products** | $67,184 million | $70,958 million | $(3,774) million | (5.3%) | | **Total Services** | $22,314 million | $19,188 million | $3,126 million | 16.3% | ### Full Fiscal Year 2023 by Category (12 Months Ended Sept 30, 2023 vs. Sept 24, 2022) | Product Category | FY 2023 | FY 2022 | $ Change | % Change | |------------------|---------|---------|-----------|-----------| | **iPhone** | $200,583 million | $205,489 million | $(4,906) million | (2.4%) | | **Mac** | $29,357 million | $40,177 million | $(10,820) million | (26.9%) | | **iPad** | $28,300 million | $29,292 million | $(992) million | (3.4%) | | **Wearables, Home and Accessories** | $39,845 million | $41,241 million | $(1,396) million | (3.4%) | | **Services** | $85,200 million | $78,129 million | $7,071 million | 9.1% | | **Total Net Sales** | $383,285 million | $394,328 million | $(11,043) million | (2.8%) | ### Products vs. Services Breakdown (Full Year FY 2023 vs. FY 2022) | Category | FY 2023 | FY 2022 | $ Change | % Change | |----------|---------|---------|-----------|-----------| | **Total Products** | $298,085 million | $316,199 million | $(18,114) million | (5.7%) | | **Total Services** | $85,200 million | $78,129 million | $7,071 million | 9.1% | --- ## 4. Net Sales by Reportable Segment (Current Quarter vs. Prior-Year Quarter) ### Q4 FY23 vs. Q4 FY22 (Three Months Ended September 30, 2023 vs. September 24, 2022) | Geographic Segment | Q4 FY23 | Q4 FY22 | $ Change | % Change | |--------------------|---------|---------|-----------|-----------| | **Americas** | $40,115 million | $39,808 million | $307 million | 0.8% | | **Europe** | $22,463 million | $22,795 million | $(332) million | (1.5%) | | **Greater China** | $15,084 million | $15,470 million | $(386) million | (2.5%) | | **Japan** | $5,505 million | $5,700 million | $(195) million | (3.4%) | | **Rest of Asia Pacific** | $6,331 million | $6,373 million | $(42) million | (0.7%) | | **Total Net Sales** | $89,498 million | $90,146 million | $(648) million | (0.7%) | ### Full Fiscal Year 2023 by Segment (12 Months Ended Sept 30, 2023 vs. Sept 24, 2022) | Geographic Segment | FY 2023 | FY 2022 | $ Change | % Change | |--------------------|---------|---------|-----------|-----------| | **Americas** | $162,560 million | $169,658 million | $(7,098) million | (4.2%) | | **Europe** | $94,294 million | $95,118 million | $(824) million | (0.9%) | | **Greater China** | $72,559 million | $74,200 million | $(1,641) million | (2.2%) | | **Japan** | $24,257 million | $25,977 million | $(1,720) million | (6.6%) | | **Rest of Asia Pacific** | $29,615 million | $29,375 million | $240 million | 0.8% | | **Total Net Sales** | $383,285 million | $394,328 million | $(11,043) million | (2.8%) | --- ## 5. Key Contributors to Changes in Net Sales **Not reported in this document.** The extracted pages contain only the condensed consolidated financial statements (Statement of Operations, Balance Sheet, and Cash Flows). These pages do not include Management's Discussion and Analysis (MD&A), segment commentary, or management's narrative explanations of the drivers behind the changes in net sales. To obtain the key contributors and drivers for Q4 FY23 and the full fiscal year 2023, the MD&A section of the Form 10-K or the earnings press release would need to be reviewed. --- ## 6. Supplementary Context ### Gross Margin Analysis **Q4 FY23 vs. Q4 FY22 (Three Months</info> <info quarter="Q3"># Apple Inc. Earnings Analysis – Q3 FY2023 ## 1. Document Identification **Document Type:** Condensed Consolidated Statements (10-Q excerpt) **Filing/Release Date:** Not explicitly stated in the provided document excerpt **Fiscal Quarter Covered:** Q3 FY2023 **Period-End Date:** July 1, 2023 **Document Scope:** Quarterly statements (unaudited); also includes nine-month year-to-date comparisons --- ## 2. Total Net Sales for the Quarter | Metric | Q3 FY2023 (Jul 1, 2023) | Q3 FY2022 (Jun 25, 2022) | $ Change | % Change | |--------|------------------------|------------------------|----------|----------| | **Total Net Sales** | $81,797 million | $82,959 million | $(1,162) million | (1.4%) | **Year-to-Date (Nine Months Ended):** | Metric | 9M FY2023 (Jul 1, 2023) | 9M FY2022 (Jun 25, 2022) | $ Change | % Change | |--------|------------------------|------------------------|----------|----------| | **Total Net Sales** | $293,787 million | $304,182 million | $(10,395) million | (3.4%) | **Key Observation:** Q3 FY2023 net sales declined slightly year-over-year, with nine-month sales also down compared to the prior-year period. --- ## 3. Net Sales by Category (Current Quarter vs. Prior-Year Quarter) | Category | Q3 FY2023 (Jul 1, 2023) | Q3 FY2022 (Jun 25, 2022) | $ Change | % Change | |----------|------------------------|------------------------|----------|----------| | **iPhone** | $39,669 million | $40,665 million | $(996) million | (2.4%) | | **Mac** | $6,840 million | $7,382 million | $(542) million | (7.3%) | | **iPad** | $5,791 million | $7,224 million | $(1,433) million | (19.8%) | | **Wearables, Home and Accessories** | $8,284 million | $8,084 million | $200 million | 2.5% | | **Services** | $21,213 million | $19,604 million | $1,609 million | 8.2% | | **Total Products** | $60,584 million | $63,355 million | $(2,771) million | (4.4%) | **Year-to-Date (Nine Months Ended):** | Category | 9M FY2023 (Jul 1, 2023) | 9M FY2022 (Jun 25, 2022) | $ Change | % Change | |----------|------------------------|------------------------|----------|----------| | **iPhone** | $156,778 million | $162,863 million | $(6,085) million | (3.7%) | | **Mac** | $21,743 million | $28,669 million | $(6,926) million | (24.2%) | | **iPad** | $21,857 million | $22,118 million | $(261) million | (1.2%) | | **Wearables, Home and Accessories** | $30,523 million | $31,591 million | $(1,068) million | (3.4%) | | **Services** | $62,886 million | $58,941 million | $3,945 million | 6.7% | | **Total Products** | $230,901 million | $245,241 million | $(14,340) million | (5.9%) | --- ## 4. Net Sales by Reportable Segment (Current Quarter vs. Prior-Year Quarter) | Segment | Q3 FY2023 (Jul 1, 2023) | Q3 FY2022 (Jun 25, 2022) | $ Change | % Change | |---------|------------------------|------------------------|----------|----------| | **Americas** | $35,383 million | $37,472 million | $(2,089) million | (5.6%) | | **Europe** | $20,205 million | $19,287 million | $918 million | 4.8% | | **Greater China** | $15,758 million | $14,604 million | $1,154 million | 7.9% | | **Japan** | $4,821 million | $5,446 million | $(625) million | (11.5%) | | **Rest of Asia Pacific** | $5,630 million | $6,150 million | $(520) million | (8.5%) | | **Total Net Sales** | $81,797 million | $82,959 million | $(1,162) million | (1.4%) | **Year-to-Date (Nine Months Ended):** | Segment | 9M FY2023 (Jul 1, 2023) | 9M FY2022 (Jun 25, 2022) | $ Change | % Change | |---------|------------------------|------------------------|----------|----------| | **Americas** | $122,445 million | $129,850 million | $(7,405) million | (5.7%) | | **Europe** | $71,831 million | $72,323 million | $(492) million | (0.7%) | | **Greater China** | $57,475 million | $58,730 million | $(1,255) million | (2.1%) | | **Japan** | $18,752 million | $20,277 million | $(1,525) million | (7.5%) | | **Rest of Asia Pacific** | $23,284 million | $23,002 million | $282 million | 1.2% | | **Total Net Sales** | $293,787 million | $304,182 million | $(10,395) million | (3.4%) | --- ## 5. Key Contributors to Changes in Net Sales **Not reported in this document.** The provided excerpts contain only the Condensed Consolidated Statements of Operations, Balance Sheets, and Cash Flows. They do not include the Management's Discussion and Analysis (MD&A) section, segment commentary, or press release narrative where management typically explains the drivers of changes in net sales by category and geography. To identify the specific factors contributing to the year-over-year declines in iPhone, Mac, iPad, and the overall product category—as well as the 8.2% growth in Services and the mixed geographic performance—reference to the full Form 10-Q or earnings release commentary would be required. --- ## 6. Supplementary Context ### Gross Margin | Metric | Q3 FY2023 | Q3 FY2022 | 9M FY2023 | 9M FY2022 | |--------|-----------|-----------|----------|-----------| | **Total Gross Margin (%)** | 44.5% | 43.3% | 43.9% | 43.6% | **Calculation:** Gross margin = (Total net sales − Total cost of sales) / Total net sales - Q3 FY2023: ($81,797 − $45,384) / $81,797 = 44.5% - Q3 FY2022: ($82,959 − $47,074) / $82,959 = 43.3% **Forward-Looking Commentary, Product Launches, or Guidance:** **Not reported in this document.** The provided statements do not contain MD&A commentary, forward guidance, or product launch information. --- ## Summary In Q3 FY2023 (ended July 1, 2023), Apple's total net sales declined 1.4% year-over-year to $81,797 million, driven primarily by weakness in Products (down 4.4%), particularly iPad (−19.8%), Mac (−7.3%), and iPhone (−2.4%), which were only partially offset by strong Services growth of 8.2%. Geographically, the Americas and Japan declined significantly (−5.6% and −11.5%, respectively), while Greater China and Europe showed growth (7.9% and 4.8%, respectively). Gross margin expanded to 44.5% from 43.3% in the prior-year quarter. The nine-month year</info> <info quarter="Q2"># Apple Inc. – Q2 FY2023 Earnings Document Analysis ## 1. Document Identification **Document Type:** Form 10-Q (Condensed Consolidated Financial Statements and related disclosures) **Filing Date:** The document is dated as of April 1, 2023 (quarter end) **Fiscal Quarter Covered:** Q2 FY2023, ended April 1, 2023 - Apple's fiscal year 2023 runs from September 25, 2022 to September 30, 2023 - This quarter covers the period from January 1, 2023 (or the end of Q1 FY23 on December 31, 2022) through April 1, 2023 **Full-Year Note:** This document contains only six-month (year-to-date) and quarterly data; it is not a full-year 10-K. Q4 FY2023 figures are not available in this document. --- ## 2. Total Net Sales for the Quarter | Metric | Q2 FY2023 (Apr 1, 2023) | Q2 FY2022 (Mar 26, 2022) | $ Change | % Change | |--------|-------------------------|-------------------------|----------|----------| | **Total Net Sales** | $94,836 million | $97,278 million | $(2,442) million | (2.5%) | **Year-to-Date (Six Months Ended):** | Metric | Six Months Ended Apr 1, 2023 | Six Months Ended Mar 26, 2022 | $ Change | % Change | |--------|------------------------------|------------------------------|----------|----------| | **Total Net Sales** | $211,990 million | $221,223 million | $(9,233) million | (4.2%) | --- ## 3. Net Sales by Category (Current Quarter vs. Prior-Year Quarter) | Category | Q2 FY2023 | Q2 FY2022 | $ Change | % Change | |----------|-----------|-----------|----------|----------| | **iPhone** | $51,334 million | $50,570 million | $764 million | 1.5% | | **Mac** | $7,168 million | $10,435 million | $(3,267) million | (31.3%) | | **iPad** | $6,670 million | $7,646 million | $(976) million | (12.8%) | | **Wearables, Home and Accessories** | $8,757 million | $8,806 million | $(49) million | (0.6%) | | **Services** | $20,907 million | $19,821 million | $1,086 million | 5.5% | | **Total Net Sales** | $94,836 million | $97,278 million | $(2,442) million | (2.5%) | **Products vs. Services Breakdown:** | Category | Q2 FY2023 | Q2 FY2022 | $ Change | % Change | |----------|-----------|-----------|----------|----------| | **Total Products** | $73,929 million | $77,457 million | $(3,528) million | (4.6%) | | **Total Services** | $20,907 million | $19,821 million | $1,086 million | 5.5% | **Year-to-Date (Six Months Ended):** | Category | Six Months Ended Apr 1, 2023 | Six Months Ended Mar 26, 2022 | $ Change | % Change | |----------|------------------------------|------------------------------|----------|----------| | **iPhone** | $117,109 million | $122,198 million | $(5,089) million | (4.2%) | | **Mac** | $14,903 million | $21,287 million | $(6,384) million | (30.0%) | | **iPad** | $16,066 million | $14,894 million | $1,172 million | 7.9% | | **Wearables, Home and Accessories** | $22,239 million | $23,507 million | $(1,268) million | (5.4%) | | **Services** | $41,673 million | $39,337 million | $2,336 million | 5.9% | | **Total Net Sales** | $211,990 million | $221,223 million | $(9,233) million | (4.2%) | --- ## 4. Net Sales by Reportable Segment (Current Quarter vs. Prior-Year Quarter) | Segment | Q2 FY2023 | Q2 FY2022 | $ Change | % Change | |---------|-----------|-----------|----------|----------| | **Americas** | $37,784 million | $40,882 million | $(3,098) million | (7.6%) | | **Europe** | $23,945 million | $23,287 million | $658 million | 2.8% | | **Greater China** | $17,812 million | $18,343 million | $(531) million | (2.9%) | | **Japan** | $7,176 million | $7,724 million | $(548) million | (7.1%) | | **Rest of Asia Pacific** | $8,119 million | $7,042 million | $1,077 million | 15.3% | | **Total Net Sales** | $94,836 million | $97,278 million | $(2,442) million | (2.5%) | **Year-to-Date (Six Months Ended):** | Segment | Six Months Ended Apr 1, 2023 | Six Months Ended Mar 26, 2022 | $ Change | % Change | |---------|------------------------------|------------------------------|----------|----------| | **Americas** | $87,062 million | $92,378 million | $(5,316) million | (5.8%) | | **Europe** | $51,626 million | $53,036 million | $(1,410) million | (2.7%) | | **Greater China** | $41,717 million | $44,126 million | $(2,409) million | (5.5%) | | **Japan** | $13,931 million | $14,831 million | $(900) million | (6.1%) | | **Rest of Asia Pacific** | $17,654 million | $16,852 million | $802 million | 4.8% | | **Total Net Sales** | $211,990 million | $221,223 million | $(9,233) million | (4.2%) | --- ## 5. Key Contributors to Changes in Net Sales **Important Note:** The provided document contains **condensed consolidated financial statements** (balance sheet, income statement, and cash flow statement) but does **not include Management's Discussion and Analysis (MD&A)** section or management commentary that typically explains the drivers of sales changes. Therefore, the specific qualitative factors cited by management are **not available in this document**. Based on the financial data presented: ### Product Category Performance: - **iPhone:** Modest growth of 1.5% in Q2 FY2023 vs. Q2 FY2022 ($51.3B vs. $50.6B), despite overall net sales decline. Year-to-date, iPhone sales declined 4.2% to $117.1B. - **Mac:** Significant decline of 31.3% in Q2 ($7.2B vs. $10.4B) and 30.0% year-to-date ($14.9B vs. $21.3B). This is the largest driver of the overall net sales decline. - **iPad:** Declined 12.8% in Q2 ($6.7B vs. $7.6B) but showed recovery year-to-date with 7.9% growth ($16.1B vs. $14.9B). - **Wearables, Home and Accessories:** Relatively flat in Q2 (down 0.6%) and down 5.4% year-to-date. - **Services:** Positive growth of 5.5% in Q2 ($20.9B vs. $19.8B) and 5.9% year-to-date ($41.7B vs. $39.3B). ### Geographic Segment Performance: - **Americas:** Declined 7.6% in Q2 ($37.8B vs. $40.</info> <info quarter="Q1"># Apple Inc. Earnings Extract – Q1 FY2023 ## 1. Document Identification - **Document type:** Unaudited Condensed Consolidated Statements (quarterly earnings report) - **Filing/release date:** Not explicitly stated in the provided documents; however, the statements are dated for the three months ended December 31, 2022 - **Fiscal quarter covered:** Q1 FY2023 - **Period-end date:** December 31, 2022 - **Prior-year comparison period:** Three months ended December 25, 2021 - **Note:** This document does not cover the full fiscal year. It presents only Q1 FY2023 results and does not include Q4 FY2023 or full-year figures. --- ## 2. Total Net Sales for the Quarter | Metric | Current Quarter (Dec 31, 2022) | Prior-Year Quarter (Dec 25, 2021) | $ Change | % Change | |--------|--------------------------------|-----------------------------------|----------|----------| | **Total net sales** | $117,154 million | $123,945 million | $(6,791) million | (5.5%) | **Source:** Condensed Consolidated Statements of Operations (Unaudited), three months ended December 31, 2022 and December 25, 2021. --- ## 3. Net Sales by Category (Current Quarter vs. Prior-Year Quarter) | Product/Service Category | Current Quarter (Dec 31, 2022) | Prior-Year Quarter (Dec 25, 2021) | $ Change | % Change | |--------------------------|--------------------------------|-----------------------------------|----------|----------| | **iPhone** | $65,775 million | $71,628 million | $(5,853) million | (8.2%) | | **Mac** | $7,735 million | $10,852 million | $(3,117) million | (28.7%) | | **iPad** | $9,396 million | $7,248 million | $2,148 million | 29.6% | | **Wearables, Home and Accessories** | $13,482 million | $14,701 million | $(1,219) million | (8.3%) | | **Services** | $20,766 million | $19,516 million | $1,250 million | 6.4% | | **Total Products** | $96,388 million | $104,429 million | $(8,041) million | (7.7%) | | **Total Services** | $20,766 million | $19,516 million | $1,250 million | 6.4% | | **Total net sales** | $117,154 million | $123,945 million | $(6,791) million | (5.5%) | **Source:** Net sales by category, Condensed Consolidated Statements of Operations (Unaudited). --- ## 4. Net Sales by Reportable Segment (Current Quarter vs. Prior-Year Quarter) | Geographic Segment | Current Quarter (Dec 31, 2022) | Prior-Year Quarter (Dec 25, 2021) | $ Change | % Change | |--------------------|--------------------------------|-----------------------------------|----------|----------| | **Americas** | $49,278 million | $51,496 million | $(2,218) million | (4.3%) | | **Europe** | $27,681 million | $29,749 million | $(2,068) million | (6.9%) | | **Greater China** | $23,905 million | $25,783 million | $(1,878) million | (7.3%) | | **Japan** | $6,755 million | $7,107 million | $(352) million | (5.0%) | | **Rest of Asia Pacific** | $9,535 million | $9,810 million | $(275) million | (2.8%) | | **Total net sales** | $117,154 million | $123,945 million | $(6,791) million | (5.5%) | **Source:** Net sales by reportable segment, Condensed Consolidated Statements of Operations (Unaudited). --- ## 5. Key Contributors to Changes in Net Sales **Not reported in this document.** The provided financial statements contain only the condensed consolidated statements of operations, balance sheet, and cash flows. They do not include management discussion and analysis (MD&A) commentary, segment discussion, or explanations of the drivers behind net sales changes. The statements present the financial data but do not provide qualitative explanations for the year-over-year declines or category-specific performance drivers. --- ## 6. Supplementary Context ### Gross Margin | Margin Category | Current Quarter (Dec 31, 2022) | Prior-Year Quarter (Dec 25, 2021) | |-----------------|--------------------------------|-----------------------------------| | **Total gross margin** | $50,332 million (42.9% of net sales) | $54,243 million (43.8% of net sales) | **Calculation:** Gross margin = Total net sales minus Total cost of sales ($117,154 − $66,822 = $50,332 for current quarter; $123,945 − $69,702 = $54,243 for prior-year quarter). ### Operating Income and Net Income | Metric | Current Quarter (Dec 31, 2022) | Prior-Year Quarter (Dec 25, 2021) | |--------|--------------------------------|-----------------------------------| | **Operating income** | $36,016 million | $41,488 million | | **Net income** | $29,998 million | $34,630 million | | **Diluted EPS** | $1.88 | $2.10 | **Source:** Condensed Consolidated Statements of Operations (Unaudited). ### Notable Observations from Financial Statements - **Earnings per share:** Diluted EPS declined from $2.10 in the prior-year quarter to $1.88 in the current quarter, a decrease of $0.22 or 10.5%. - **Share count:** Diluted shares outstanding decreased from 16,519,291 thousand to 15,955,718 thousand, reflecting share repurchases. - **No forward-looking guidance or commentary** is provided in the financial statements presented. - **No product launches or strategic initiatives** are mentioned in these financial statement pages. --- ## Summary Apple's Q1 FY2023 (ended December 31, 2022) total net sales declined 5.5% year-over-year to $117.2 billion, driven primarily by declines in iPhone (down 8.2%) and Mac (down 28.7%), partially offset by growth in iPad (up 29.6%) and Services (up 6.4%). All five geographic segments experienced sales declines, with Europe and Greater China showing the largest percentage drops at 6.9% and 7.3%, respectively. The financial statements alone do not provide management's explanations for these changes; such commentary would be found in accompanying MD&A sections not included in this document extract.</info>
We extract information from the PDFs concurrently using sub-agent models and combine the extracted information. We then prepare the messages for the powerful model, including the question and the extracted information, and ask it to generate a response and matplotlib code.
Step 6: Pass the information to Opus to generate a response
Now that we have fetched the information from each PDF using the sub-agents, let's call Opus to actually answer the question and write code to create a graph to accompany the answer.
Generated Response: # Apple's Quarter-to-Quarter Net Sales Changes in Fiscal 2023 ## Summary Apple's net sales fell for two quarters in a row and then recovered partly in Q4: | Quarter (period end) | Net Sales | QoQ $ Change | QoQ % Change | YoY % Change | |---|---|---|---|---| | Q1 FY23 (Dec 31, 2022) | $117,154M | n/a | n/a | (5.5%) | | Q2 FY23 (Apr 1, 2023) | $94,836M | $(22,318)M | (19.1%) | (2.5%) | | Q3 FY23 (Jul 1, 2023) | $81,797M | $(13,039)M | (13.7%) | (1.4%) | | Q4 FY23 (Sep 30, 2023) | $89,498M | +$7,701M | +9.4% | (0.7%) | | **FY23 Total** | **$383,285M** | | | **(2.8%)** | The four quarters add up exactly to the reported full-year total of $383,285M. **Key takeaways:** - **Seasonality drives the pattern.** Q1 is the holiday quarter and the peak. Sales then fell through Q3 and rebounded in Q4. - **Year-over-year declines narrowed every quarter**, from −5.5% to −2.5% to −1.4% to −0.7%. Even as the business shrank versus FY22, the trend was improving. - **Q1 had an extra week.** Based on the period dates (Sept 25 to Dec 31, 2022), Q1 FY23 covered about 14 weeks versus 13 in the other quarters. Q1 sales still declined 5.5% year over year despite this. > **Important caveat:** All four source documents say management's explanations (MD&A / press release commentary) are **not included**. The "contributors" below are therefore derived from the reported category and segment figures, not from management's stated reasons. --- ## Contributors by Product Category ($ millions) | Category | Q1 | Q2 | Q3 | Q4 | Q1→Q2 | Q2→Q3 | Q3→Q4 | |---|---|---|---|---|---|---|---| | iPhone | 65,775 | 51,334 | 39,669 | 43,805 | (14,441) / −22.0% | (11,665) / −22.7% | +4,136 / +10.4% | | Mac | 7,735 | 7,168 | 6,840 | 7,614 | (567) / −7.3% | (328) / −4.6% | +774 / +11.3% | | iPad | 9,396 | 6,670 | 5,791 | 6,443 | (2,726) / −29.0% | (879) / −13.2% | +652 / +
Step 7: Extract response and execute Matplotlib code
Finally, let's extract the matplotlib code from the generated response and execute it to visualize the revenue growth trend.
We define the extract_code_and_response function to extract the matplotlib code and non-code response from the generated response. We print the non-code response and execute the matplotlib code if it is found.
Note that it is not good practice to use exec on model-written code outside of a sandbox but for the purposes of this demo we are doing it :)
# Apple's Quarter-to-Quarter Net Sales Changes in Fiscal 2023 ## Summary Apple's net sales fell for two quarters in a row and then recovered partly in Q4: | Quarter (period end) | Net Sales | QoQ $ Change | QoQ % Change | YoY % Change | |---|---|---|---|---| | Q1 FY23 (Dec 31, 2022) | $117,154M | n/a | n/a | (5.5%) | | Q2 FY23 (Apr 1, 2023) | $94,836M | $(22,318)M | (19.1%) | (2.5%) | | Q3 FY23 (Jul 1, 2023) | $81,797M | $(13,039)M | (13.7%) | (1.4%) | | Q4 FY23 (Sep 30, 2023) | $89,498M | +$7,701M | +9.4% | (0.7%) | | **FY23 Total** | **$383,285M** | | | **(2.8%)** | The four quarters add up exactly to the reported full-year total of $383,285M. **Key takeaways:** - **Seasonality drives the pattern.** Q1 is the holiday quarter and the peak. Sales then fell through Q3 and rebounded in Q4. - **Year-over-year declines narrowed every quarter**, from −5.5% to −2.5% to −1.4% to −0.7%. Even as the business shrank versus FY22, the trend was improving. - **Q1 had an extra week.** Based on the period dates (Sept 25 to Dec 31, 2022), Q1 FY23 covered about 14 weeks versus 13 in the other quarters. Q1 sales still declined 5.5% year over year despite this. > **Important caveat:** All four source documents say management's explanations (MD&A / press release commentary) are **not included**. The "contributors" below are therefore derived from the reported category and segment figures, not from management's stated reasons. --- ## Contributors by Product Category ($ millions) | Category | Q1 | Q2 | Q3 | Q4 | Q1→Q2 | Q2→Q3 | Q3→Q4 | |---|---|---|---|---|---|---|---| | iPhone | 65,775 | 51,334 | 39,669 | 43,805 | (14,441) / −22.0% | (11,665) / −22.7% | +4,136 / +10.4% | | Mac | 7,735 | 7,168 | 6,840 | 7,614 | (567) / −7.3% | (328) / −4.6% | +774 / +11.3% | | iPad | 9,396 | 6,670 | 5,791 | 6,443 | (2,726) / −29.0% | (879) / −13.2% | +652 / + No matplotlib code found in the response.