Skip to content

Commit ffa8b46

Browse files
author
chenchaomin
committed
replace .py file with .ipynb for Jupyter example
1 parent cef3d53 commit ffa8b46

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ print(result.final_output)
4747

4848
(_If running this, ensure you set the `OPENAI_API_KEY` environment variable_)
4949

50-
(_For Jupyter notebook users, see [hello_world_jupyter.py](examples/basic/hello_world_jupyter.py)_)
50+
(_For Jupyter notebook users, see [hello_world_jupyter.ipynb](examples/basic/hello_world_jupyter.ipynb)_)
5151

5252
## Handoffs example
5353

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "8a77ee2e-22f2-409c-837d-b994978b0aa2",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"A function calls self, \n",
14+
"Unraveling layers deep, \n",
15+
"Base case ends the quest. \n",
16+
"\n",
17+
"Infinite loops lurk, \n",
18+
"Mind the base condition well, \n",
19+
"Or it will not work. \n",
20+
"\n",
21+
"Trees and lists unfold, \n",
22+
"Elegant solutions bloom, \n",
23+
"Recursion's art told.\n"
24+
]
25+
}
26+
],
27+
"source": [
28+
"from agents import Agent, Runner\n",
29+
"\n",
30+
"agent = Agent(name=\"Assistant\", instructions=\"You are a helpful assistant\")\n",
31+
"\n",
32+
"# Intended for Jupyter notebooks where there's an existing event loop\n",
33+
"result = await Runner.run(agent, \"Write a haiku about recursion in programming.\") # type: ignore[top-level-await] # noqa: F704\n",
34+
"print(result.final_output)"
35+
]
36+
}
37+
],
38+
"metadata": {
39+
"language_info": {
40+
"name": "python"
41+
}
42+
},
43+
"nbformat": 4,
44+
"nbformat_minor": 5
45+
}

examples/basic/hello_world_jupyter.py

-11
This file was deleted.

0 commit comments

Comments
 (0)