microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
35.39k stars 5.12k forks source link

Using top level awaits in tutorial notebooks is confusing #3885

Open jackgerrits opened 1 month ago

jackgerrits commented 1 month ago

Jupyter allows top level await which is very convenient - but when we then render these notebooks to a docs page is confusing for users as it is not confusing why there is a top level await when this isn't normally supported in python.

Not sure what the best solution is here but we need to improve/fix this

gziz commented 3 weeks ago

Hi @jackgerrits , I agree and kinda feel the struggle when having to copy paste each code block and wrap the awaits inside an async function.

One proposal could be to have the full code of the notebook inside a dropdown at the bottom of the notebook.

```{dropdown} Full Code
:icon: code
```python
# Here goes the full code

Block of code with a handy copy button!

jackgerrits commented 2 weeks ago

I like it but unfortunately we lose the ability to easily check those codeblocks so they can become out of sync easily. The approach taken in this page feels like a potentially simple solution where we structure things such that running the main is nice and easy when a user does face the error