Skip to content

Examples and guides for using the OpenAI API

update authors.yaml and prompt-personality cookbook (#2355)

Kathy Laub8ed4810a1e7
diff --git a/authors.yaml b/authors.yaml
index 34cef30d..7d292e38 100644
--- a/authors.yaml
+++ b/authors.yaml
@@ -560,5 +560,5 @@ annikab-oai:
kathylau-oai:
name: "Kathy Lau"
- website: "https://www.linkedin.com/in/kathy-lau-nyc/"
- avatar: "https://avatars.githubusercontent.com/u/231350694"
\ No newline at end of file
+ website: "https://github.com/kathylau-oai"
+ avatar: "https://avatars.githubusercontent.com/u/247463782"
diff --git a/examples/gpt-5/prompt_personalities.ipynb b/examples/gpt-5/prompt_personalities.ipynb
index 25075bae..eb2d6dac 100644
--- a/examples/gpt-5/prompt_personalities.ipynb
+++ b/examples/gpt-5/prompt_personalities.ipynb
@@ -38,12 +38,13 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 12,
"id": "091b8921",
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import HTML, display, Markdown\n",
+ "import markdown\n",
"from openai import OpenAI\n",
"\n",
"client = OpenAI()"
@@ -65,7 +66,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 13,
"id": "7bd98db9",
"metadata": {},
"outputs": [],
@@ -99,33 +100,31 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"id": "cb6f525d",
"metadata": {},
"outputs": [
{
"data": {
- "text/markdown": [
- "## Announcement: Update to Travel Reimbursement Policy — Per Diem Set at $75\n",
- "\n",
- "Effective immediately, the Company’s travel reimbursement policy will include a **per diem allowance of $75 per day** for eligible business travel.\n",
- "\n",
- "### Key Details\n",
- "- **Per diem rate:** **$75/day**\n",
- "- **Purpose:** Covers standard **meals and incidental expenses (M&IE)** while traveling for business\n",
- "- **Eligibility:** Applies to **approved business travel** that requires overnight stay or otherwise meets the Company’s travel criteria\n",
- "- **Documentation:** \n",
- " - **Per diem claims do not require itemized meal receipts** unless otherwise specified by Finance or a client contract \n",
- " - Travelers must still submit required **travel dates, location, and proof of travel (as applicable)** in the expense report\n",
- "- **Exceptions:** If a **client contract, local regulation, or business unit guideline** requires a different rate or receipt-based reimbursement, those requirements will take precedence.\n",
- "\n",
- "### Action Required\n",
- "Please apply the **$75/day per diem** to all newly submitted expense reports for qualifying travel on or after the effective date.\n",
- "\n",
- "If you would like, I can tailor this announcement to your organization’s standards by adding the effective date, eligible travel definition (e.g., “50+ miles from home office”), and expense system instructions (e.g., Concur)."
+ "text/html": [
+ "<p>Subject: Update to Travel Reimbursement Policy – Per Diem Rate Set to $75</p>\n",
+ "<p>Team,</p>\n",
+ "<p>Effective immediately, the Company’s travel reimbursement policy is updated to include a <strong>standard per diem of $75 per day</strong> for eligible business travel.</p>\n",
+ "<p><strong>Key details</strong>\n",
+ "- <strong>Per diem amount:</strong> $75 per day<br />\n",
+ "- <strong>Purpose:</strong> Covers reasonable <strong>meals and incidental expenses</strong> incurred while traveling for business\n",
+ "- <strong>Eligibility:</strong> Applies to <strong>approved, overnight business travel</strong> (unless otherwise specified by department guidance)\n",
+ "- <strong>Claim method:</strong> Per diem will be reimbursed <strong>in lieu of itemized meal receipts</strong> (receipts may still be required for other reimbursable expenses, per policy)\n",
+ "- <strong>Partial travel days:</strong> For travel days that are not a full day, reimbursement will follow the Company’s <strong>standard proration rules</strong> (if applicable)</p>\n",
+ "<p>Please continue to submit all other travel-related expenses (e.g., airfare, lodging, ground transportation) in accordance with the existing travel and expense policy and approval requirements.</p>\n",
+ "<p>If you have questions about eligibility, proration, or how to submit per diem in the expense system, please contact <strong>[Finance/Travel Desk/HR]</strong> at <strong>[contact info]</strong>.</p>\n",
+ "<p>Thank you,<br />\n",
+ "[Name]<br />\n",
+ "[Title]<br />\n",
+ "[Company]</p>"
],
"text/plain": [
- "<IPython.core.display.Markdown object>"
+ "<IPython.core.display.HTML object>"
]
},
"metadata": {},
@@ -139,7 +138,7 @@
" input=\"Announce a per diem of $75 in company travel reimbursement policy\"\n",
")\n",
"\n",
- "display(Markdown(response.output_text))\n"
+ "display(HTML(markdown.markdown(response.output_text)))"
]
},
{
@@ -198,27 +197,30 @@
"outputs": [
{
"data": {
- "text/markdown": [
- "- Tomatoes (fresh Roma/on-vine) or canned whole/ crushed tomatoes \n",
- "- Yellow onion \n",
- "- Garlic \n",
- "- Carrot (optional, for sweetness) \n",
- "- Celery (optional) \n",
- "- Tomato paste (optional, for richer flavor) \n",
- "- Vegetable or chicken broth (or bouillon) \n",
- "- Olive oil or butter \n",
- "- Salt \n",
- "- Black pepper \n",
- "- Dried basil or fresh basil \n",
- "- Dried oregano or thyme (optional) \n",
- "- Bay leaf (optional) \n",
- "- Sugar or honey (optional, to balance acidity) \n",
- "- Heavy cream, half-and-half, or milk (optional, for creamy soup) \n",
- "- Parmesan (optional, for serving) \n",
- "- Croutons or bread (for serving)"
+ "text/html": [
+ "<ul>\n",
+ "<li>Tomatoes (fresh or canned whole/crushed)</li>\n",
+ "<li>Yellow onion</li>\n",
+ "<li>Garlic</li>\n",
+ "<li>Carrots (optional, for sweetness)</li>\n",
+ "<li>Celery (optional)</li>\n",
+ "<li>Olive oil or butter</li>\n",
+ "<li>Tomato paste (optional, for depth)</li>\n",
+ "<li>Vegetable or chicken broth/stock</li>\n",
+ "<li>Heavy cream or milk (optional, for creamy soup)</li>\n",
+ "<li>Basil (fresh or dried)</li>\n",
+ "<li>Oregano or thyme (optional)</li>\n",
+ "<li>Bay leaf (optional)</li>\n",
+ "<li>Sugar or honey (optional, to balance acidity)</li>\n",
+ "<li>Salt</li>\n",
+ "<li>Black pepper</li>\n",
+ "<li>Red pepper flakes (optional)</li>\n",
+ "<li>Parmesan (optional, for serving)</li>\n",
+ "<li>Croutons or bread/grilled cheese (optional, for serving)</li>\n",
+ "</ul>"
],
"text/plain": [
- "<IPython.core.display.Markdown object>"
+ "<IPython.core.display.HTML object>"
]
},
"metadata": {},
@@ -233,7 +235,7 @@
" \n",
")\n",
"\n",
- "display(Markdown(response.output_text))"
+ "display(HTML(markdown.markdown(response.output_text)))"
]
},
{
@@ -289,22 +291,24 @@
"id": "24af00e9",
"metadata": {},
"source": [
- "Let's use an example where your agent needs to cite the sources. The agent will search the web to find **\"How many US Federal holidays are there in the year 2026?\"** "
+ "Let's use an example where your agent needs to cite the sources. The agent will search the web to find **\"How many US Federal holidays are there in the year 2026?\"** \n",
+ "\n",
+ "**Note:** The use of the `web_search` tool is optional and should be included only if your use case requires searching external information. If your application does not need web access or external lookups, you can omit the `tools=[{\"type\": \"web_search\"}]` argument."
]
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 18,
"id": "79e80e38",
"metadata": {},
"outputs": [
{
"data": {
- "text/markdown": [
- "Per the U.S. Office of Personnel Management (OPM) federal holiday schedule, there are **11 Federal holidays in 2026**. ([piv.opm.gov](https://piv.opm.gov/policy-data-oversight/pay-leave/federal-holidays/))"
+ "text/html": [
+ "<p>Per the U.S. Office of Personnel Management (OPM) federal holidays schedule, there are <strong>11 federal holidays in calendar year 2026</strong>. (<a href=\"https://piv.opm.gov/policy-data-oversight/pay-leave/federal-holidays/?utm_source=openai\">piv.opm.gov</a>)</p>"
],
"text/plain": [
- "<IPython.core.display.Markdown object>"
+ "<IPython.core.display.HTML object>"
]
},
"metadata": {},
@@ -319,7 +323,7 @@
" tools=[{\"type\": \"web_search\"}],\n",
")\n",
"\n",
- "display(Markdown(response.output_text))"
+ "display(HTML(markdown.markdown(response.output_text)))"
]
},
{
@@ -338,7 +342,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 19,
"id": "f4e4b3cb",
"metadata": {},
"outputs": [],
@@ -372,36 +376,31 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 20,
"id": "84d7f080",
"metadata": {},
"outputs": [
{
"data": {
- "text/markdown": [
- "San Francisco in **January** is typically in its **cool, wet-season** pattern: mild temperatures (by most U.S. standards), frequent marine clouds, and periodic rain systems rather than constant drizzle.\n",
- "\n",
- "### Typical conditions (what it usually feels like)\n",
- "- **Temperatures:** generally **cool to mild**\n",
- " - **Daytime highs:** often around the **mid‑50s to low‑60s °F**\n",
- " - **Nighttime lows:** often around the **mid‑40s to low‑50s °F**\n",
- "- **Rain:** **one of the wetter times of year**\n",
- " - Rain often comes in **bursts tied to passing storms** (you can have a few rainy days, then a stretch of dry, clear days).\n",
- "- **Sky & visibility:** a mix of **gray/cloudy days** and **crisp, clear days** after storms.\n",
- "- **Wind & “feels like”:** breezes plus damp air can make it feel **colder than the thermometer suggests**, especially near the water.\n",
- "\n",
- "### What to pack / expect day-to-day\n",
- "- A **light-to-medium jacket** (many locals use a layered setup: T‑shirt + sweater + windproof shell).\n",
- "- **Rain protection**: a compact umbrella or, better in wind, a **hooded rain shell**.\n",
- "- **Comfortable closed shoes** that can handle wet sidewalks.\n",
- "\n",
- "### A very SF-specific note\n",
- "Microclimates still matter in winter: the **Sunset/Richmond (near the ocean)** can feel cooler and grayer, while **downtown/Mission** is often a bit milder.\n",
- "\n",
- "If you tell me **the exact dates** and what neighborhood you’ll be in (or whether this is for a trip), I can also give a more practical “what you’ll likely experience” checklist—or look up the actual forecast."
+ "text/html": [
+ "<p>In San Francisco, <strong>January is typically the heart of the “cool + wet” season</strong>—not frigid by most U.S. standards, but often <strong>damp, breezy, and variable</strong> from day to day.</p>\n",
+ "<h3>Typical January feel</h3>\n",
+ "<ul>\n",
+ "<li><strong>Cool days, chilly nights:</strong> Daytime is usually “light jacket” weather; evenings often feel noticeably colder.</li>\n",
+ "<li><strong>Rain is common (but not constant):</strong> January is one of SF’s wetter months. You’ll often see <strong>showery systems</strong> roll through, with clearer breaks in between.</li>\n",
+ "<li><strong>Wind + marine influence:</strong> Even in winter, the ocean moderates temperatures, and <strong>breezy conditions</strong> can make it feel colder than the thermometer suggests.</li>\n",
+ "<li><strong>Microclimates still matter:</strong> Neighborhood-to-neighborhood differences are real year-round (e.g., <strong>Sunset/Richmond</strong> often feels cooler than <strong>Mission/SOMA</strong>).</li>\n",
+ "</ul>\n",
+ "<h3>What to pack / wear</h3>\n",
+ "<ul>\n",
+ "<li><strong>Layers:</strong> T-shirt + sweater + medium jacket is a reliable combo.</li>\n",
+ "<li><strong>A waterproof outer layer:</strong> More useful than an umbrella on windy days.</li>\n",
+ "<li><strong>Comfortable closed-toe shoes</strong> that can handle wet sidewalks.</li>\n",
+ "</ul>\n",
+ "<p>If you tell me <strong>what you’ll be doing</strong> (walking around all day vs. dinners out, visiting Marin, etc.), I can suggest a more specific packing list.</p>"
],
"text/plain": [
- "<IPython.core.display.Markdown object>"
+ "<IPython.core.display.HTML object>"
]
},
"metadata": {},
@@ -416,7 +415,7 @@
" tools=[{\"type\": \"web_search\"}],\n",
")\n",
"\n",
- "display(Markdown(response.output_text))"
+ "display(HTML(markdown.markdown(response.output_text)))"
]
},
{
@@ -438,9 +437,9 @@
],
"metadata": {
"kernelspec": {
- "display_name": ".venv",
+ "display_name": "openai-cookbook (.venv)",
"language": "python",
- "name": "python3"
+ "name": "openai-cookbook"
},
"language_info": {
"codemirror_mode": {