|
22 | 22 | },
|
23 | 23 | {
|
24 | 24 | "cell_type": "code",
|
25 |
| - "execution_count": 64, |
| 25 | + "execution_count": 1, |
26 | 26 | "id": "e6404ca7-5a5f-4b66-b341-211a394810ed",
|
27 | 27 | "metadata": {},
|
28 | 28 | "outputs": [],
|
|
68 | 68 | },
|
69 | 69 | {
|
70 | 70 | "cell_type": "code",
|
71 |
| - "execution_count": 66, |
| 71 | + "execution_count": null, |
72 | 72 | "id": "9c1c82bb-206e-4023-be95-d79b7ccfb71b",
|
73 | 73 | "metadata": {},
|
74 |
| - "outputs": [ |
75 |
| - { |
76 |
| - "name": "stdout", |
77 |
| - "output_type": "stream", |
78 |
| - "text": [ |
79 |
| - "Converstion id: KN7Fy9TZ00q8eFj41WsE5Q-au\n", |
80 |
| - "CPU times: user 118 ms, sys: 799 µs, total: 119 ms\n", |
81 |
| - "Wall time: 21.6 s\n" |
82 |
| - ] |
83 |
| - } |
84 |
| - ], |
| 74 | + "outputs": [], |
85 | 75 | "source": [
|
86 | 76 | "%%time\n",
|
87 | 77 | "\n",
|
88 | 78 | "# Simple workflow\n",
|
89 | 79 | "start_conversation_url = f\"{base_url}/conversations\"\n",
|
90 |
| - "get_activities_url = f\"{base_url}/conversations/{conversation_id}/activities\"\n", |
91 | 80 | "\n",
|
92 | 81 | "# 1- Start a conversation\n",
|
93 | 82 | "headers = {\"Authorization\": f\"Bearer {direct_line_secret}\"}\n",
|
94 | 83 | "response = requests.post(start_conversation_url, headers=headers)\n",
|
95 | 84 | "conversation_id = response.json()[\"conversationId\"]\n",
|
96 | 85 | "print('Converstion id:', conversation_id)\n",
|
97 | 86 | "\n",
|
| 87 | + "get_activities_url = f\"{base_url}/conversations/{conversation_id}/activities\"\n", |
| 88 | + "\n", |
| 89 | + "\n", |
98 | 90 | "# 2 - Send a message to the bot\n",
|
99 | 91 | "send_message_url = f\"{base_url}/conversations/{conversation_id}/activities\"\n",
|
100 | 92 | "message = {\n",
|
101 | 93 | " \"type\": \"message\",\n",
|
102 | 94 | " \"from\": {\"id\": \"user\"},\n",
|
103 |
| - " \"text\": \"what CLP?\"\n", |
| 95 | + " \"text\": \"what is CLP?\"\n", |
104 | 96 | "}\n",
|
105 | 97 | "\n",
|
106 | 98 | "response = requests.post(send_message_url, headers=headers, json=message)\n",
|
|
258 | 250 | "\n",
|
259 | 251 | "\n",
|
260 | 252 | "# Main function to send a question to the bot and print responses.\n",
|
261 |
| - "async def check_activities_and_send_question(base_url, bot_id, conversation_id, headers, question, timeout=30):\n", |
| 253 | + "async def send_question_and_check_activities(base_url, bot_id, conversation_id, headers, question, timeout=30):\n", |
262 | 254 | " # Send the initial question to the bot.\n",
|
263 | 255 | " await send_message(base_url, conversation_id, headers, question)\n",
|
264 | 256 | " \n",
|
|
392 | 384 | }
|
393 | 385 | ],
|
394 | 386 | "source": [
|
395 |
| - "await check_activities_and_send_question(base_url, bot_id, conversation_id, headers, QUESTION, timeout=timeout)" |
| 387 | + "await send_question_and_check_activities(base_url, bot_id, conversation_id, headers, QUESTION, timeout=timeout)" |
396 | 388 | ]
|
397 | 389 | },
|
398 | 390 | {
|
|
462 | 454 | }
|
463 | 455 | ],
|
464 | 456 | "source": [
|
465 |
| - "await check_activities_and_send_question(base_url, bot_id, conversation_id, headers, FOLLOWUP_QUESTION, timeout=timeout)" |
| 457 | + "await send_question_and_check_activities(base_url, bot_id, conversation_id, headers, FOLLOWUP_QUESTION, timeout=timeout)" |
466 | 458 | ]
|
467 | 459 | },
|
468 | 460 | {
|
|
500 | 492 | "source": [
|
501 | 493 | "# NEXT\n",
|
502 | 494 | "\n",
|
503 |
| - "(Coming Soon) - In our next notebook, we will venture into creating a different type of Backend API, this time utilizing FastAPI and LangServe. This approach will also enable us to incorporate streaming capabilities." |
| 495 | + "In the next notebook, we will venture into creating a different type of Backend API, this time utilizing FastAPI and LangServe. This approach will also enable us to incorporate streaming capabilities." |
504 | 496 | ]
|
505 | 497 | },
|
506 | 498 | {
|
|
0 commit comments