Skip to content

Commit 7b81226

Browse files
authored
Merge pull request #113 from openai/examples/jupyter
Adding Jupyter notebook example
2 parents 1670d40 + 26f9cb4 commit 7b81226

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ 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)_)
51+
5052
## Handoffs example
5153

52-
```py
54+
```python
5355
from agents import Agent, Runner
5456
import asyncio
5557

examples/basic/hello_world_jupyter.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from agents import Agent, Runner
2+
3+
agent = Agent(name="Assistant", instructions="You are a helpful assistant")
4+
5+
# Intended for Jupyter notebooks where there's an existing event loop
6+
result = await Runner.run(agent, "Write a haiku about recursion in programming.") # type: ignore[top-level-await] # noqa: F704
7+
print(result.final_output)
8+
9+
# Code within code loops,
10+
# Infinite mirrors reflect—
11+
# Logic folds on self.

0 commit comments

Comments
 (0)