add snippet for max concurrency (#9892)

This commit is contained in:
Harrison Chase 2023-08-31 16:52:28 -07:00 committed by GitHub
parent 566ce06f4a
commit ad9e242a7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,7 +62,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 3,
"id": "d1850a1f", "id": "d1850a1f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -72,7 +72,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 4,
"id": "56d0669f", "id": "56d0669f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -170,6 +170,36 @@
"chain.batch([{\"topic\": \"bears\"}, {\"topic\": \"cats\"}])" "chain.batch([{\"topic\": \"bears\"}, {\"topic\": \"cats\"}])"
] ]
}, },
{
"cell_type": "markdown",
"id": "2434ab15",
"metadata": {},
"source": [
"You can set the number of concurrent requests by using the `max_concurrency` parameter"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a08522f6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[AIMessage(content=\"Why don't bears wear shoes?\\n\\nBecause they have bear feet!\", additional_kwargs={}, example=False),\n",
" AIMessage(content=\"Why don't cats play poker in the wild?\\n\\nToo many cheetahs!\", additional_kwargs={}, example=False)]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"chain.batch([{\"topic\": \"bears\"}, {\"topic\": \"cats\"}], config={\"max_concurrency\": 5})"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "b960cbfe", "id": "b960cbfe",