Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the file on how run the handoffs (with a new example) in jupyter notebook #165

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def main():
if __name__ == "__main__":
asyncio.run(main())
```

(_For Jupyter notebook users, see [handoff_jupyter.py](examples/basic/handoff_jupyter.py)_)
## Functions example

```python
Expand Down
23 changes: 23 additions & 0 deletions examples/basic/handoff_jupyter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from agents import Agent, Runner
import asyncio # The asyncio library in Python is used for writing concurrent code using the async/await syntax

coding_agent =Agent(name="Coding Assistant",
instructions="You are a helpful coding assistant",
handoff_description="Specialised agent for coding tasks")

debugging_agent = Agent(name="Debugging Assistant",
instructions="You are a helpful debugging assistant",
handoff_description="Specialised agent for debugging tasks")

triage_agent = Agent(name="Triage Agent",
instructions="Hand off to the respective agent based on the request",
handoffs=[coding_agent,debugging_agent],
handoff_description="Specialised agent for the delication of tasks")

# Main function
async def main():
result = await Runner.run(triage_agent, "Write a function to calculate the factorial of a number.") # type: ignore[top-level-await] # noqa: F704
print(result.final_output)

if __name__ == "__main__":
await main()