|
|
@ -323,6 +323,58 @@
|
|
|
|
"```"
|
|
|
|
"```"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"cell_type": "markdown",
|
|
|
|
|
|
|
|
"id": "1f282129-99a3-40f4-b67f-2d0718b1bea9",
|
|
|
|
|
|
|
|
"metadata": {},
|
|
|
|
|
|
|
|
"source": [
|
|
|
|
|
|
|
|
"</Column>\n",
|
|
|
|
|
|
|
|
"</ColumnContainer>\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"## Async Batch\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"<ColumnContainer>\n",
|
|
|
|
|
|
|
|
"<Column>\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",
|
|
|
|
|
|
|
|
"</Column>\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"<Column>\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"#### LCEL\n",
|
|
|
|
|
|
|
|
"\n",
|
|
|
|
|
|
|
|
"```python\n",
|
|
|
|
|
|
|
|
"await chain.abatch([\"ice cream\", \"spaghetti\", \"dumplings\"])\n",
|
|
|
|
|
|
|
|
"```"
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"id": "f6888245-1ebe-4768-a53b-e1fef6a8b379",
|
|
|
|
"id": "f6888245-1ebe-4768-a53b-e1fef6a8b379",
|
|
|
|