docs: update cloud how-tos (#747)

This commit is contained in:
Vadym Barda
2024-06-21 14:04:25 -04:00
committed by GitHub
parent f8e7221cae
commit c99b63b9d8
9 changed files with 387 additions and 1759 deletions
+5 -51
View File
@@ -40,57 +40,11 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "4947e9bc-111f-4991-8c41-1041da9bf0ba",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'assistant_id': 'fe096781-5601-53d2-b2f6-0d3403f7e9ca',\n",
" 'graph_id': 'agent',\n",
" 'config': {},\n",
" 'created_at': '2024-05-18T00:19:39.688822+00:00',\n",
" 'updated_at': '2024-05-18T00:19:39.688822+00:00',\n",
" 'metadata': {'created_by': 'system'}}]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# There should always be a default assistant with no configuration\n",
"assistants = await client.assistants.search()\n",
"assistants = [a for a in assistants if not a['config']]\n",
"assistants"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "230c0464-a6e5-420f-9e38-ca514e5634ce",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'assistant_id': 'fe096781-5601-53d2-b2f6-0d3403f7e9ca',\n",
" 'graph_id': 'agent',\n",
" 'config': {},\n",
" 'created_at': '2024-05-18T00:19:39.688822+00:00',\n",
" 'updated_at': '2024-05-18T00:19:39.688822+00:00',\n",
" 'metadata': {'created_by': 'system'}}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"assistant = assistants[0]\n",
"assistant"
"assistant_id = \"agent\""
]
},
{
@@ -139,7 +93,7 @@
"source": [
"input = {\"messages\": [{\"role\": \"human\", \"content\": \"what's the weather in la\"}]}\n",
"thread = await client.threads.create()\n",
"async for chunk in client.runs.stream(thread['thread_id'], assistant['assistant_id'], input=input):\n",
"async for chunk in client.runs.stream(thread['thread_id'], assistant_id, input=input):\n",
" print(f\"Receiving new event of type: {chunk.event}...\")\n",
" print(chunk.data)\n",
" print(\"\\n\\n\")"
@@ -163,7 +117,7 @@
"input = {\"messages\": [{\"role\": \"human\", \"content\": \"what's the weather in la\"}]}\n",
"thread = await client.threads.create()\n",
"final_answer = None\n",
"async for chunk in client.runs.stream(thread['thread_id'], assistant['assistant_id'], input=input):\n",
"async for chunk in client.runs.stream(thread['thread_id'], assistant_id, input=input):\n",
" if chunk.event == \"values\":\n",
" final_answer = chunk.data"
]
@@ -250,7 +204,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.1"
"version": "3.11.9"
}
},
"nbformat": 4,