Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 67 additions & 9 deletions notebooks/simplest_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "dced13ed",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"We are up and running!\n"
]
}
],
"source": [
"import dotenv\n",
"import os\n",
Expand Down Expand Up @@ -44,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "afcbf0e1",
"metadata": {},
"outputs": [],
Expand All @@ -63,11 +71,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "5e542d69",
"metadata": {},
"outputs": [],
"source": []
"source": [
"nutrition_agent = Agent(\n",
" name=\"Nutritio Assistant\",\n",
" instructions=\"\"\"\n",
" You are a helpful assistant giving out nutrition advice.\n",
" You give concise answers\n",
" \"\"\"\n",
")"
]
},
{
"cell_type": "markdown",
Expand All @@ -79,10 +95,38 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "1ede6dc3",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RunResult:\n",
"- Last agent: Agent(name=\"Nutritio Assistant\", ...)\n",
"- Final output (str):\n",
" Bananas are very healthy as part of a balanced diet.\n",
" \n",
" Key points:\n",
" - Nutrients: potassium (good for blood pressure), vitamin C, vitamin B6, fiber.\n",
" - Energy: about 90 calories per medium; natural sugars provide quick energy.\n",
" - Benefits: supports heart health, digestion, and satiety.\n",
" \n",
" Notes:\n",
" - Not a complete meal (low in protein/fat); pair with protein/fiber-containing foods.\n",
" - Ripeness changes sugar: underripe has more resistant starch; ripe is sweeter.\n",
" - Kidney disease or very high potassium issues: use caution and check with a clinician.\n",
" \n",
" Simple serving ideas: with yogurt, on cereal, in smoothies, or as a snack.\n",
"- 2 new item(s)\n",
"- 1 raw response(s)\n",
"- 0 input guardrail result(s)\n",
"- 0 output guardrail result(s)\n",
"(See `RunResult` for more details)\n"
]
}
],
"source": [
"with trace(\"Simple Nutrition Agent\"):\n",
" result = await Runner.run(nutrition_agent, \"How healthy are bananas?\")\n",
Expand All @@ -100,10 +144,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "fa70122b",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Bananas are a healthy, convenient fruit. Quick notes:\n",
"\n",
"- Nutrients: potassium, vitamin B6, vitamin C, fiber.\n",
"- Benefits: supports heart health, digestion, and energy; naturally sweet with a low fat profile.\n",
"- Considerations: contain sugars and carbs; portion size matters for diabetes or calorie goals (1 medium banana ≈ 105 kcal).\n",
"- Ripeness: greener = more resistant starch (lower GI); riper = sweeter, higher sugar.\n",
"- Overall: great as part of a balanced diet; pair with protein or fats for slower sugar absorption."
]
}
],
"source": [
"response_stream = Runner.run_streamed(nutrition_agent, \"How healthy are bananas?\")\n",
"\n",
Expand Down