From c14a4aa852ab5da110740dae674bc98aaf9a8ca4 Mon Sep 17 00:00:00 2001
From: Siraj R Aizlewood <siraj@aurelio.ai>
Date: Mon, 5 Feb 2024 16:02:25 +0400
Subject: [PATCH] Notebook 07 Now Uses print(Conversation)

Rather than Conversation.print_topics().

Prints in nice colours.
---
 docs/07-route-conversations-by-topic.ipynb | 56 +++++++++-------------
 1 file changed, 22 insertions(+), 34 deletions(-)

diff --git a/docs/07-route-conversations-by-topic.ipynb b/docs/07-route-conversations-by-topic.ipynb
index 89b4a174..cf876353 100644
--- a/docs/07-route-conversations-by-topic.ipynb
+++ b/docs/07-route-conversations-by-topic.ipynb
@@ -88,7 +88,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -115,22 +115,20 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "All Topics:\n",
-      "Topic 2: - user: Hi, there, please can you confirm your full name\n",
-      "Topic 2: - user: Hi, my name is John Doe.\n",
-      "Topic 3: - bot: Okay, how can I help you today?\n",
-      "Topic 4: - user: My computer keeps crashing\n",
-      "Topic 4: - bot: Okay, is our software running when the computer crashes.\n",
-      "Topic 4: - user: Yeah, v.3.11.2 is running when it crashes.\n",
-      "\n",
-      "\n"
+      "No unclustered messages to process.\n",
+      "\u001b[31muser: Hi, there, please can you confirm your full name\u001b[0m\n",
+      "\u001b[31muser: Hi, my name is John Doe.\u001b[0m\n",
+      "\u001b[32mbot: Okay, how can I help you today?\u001b[0m\n",
+      "\u001b[33muser: My computer keeps crashing\u001b[0m\n",
+      "\u001b[33mbot: Okay, is our software running when the computer crashes.\u001b[0m\n",
+      "\u001b[33muser: Yeah, v.3.11.2 is running when it crashes.\u001b[0m\n"
      ]
     }
    ],
@@ -144,10 +142,7 @@
     "all_topics, new_topics = conversation.split_by_topic()\n",
     "\n",
     "# Display all topics\n",
-    "print(\"All Topics:\")\n",
-    "for i, (topic_id, doc) in enumerate(all_topics):\n",
-    "    print(f\"Topic {topic_id + 1}: - {doc}\")\n",
-    "print(\"\\n\")"
+    "print(conversation)"
    ]
   },
   {
@@ -190,7 +185,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -207,25 +202,22 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "All Topics:\n",
-      "Topic 2: - user: Hi, there, please can you confirm your full name\n",
-      "Topic 2: - user: Hi, my name is John Doe.\n",
-      "Topic 3: - bot: Okay, how can I help you today?\n",
-      "Topic 4: - user: My computer keeps crashing\n",
-      "Topic 4: - bot: Okay, is our software running when the computer crashes.\n",
-      "Topic 4: - user: Yeah, v.3.11.2 is running when it crashes.\n",
-      "Topic 4: - user: What do the system logs say, right before the crash?\n",
-      "Topic 5: - user: I'll check soon, but first let's talk refund.\n",
-      "Topic 5: - bot: Okay let me sort out a refund.\n",
-      "\n",
-      "\n"
+      "\u001b[31muser: Hi, there, please can you confirm your full name\u001b[0m\n",
+      "\u001b[31muser: Hi, my name is John Doe.\u001b[0m\n",
+      "\u001b[32mbot: Okay, how can I help you today?\u001b[0m\n",
+      "\u001b[33muser: My computer keeps crashing\u001b[0m\n",
+      "\u001b[33mbot: Okay, is our software running when the computer crashes.\u001b[0m\n",
+      "\u001b[33muser: Yeah, v.3.11.2 is running when it crashes.\u001b[0m\n",
+      "\u001b[33muser: What do the system logs say, right before the crash?\u001b[0m\n",
+      "\u001b[34muser: I'll check soon, but first let's talk refund.\u001b[0m\n",
+      "\u001b[34mbot: Okay let me sort out a refund.\u001b[0m\n"
      ]
     }
    ],
@@ -238,11 +230,7 @@
     "\n",
     "all_topics, new_topics = conversation.split_by_topic()\n",
     "\n",
-    "# Display all topics\n",
-    "print(\"All Topics:\")\n",
-    "for i, (topic_id, doc) in enumerate(all_topics):\n",
-    "    print(f\"Topic {topic_id + 1}: - {doc}\")\n",
-    "print(\"\\n\")"
+    "print(conversation)"
    ]
   },
   {
-- 
GitLab