added a Jupyter example to clarify how to use the SDK with an existing event loop
This commit is contained in:
parent
18b10f1371
commit
536d7826d5
2 changed files with 14 additions and 1 deletions
|
|
@ -47,9 +47,11 @@ print(result.final_output)
|
|||
|
||||
(_If running this, ensure you set the `OPENAI_API_KEY` environment variable_)
|
||||
|
||||
(_For Jupyter notebook users, see [hello_world_jupyter.py](examples/basic/hello_world_jupyter.py)_)
|
||||
|
||||
## Handoffs example
|
||||
|
||||
```py
|
||||
```python
|
||||
from agents import Agent, Runner
|
||||
import asyncio
|
||||
|
||||
|
|
|
|||
11
examples/basic/hello_world_jupyter.py
Normal file
11
examples/basic/hello_world_jupyter.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from agents import Agent, Runner
|
||||
|
||||
agent = Agent(name="Assistant", instructions="You are a helpful assistant")
|
||||
|
||||
# Intended for Jupyter notebooks where there's an existing event loop
|
||||
result = await Runner.run(agent, "Write a haiku about recursion in programming.")
|
||||
print(result.final_output)
|
||||
|
||||
# Code within code loops,
|
||||
# Infinite mirrors reflect—
|
||||
# Logic folds on self.
|
||||
Loading…
Reference in a new issue