diff --git a/docs/docs/expression_language/why.ipynb b/docs/docs/expression_language/why.ipynb index 7601ce1d5f..ecd8ed5266 100644 --- a/docs/docs/expression_language/why.ipynb +++ b/docs/docs/expression_language/why.ipynb @@ -323,6 +323,58 @@ "```" ] }, + { + "cell_type": "markdown", + "id": "1f282129-99a3-40f4-b67f-2d0718b1bea9", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "## Async Batch\n", + "\n", + "\n", + "\n", + "\n", + "#### Without LCEL\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1933f39d-7bd7-45fa-a6a5-5fb7be8e31ec", + "metadata": {}, + "outputs": [], + "source": [ + "import openai\n", + "\n", + "\n", + "async def abatch_chain(topics: list) -> list:\n", + " coros = map(ainvoke_chain, topics)\n", + " return await asyncio.gather(*coros)\n" + ] + }, + { + "cell_type": "markdown", + "id": "90691048-17ae-479d-83c2-859e33ddf3eb", + "metadata": {}, + "source": [ + "```python\n", + "await abatch_chain([\"ice cream\", \"spaghetti\", \"dumplings\"])\n", + "```\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "#### LCEL\n", + "\n", + "```python\n", + "await chain.abatch([\"ice cream\", \"spaghetti\", \"dumplings\"])\n", + "```" + ] + }, { "cell_type": "markdown", "id": "f6888245-1ebe-4768-a53b-e1fef6a8b379",