doc: nested loop code for offline engine (#5244)

This commit is contained in:
mlmz
2025-04-11 16:36:30 +08:00
committed by GitHub
parent e53a0b3d5b
commit 4d2e305149

View File

@@ -22,6 +22,20 @@
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Nest Asyncio\n",
"Note that if you want to use **Offline Engine** in ipython or some other nested loop code, you need to add the following code:\n",
"```python\n",
"import nest_asyncio\n",
"\n",
"nest_asyncio.apply()\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
@@ -63,6 +77,10 @@
"\n",
"if is_in_ci():\n",
" import patch\n",
"else:\n",
" import nest_asyncio\n",
"\n",
" nest_asyncio.apply()\n",
"\n",
"\n",
"llm = sgl.Engine(model_path=\"meta-llama/Meta-Llama-3.1-8B-Instruct\")"