{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Creating slides with the Assistants API (GPT-4), and DALL·E-3\n",
"\n",
"This notebook illustrates the use of the new [Assistants API](https://platform.openai.com/docs/assistants/overview) (GPT-4), and DALL·E-3 in crafting informative and visually appealing slides.
\n",
"Creating slides is a pivotal aspect of many jobs, but can be laborious and time-consuming. Additionally, extracting insights from data and articulating them effectively on slides can be challenging.
This cookbook recipe will demonstrate how you can utilize the new Assistants API to faciliate the end to end slide creation process for you without you having to touch Microsoft PowerPoint or Google Slides, saving you valuable time and effort!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 0. Setup"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display, Image\n",
"from openai import OpenAI\n",
"import pandas as pd\n",
"import json\n",
"import io\n",
"from PIL import Image\n",
"import requests\n",
"\n",
"client = OpenAI()\n",
"\n",
"#Lets import some helper functions for assistants from https://cookbook.openai.com/examples/assistants_api_overview_python\n",
"def show_json(obj):\n",
" display(json.loads(obj.model_dump_json()))\n",
"\n",
"def submit_message(assistant_id, thread, user_message,file_ids=None):\n",
" params = {\n",
" 'thread_id': thread.id,\n",
" 'role': 'user',\n",
" 'content': user_message,\n",
" }\n",
" if file_ids:\n",
" params['file_ids']=file_ids\n",
"\n",
" client.beta.threads.messages.create(\n",
" **params\n",
")\n",
" return client.beta.threads.runs.create(\n",
" thread_id=thread.id,\n",
" assistant_id=assistant_id,\n",
")\n",
"\n",
"def get_response(thread):\n",
" return client.beta.threads.messages.list(thread_id=thread.id)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Creating the content"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this recipe, we will be creating a brief fictional presentation for the quarterly financial review of our company, NotReal Corporation. We want to highlight some key trends we are seeing that are affecting the profitability of our company.
Let's say we have the some financial data at our disposal. Let's load in the data, and take a look..."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n", " | Year | \n", "Quarter | \n", "Distribution channel | \n", "Revenue ($M) | \n", "Costs ($M) | \n", "Customer count | \n", "Time | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "2021 | \n", "Q1 | \n", "Online Sales | \n", "1.50 | \n", "1.301953 | \n", "150 | \n", "2021 Q1 | \n", "
1 | \n", "2021 | \n", "Q1 | \n", "Direct Sales | \n", "1.50 | \n", "1.380809 | \n", "151 | \n", "2021 Q1 | \n", "
2 | \n", "2021 | \n", "Q1 | \n", "Retail Partners | \n", "1.50 | \n", "1.348246 | \n", "152 | \n", "2021 Q1 | \n", "
3 | \n", "2021 | \n", "Q2 | \n", "Online Sales | \n", "1.52 | \n", "1.308608 | \n", "152 | \n", "2021 Q2 | \n", "
4 | \n", "2021 | \n", "Q2 | \n", "Direct Sales | \n", "1.52 | \n", "1.413305 | \n", "153 | \n", "2021 Q2 | \n", "