From 0424843417d56f8bed392f6fb45b569944cdf0a9 Mon Sep 17 00:00:00 2001 From: Shuvojit Das Date: Tue, 8 Oct 2024 23:09:49 +0530 Subject: [PATCH] Modified the import to use openai and set the API key using openai.api_key (#611) The openai library does not have a Client class that can be imported directly. Instead, we can use openai.api_key for authentication and the module's built-in methods to interact with the API. Set the API key using openai.api_key. In the RecSum-experiments.ipynb file I have converted user_input to lowercase using input("You: ").lower() before the comparison. This ensures that both "bye" and "Bye" (or any variation like "BYE") are treated the same, making the condition work as intended. PR #594, accidentally got closed. @creatorrr I removed the .DS_Store file that I checked in accidentally. Co-authored-by: Diwank Singh Tomer --- agents-api/notebooks/01-revise-entities.ipynb | 156 ++++-- agents-api/notebooks/02-trim-messages.ipynb | 107 +++- agents-api/notebooks/03-summarise.ipynb | 492 +++++++++++------- agents-api/notebooks/RecSum-experiments.ipynb | 232 +++++---- 4 files changed, 597 insertions(+), 390 deletions(-) diff --git a/agents-api/notebooks/01-revise-entities.ipynb b/agents-api/notebooks/01-revise-entities.ipynb index 00667cb82..27b2e1f0d 100644 --- a/agents-api/notebooks/01-revise-entities.ipynb +++ b/agents-api/notebooks/01-revise-entities.ipynb @@ -2,16 +2,64 @@ "cells": [ { "cell_type": "code", - "execution_count": 6, + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.51.0)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.6.0)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.27.2)\n", + "Requirement already satisfied: jiter<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.5.0)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (2.9.2)\n", + "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n", + "Requirement already satisfied: tqdm>4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.66.5)\n", + "Requirement already satisfied: typing-extensions<5,>=4.11 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.2)\n", + "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n", + "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n", + "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.23.4)\n" + ] + } + ], + "source": [ + "! pip install openai" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.1)\n" + ] + } + ], + "source": [ + "! pip install python-dotenv" + ] + }, + { + "cell_type": "code", + "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "True" + "False" ] }, - "execution_count": 6, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -35,18 +83,22 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "from openai import Client\n", + "import openai\n", + "from openai import OpenAI\n", + "\n", + "api_key = \"YOUR_OPENAI_API_KEY\"\n", "\n", - "client = Client()" + "openai.api_key = api_key\n", + "client = OpenAI(api_key=api_key)" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -69,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -89,7 +141,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -106,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -290,7 +342,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -314,7 +366,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -323,7 +375,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -339,7 +391,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -348,7 +400,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -365,7 +417,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -381,7 +433,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -460,7 +512,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -468,44 +520,37 @@ "output_type": "stream", "text": [ "Starting CoT generation\n", - "{'content': 'Planning step by step:\\n'\n", + "{'content': 'To add context for future entries, we should outline the main '\n", + " 'entities in the session. These entities are the main people, '\n", + " 'places, or things that are most relevant to the conversation.\\n'\n", " '\\n'\n", - " '1. Identify key entities such as characters, games, and '\n", - " 'technology mentioned in the conversation.\\n'\n", - " '2. Provide context for each entity, explaining its relevance to '\n", - " 'the conversation and any additional useful information.\\n'\n", - " '3. Ensure the entities and their descriptions encapsulate the '\n", - " 'essence of the conversation for future reference or follow-up '\n", - " 'discussions.\\n'\n", - " '\\n'\n", - " 'Entities will be identified and described based on the '\n", - " \"conversation's content and flow. This will include the games \"\n", - " 'discussed, characters within those games, and any technology '\n", - " 'issues mentioned.',\n", + " 'Entities:\\n'\n", + " '1. User (The participant initiating the conversation, interested '\n", + " 'in video games and experiencing technical issues).\\n'\n", + " '2. Assistant (Engages in conversation about video games and '\n", + " 'offers technical advice).\\n'\n", + " '3. Red Dead Redemption 2 (Video game discussed, specifically the '\n", + " '\"Blood Feuds, Ancient and Modern\" mission and the character '\n", + " 'development of Arthur and Dutch).\\n'\n", + " '4. Helldivers 2 (Another video game discussed, focusing on '\n", + " 'gameplay, strategy, and specific in-game items like the laser '\n", + " 'cannon and guard dog).\\n'\n", + " '5. Nvidia (Referenced in relation to driver issues, particularly '\n", + " 'in the context of compatibility with Linux operating systems).',\n", " 'role': 'assistant'}\n", "End CoT generation\n", "Starting chatml generation\n", "End chatml generation\n", - "{'content': '- **User**: Engages in discussions about video games and faces '\n", + "{'content': '- User: Engages in discussions about video games and experiences '\n", " 'technical issues with Nvidia drivers on Linux.\\n'\n", - " '- **Assistant**: Provides conversation on video games, offers '\n", - " 'suggestions on game strategies, and gives technical advice '\n", - " 'regarding Nvidia drivers.\\n'\n", - " '- **Red Dead Redemption 2 (RDR2)**: A video game discussed '\n", - " 'extensively, particularly its missions and character '\n", - " 'development.\\n'\n", - " '- **Arthur Morgan**: A central character in RDR2, noted for his '\n", - " 'moral complexity and development throughout the game.\\n'\n", - " '- **Dutch van der Linde**: Another key character from RDR2, whose '\n", - " \"increasingly erratic decisions impact the game's storyline.\\n\"\n", - " '- **Helldivers 2**: A cooperative multiplayer game mentioned by '\n", - " 'the user, known for its intense gameplay and strategic team '\n", - " 'dynamics.\\n'\n", - " '- **Nvidia**: Technology company referenced in relation to driver '\n", - " 'compatibility issues with Linux operating systems.\\n'\n", - " '- **Linux**: Operating system mentioned as having compatibility '\n", - " \"issues with Nvidia drivers, affecting the user's gaming \"\n", - " 'experience.',\n", + " '- Assistant: Provides insights and engages in discussions about '\n", + " 'video games, offers technical advice.\\n'\n", + " '- Red Dead Redemption 2: A video game discussed for its missions '\n", + " 'and character development.\\n'\n", + " '- Helldivers 2: Another video game mentioned, focusing on '\n", + " 'gameplay and strategies.\\n'\n", + " '- Nvidia: Mentioned in relation to driver compatibility issues '\n", + " 'with Linux.',\n", " 'role': 'assistant'}\n" ] } @@ -513,11 +558,18 @@ "source": [ "pprint(get_entities(chat_session))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "julep", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -531,7 +583,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.12.1" } }, "nbformat": 4, diff --git a/agents-api/notebooks/02-trim-messages.ipynb b/agents-api/notebooks/02-trim-messages.ipynb index 2a5c58da2..bf03a76a0 100644 --- a/agents-api/notebooks/02-trim-messages.ipynb +++ b/agents-api/notebooks/02-trim-messages.ipynb @@ -4,14 +4,62 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.51.0)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.6.0)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.27.2)\n", + "Requirement already satisfied: jiter<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.5.0)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (2.9.2)\n", + "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n", + "Requirement already satisfied: tqdm>4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.66.5)\n", + "Requirement already satisfied: typing-extensions<5,>=4.11 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.2)\n", + "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n", + "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n", + "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.23.4)\n" + ] + } + ], + "source": [ + "! pip install openai" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.1)\n" + ] + } + ], + "source": [ + "! pip install python-dotenv" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "True" + "False" ] }, - "execution_count": 1, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -35,18 +83,22 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "from openai import Client\n", + "import openai\n", + "from openai import OpenAI\n", "\n", - "client = Client()" + "api_key = \"YOUR_OPENAI_API_KEY\"\n", + "\n", + "openai.api_key = api_key\n", + "client = OpenAI(api_key=api_key)" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -69,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -89,7 +141,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -106,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -290,7 +342,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -351,7 +403,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -360,7 +412,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -376,7 +428,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -385,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -402,7 +454,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -418,7 +470,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -493,7 +545,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -501,11 +553,11 @@ "output_type": "stream", "text": [ "Starting CoT generation\n", - "{'content': 'The messages are clear and concise, reflecting a casual '\n", - " 'conversation about gaming experiences and software issues. '\n", - " \"There's no need for trimming as each message contributes to the \"\n", - " 'flow of the conversation, maintaining user engagement and '\n", - " 'providing relevant information and responses.',\n", + "{'content': 'The conversation is generally concise and relevant to the casual, '\n", + " 'gaming-centered topic. Each message contributes to the dialogue '\n", + " 'by either providing information or prompting further discussion, '\n", + " 'and no excessive verbosity or extraneous details are present. '\n", + " 'Therefore, no trimming is required for this session.',\n", " 'role': 'assistant'}\n", "End CoT generation\n", "Starting chatml generation\n", @@ -701,11 +753,18 @@ "source": [ "pprint(trim_messages(chat_session))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "julep", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -719,7 +778,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.12.1" } }, "nbformat": 4, diff --git a/agents-api/notebooks/03-summarise.ipynb b/agents-api/notebooks/03-summarise.ipynb index 98e6f5e0a..7be4baf02 100644 --- a/agents-api/notebooks/03-summarise.ipynb +++ b/agents-api/notebooks/03-summarise.ipynb @@ -4,14 +4,62 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.51.0)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.6.0)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.27.2)\n", + "Requirement already satisfied: jiter<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.5.0)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (2.9.2)\n", + "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n", + "Requirement already satisfied: tqdm>4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.66.5)\n", + "Requirement already satisfied: typing-extensions<5,>=4.11 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.2)\n", + "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n", + "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n", + "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.23.4)\n" + ] + } + ], + "source": [ + "! pip install openai" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.1)\n" + ] + } + ], + "source": [ + "! pip install python-dotenv" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "True" + "False" ] }, - "execution_count": 1, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -42,18 +90,22 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "from openai import Client\n", + "import openai\n", + "from openai import OpenAI\n", + "\n", + "api_key = \"YOUR_OPENAI_API_KEY\"\n", "\n", - "client = Client()" + "openai.api_key = api_key\n", + "client = OpenAI(api_key=api_key)" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -80,7 +132,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -100,7 +152,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -124,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -315,7 +367,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -355,7 +407,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -429,7 +481,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -474,7 +526,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -490,7 +542,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -506,7 +558,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -515,7 +567,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -532,7 +584,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -555,7 +607,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -636,7 +688,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -644,41 +696,37 @@ "output_type": "stream", "text": [ "Starting CoT generation\n", - "{'content': 'To provide a comprehensive overview of the entities in the '\n", - " 'session, we need to focus on the main people, places, things, and '\n", - " 'concepts that have been discussed:\\n'\n", + "{'content': 'To summarize the important entities from this conversation:\\n'\n", " '\\n'\n", - " '1. **User**: Engages in conversation about video games, '\n", - " 'specifically mentioning experiences with \"Red Dead Redemption 2\" '\n", - " 'and \"Helldivers 2.\" Also, shares technical issues related to '\n", - " 'Nvidia graphics drivers on Linux.\\n'\n", + " '1. **User**: Engages in a casual and friendly chat with the '\n", + " 'Assistant, discussing video games and a technical issue.\\n'\n", + " '2. **Assistant**: Responds to the User, engaging in discussions '\n", + " 'about specific video games and offering technical advice '\n", + " 'regarding an Nvidia driver issue.\\n'\n", + " '3. **Video Games Discussed**:\\n'\n", + " ' - **Red Dead Redemption 2 (RDR2)**: User recently finished '\n", + " 'this game and discusses specific missions such as \"Blood Feuds, '\n", + " 'Ancient and Modern\".\\n'\n", + " ' - **Helldivers 2**: User is currently playing this game, '\n", + " 'mentioning favorite builds and discussing gameplay strategies.\\n'\n", + " '4. **Technical Issue**: User mentions having an Nvidia driver '\n", + " 'issue, particularly concerning its compatibility with Linux. The '\n", + " 'Assistant offers advice on handling this issue.\\n'\n", + " '5. **Game Characters**:\\n'\n", + " ' - **Arthur**: From RDR2, discussed in terms of his journey and '\n", + " 'character development.\\n'\n", + " ' - **Dutch**: Also from RDR2, discussed for his progressive '\n", + " 'craziness and leadership style.\\n'\n", + " '6. **Gaming Strategies**:\\n'\n", + " ' - **Run and Gun**: Mentioned by the User as a strategy used in '\n", + " 'Helldivers 2.\\n'\n", + " '7. **Operating System**:\\n'\n", + " ' - **Linux**: Mentioned in relation to the Nvidia driver '\n", + " 'compatibility issue.\\n'\n", " '\\n'\n", - " '2. **Assistant**: Offers insights and engages in discussions '\n", - " 'about the video games mentioned by the user, provides gameplay '\n", - " 'strategies, and offers technical advice regarding Nvidia driver '\n", - " 'issues on Linux.\\n'\n", - " '\\n'\n", - " '3. **Red Dead Redemption 2 (RDR2)**: A video game discussed '\n", - " 'extensively in the conversation. Key aspects such as the '\n", - " 'character Arthur, missions like \"Blood Feuds, Ancient and '\n", - " 'Modern,\" and side quests are highlighted.\\n'\n", - " '\\n'\n", - " '4. **Helldivers 2**: Another video game mentioned by the user. '\n", - " 'The conversation covers gameplay elements like the laser cannon, '\n", - " 'guard dog, and challenges like the Charger enemy.\\n'\n", - " '\\n'\n", - " '5. **Nvidia Drivers**: A technical issue brought up by the user, '\n", - " 'particularly focusing on compatibility problems with Linux. The '\n", - " 'assistant provides troubleshooting advice and recommendations for '\n", - " 'dealing with these issues.\\n'\n", - " '\\n'\n", - " '6. **Linux**: Mentioned in the context of having compatibility '\n", - " \"issues with Nvidia drivers, highlighting the user's struggle with \"\n", - " 'technical aspects of gaming on this operating system.\\n'\n", - " '\\n'\n", - " 'These entities encapsulate the core topics and issues discussed '\n", - " \"in the session, providing a clear view of the conversation's \"\n", - " 'focus areas.',\n", + " 'These entities encapsulate the main topics and references made '\n", + " 'during the conversation, focusing on video gaming experiences, '\n", + " 'character analysis, and technical troubleshooting.',\n", " 'role': 'assistant'}\n", "End CoT generation\n", "Starting chatml generation\n", @@ -699,7 +747,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -777,7 +825,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -785,19 +833,45 @@ "output_type": "stream", "text": [ "Starting CoT generation\n", - "{'content': 'The conversation between the user and the assistant revolves '\n", - " 'around video games and technical issues. The assistant engages '\n", - " 'enthusiastically about the user’s gaming experiences, providing '\n", - " 'tips and engaging on a technical level about Nvidia drivers on '\n", - " 'Linux towards the end. The user is generally responsive and '\n", - " 'shares specifics about their gaming preferences and technical '\n", - " 'difficulties. The tone is casual and friendly throughout, with '\n", - " 'the assistant providing support and showing interest in the '\n", - " \"user's activities. \\n\"\n", - " '\\n'\n", - " 'No trimming is required as the messages are well-paced and '\n", - " \"relevant to the users' interests, fostering an engaging and \"\n", - " 'informative dialogue.',\n", + "{'content': '\\n'\n", + " \"- User greeted the assistant and asked what's good.\\n\"\n", + " '- Assistant replied casually, asking about recent games.\\n'\n", + " '- User mentioned finishing Red Dead Redemption 2, praising the '\n", + " 'final mission.\\n'\n", + " \"- Assistant inquired about the user's thoughts on Arthur's \"\n", + " 'journey and favorite moments.\\n'\n", + " '- User highlighted the \"Blood Feuds\" mission.\\n'\n", + " \"- Assistant discussed the mission's cinematic aspects and asked \"\n", + " \"about user's alignment with game characters.\\n\"\n", + " '- User preferred Arthur over Dutch.\\n'\n", + " '- Assistant discussed character development and suggested '\n", + " 'exploring side quests.\\n'\n", + " '- User mentioned completing side quests, liked the widow and '\n", + " 'bounty missions.\\n'\n", + " \"- Assistant praised the game's side missions and asked about \"\n", + " \"user's next gaming plans.\\n\"\n", + " '- User switched to playing Helldivers 2.\\n'\n", + " \"- Assistant described Helldivers 2's gameplay and asked about \"\n", + " \"user's experience.\\n\"\n", + " '- User shared favorite equipment setup.\\n'\n", + " '- Assistant discussed tactical options and asked about '\n", + " 'challenging missions.\\n'\n", + " '- User mentioned difficulty with a specific enemy.\\n'\n", + " \"- Assistant offered strategy tips and inquired about team's \"\n", + " 'handling of game challenges.\\n'\n", + " '- User described their run-and-gun approach.\\n'\n", + " '- Assistant acknowledged the strategy and asked about difficulty '\n", + " 'levels.\\n'\n", + " '- User mentioned needing to work and a technical issue with '\n", + " 'Nvidia drivers.\\n'\n", + " '- Assistant offered technical advice for driver issue and wished '\n", + " 'good luck with work.\\n'\n", + " '- User commented on Nvidia and Linux compatibility issues.\\n'\n", + " '- Assistant provided detailed advice for handling Nvidia drivers '\n", + " 'on Linux.\\n'\n", + " '- User ended the conversation, intending to leave.\\n'\n", + " '- Assistant said goodbye.\\n'\n", + " '',\n", " 'role': 'assistant'}\n", "End CoT generation\n", "Starting chatml generation\n", @@ -811,7 +885,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -1011,7 +1085,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -1098,7 +1172,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -1106,106 +1180,21 @@ "output_type": "stream", "text": [ "Starting CoT generation\n", - "{'content': '- Combine initial greetings and the start of the discussion about '\n", - " '\"Red Dead Redemption 2 (RDR2)\" into a summary.\\n'\n", - " '- Summarize the detailed conversation about specific missions and '\n", - " 'characters in \"RDR2\".\\n'\n", - " '- Retain individual entries about \"Helldivers 2\" due to the '\n", - " \"user's direct interaction and game preferences.\\n\"\n", - " '- Summarize discussions around \"Nvidia Drivers\" and \"Linux\" '\n", - " 'compatibility, emphasizing the solution offered.\\n'\n", - " '- Retain the closing conversation as it indicates the end of the '\n", - " 'session. \\n'\n", - " '\\n'\n", - " '\\n'\n", - " '[\\n'\n", - " ' {\\n'\n", - " ' \"role\": \"system\",\\n'\n", - " ' \"name\": \"summary\",\\n'\n", - " ' \"content\": \"Event: The user discussed finishing \\'Red Dead '\n", - " \"Redemption 2' and particularly enjoyed the last mission. They \"\n", - " 'also talked about favorite missions and characters, specifically '\n", - " 'Arthur over Dutch.\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 12,\\n'\n", - " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"im playing helldivers 2. do u know of it\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 13,\\n'\n", - " ' \"role\": \"assistant\",\\n'\n", - " ' \"content\": \"Yes, Helldivers 2! It\\'s a great choice if '\n", - " \"you're into intense co-op action. The game really ramps up with \"\n", - " 'its twin-stick shooter gameplay, and it\\\\u2019s super fun but '\n", - " 'also quite challenging. Working together with teammates to '\n", - " 'complete those missions can get pretty hectic. How are you '\n", - " 'finding the chaos and team dynamics so far?\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 14,\\n'\n", - " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"amazing. my fav build is laser cannon + guard '\n", - " 'dog. what about u\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 15,\\n'\n", - " ' \"role\": \"assistant\",\\n'\n", - " ' \"content\": \"Nice combo! The laser cannon is awesome for '\n", - " 'tearing through those enemy swarms, and the guard dog drone '\n", - " 'really helps in keeping the smaller threats at bay. I personally '\n", - " 'love using the railgun with a shield backpack. It gives a good '\n", - " 'balance of offense and defense, especially when things get really '\n", - " 'chaotic. What\\'s been the toughest mission for you so far?\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 16,\\n'\n", - " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"dude the charger is so difficult to kill.\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 17,\\n'\n", - " ' \"role\": \"assistant\",\\n'\n", - " ' \"content\": \"Yeah, the Charger can be brutal! They really test '\n", - " \"your reflexes and teamwork. It's all about timing and \"\n", - " 'coordination with your team to bring those heavy hitters down. '\n", - " 'Have you tried using more strategic traps or mines? Sometimes '\n", - " 'setting up the right position with static fields can really make '\n", - " 'a difference against them. How do your squadmates handle it?\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 18,\\n'\n", - " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"we just run and gun\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 19,\\n'\n", - " ' \"role\": \"assistant\",\\n'\n", - " ' \"content\": \"Classic strategy! That can definitely be fun, '\n", - " 'especially in a game as intense as Helldivers 2 where things get '\n", - " 'chaotic fast. Keeping on the move helps a ton. Just make sure '\n", - " \"someone's always got your back! Have you guys tried any of the \"\n", - " 'higher difficulty levels yet, or are you sticking to a certain '\n", - " 'comfort zone for now?\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"role\": \"system\",\\n'\n", - " ' \"name\": \"summary\",\\n'\n", - " ' \"content\": \"Event: The user discussed an Nvidia driver issue, '\n", - " 'particularly its incompatibility with Linux, and the assistant '\n", - " 'provided potential solutions and resources for assistance.\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 24,\\n'\n", - " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"yep. see u bye!\"\\n'\n", - " ' },\\n'\n", - " ' {\\n'\n", - " ' \"index\": 25,\\n'\n", - " ' \"role\": \"assistant\",\\n'\n", - " ' \"content\": \"See you, take care! Bye!\"\\n'\n", - " ' }\\n'\n", - " ']\\n',\n", + "{'content': '- Summarize the initial casual greeting between User and '\n", + " 'Assistant.\\n'\n", + " \"- Keep detailed discussion on RDR2, including User's favorite \"\n", + " 'moments and characters, as they directly relate to the entities '\n", + " 'outlined.\\n'\n", + " '- Summarize the transition from RDR2 discussion to Helldivers 2 '\n", + " 'without losing game-specific details.\\n'\n", + " '- Preserve details on Helldivers 2 gameplay strategies mentioned '\n", + " 'by User.\\n'\n", + " \"- Summarize User's mention of work and Nvidia driver issue while \"\n", + " 'retaining the essence of their tech problem.\\n'\n", + " \"- Retain Assistant's advice on Nvidia and Linux compatibility \"\n", + " \"issues, as it's relevant to the User's context.\\n\"\n", + " '- Keep the farewell message brief but intact to maintain the '\n", + " 'conversational closure.',\n", " 'role': 'assistant'}\n", "End CoT generation\n", "Starting chatml generation\n", @@ -1225,7 +1214,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -1236,88 +1225,180 @@ " ' {\\n'\n", " ' \"role\": \"system\",\\n'\n", " ' \"name\": \"summary\",\\n'\n", - " ' \"content\": \"Event: The user discussed finishing \\'Red Dead '\n", - " \"Redemption 2' and particularly enjoyed the last mission. They \"\n", - " 'also talked about favorite missions and characters, specifically '\n", - " 'Arthur over Dutch.\"\\n'\n", + " ' \"content\": \"Event: Casual greeting between User and '\n", + " 'Assistant, with User mentioning they recently finished playing '\n", + " 'Red Dead Redemption 2.\"\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"user\",\\n'\n", + " ' \"content\": \"i just got done with finishing red dead '\n", + " 'redemption 2 recently. the last mission was so fkng coolll\",\\n'\n", + " ' \"index\": 4\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"assistant\",\\n'\n", + " ' \"content\": \"Oh man, RDR2 is epic! That ending is intense, '\n", + " \"right? What did you think about Arthur's journey throughout the \"\n", + " 'game? Got any favorite moments?\",\\n'\n", + " ' \"index\": 5\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"user\",\\n'\n", + " ' \"content\": \"blood feuds mission was amazing\",\\n'\n", + " ' \"index\": 6\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"assistant\",\\n'\n", + " ' \"content\": \"Absolutely, the \\\\\"Blood Feuds, Ancient and '\n", + " 'Modern\\\\\" mission is a standout! The whole shootout at '\n", + " 'Braithwaite Manor is intense. The atmosphere Rockstar created '\n", + " 'during that mission with the burning building in the background '\n", + " 'is just cinematic perfection. Did you side more with Arthur or '\n", + " 'Dutch throughout the game?\",\\n'\n", + " ' \"index\": 7\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 12,\\n'\n", " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"im playing helldivers 2. do u know of it\"\\n'\n", + " ' \"content\": \"arthur of course. dutch just kept becoming '\n", + " 'crazier and crazier.\",\\n'\n", + " ' \"index\": 8\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"assistant\",\\n'\n", + " ' \"content\": \"Totally get that. Arthur\\'s character development '\n", + " \"is really something else. He starts questioning Dutch's decisions \"\n", + " 'and looking at things more critically, which adds so much depth '\n", + " \"to his character. Watching Dutch's descent as the gang falls \"\n", + " 'apart is pretty intense. Have you thought about checking out any '\n", + " 'of the side quests or exploring more of the open world now that '\n", + " 'you\\'ve finished the main story?\",\\n'\n", + " ' \"index\": 9\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"user\",\\n'\n", + " ' \"content\": \"oh i\\'ve done all the side quests. the widow '\n", + " 'missions are great but i also loved the bounty missions (where u '\n", + " 'have to talk to gangsters for an author)\",\\n'\n", + " ' \"index\": 10\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"assistant\",\\n'\n", + " ' \"content\": \"Ah, the bounty missions for the author are a '\n", + " 'blast! Hunting down those gunslingers for the book gives you such '\n", + " \"a great tour of the game's diverse characters. And Charlotte's \"\n", + " \"missions, the widow, they're pretty touching, right? It\\\\u2019s \"\n", + " 'nice to see Arthur helping her adapt to wilderness life. Adds a '\n", + " 'softer side to the game amidst all the chaos.\\\\n\\\\nNow that '\n", + " 'you\\'ve conquered RDR2, any other games on your radar?\",\\n'\n", + " ' \"index\": 11\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"user\",\\n'\n", + " ' \"content\": \"im playing helldivers 2. do u know of it\",\\n'\n", + " ' \"index\": 12\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 13,\\n'\n", " ' \"role\": \"assistant\",\\n'\n", " ' \"content\": \"Yes, Helldivers 2! It\\'s a great choice if '\n", " \"you're into intense co-op action. The game really ramps up with \"\n", " 'its twin-stick shooter gameplay, and it\\\\u2019s super fun but '\n", " 'also quite challenging. Working together with teammates to '\n", " 'complete those missions can get pretty hectic. How are you '\n", - " 'finding the chaos and team dynamics so far?\"\\n'\n", + " 'finding the chaos and team dynamics so far?\",\\n'\n", + " ' \"index\": 13\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 14,\\n'\n", " ' \"role\": \"user\",\\n'\n", " ' \"content\": \"amazing. my fav build is laser cannon + guard '\n", - " 'dog. what about u\"\\n'\n", + " 'dog. what about u\",\\n'\n", + " ' \"index\": 14\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 15,\\n'\n", " ' \"role\": \"assistant\",\\n'\n", " ' \"content\": \"Nice combo! The laser cannon is awesome for '\n", " 'tearing through those enemy swarms, and the guard dog drone '\n", " 'really helps in keeping the smaller threats at bay. I personally '\n", " 'love using the railgun with a shield backpack. It gives a good '\n", " 'balance of offense and defense, especially when things get really '\n", - " 'chaotic. What\\'s been the toughest mission for you so far?\"\\n'\n", + " 'chaotic. What\\'s been the toughest mission for you so far?\",\\n'\n", + " ' \"index\": 15\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 16,\\n'\n", " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"dude the charger is so difficult to kill.\"\\n'\n", + " ' \"content\": \"dude the charger is so difficult to kill.\",\\n'\n", + " ' \"index\": 16\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 17,\\n'\n", " ' \"role\": \"assistant\",\\n'\n", " ' \"content\": \"Yeah, the Charger can be brutal! They really test '\n", " \"your reflexes and teamwork. It's all about timing and \"\n", " 'coordination with your team to bring those heavy hitters down. '\n", " 'Have you tried using more strategic traps or mines? Sometimes '\n", " 'setting up the right position with static fields can really make '\n", - " 'a difference against them. How do your squadmates handle it?\"\\n'\n", + " 'a difference against them. How do your squadmates handle it?\",\\n'\n", + " ' \"index\": 17\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 18,\\n'\n", " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"we just run and gun\"\\n'\n", + " ' \"content\": \"we just run and gun\",\\n'\n", + " ' \"index\": 18\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 19,\\n'\n", " ' \"role\": \"assistant\",\\n'\n", " ' \"content\": \"Classic strategy! That can definitely be fun, '\n", " 'especially in a game as intense as Helldivers 2 where things get '\n", " 'chaotic fast. Keeping on the move helps a ton. Just make sure '\n", " \"someone's always got your back! Have you guys tried any of the \"\n", " 'higher difficulty levels yet, or are you sticking to a certain '\n", - " 'comfort zone for now?\"\\n'\n", + " 'comfort zone for now?\",\\n'\n", + " ' \"index\": 19\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"role\": \"system\",\\n'\n", - " ' \"name\": \"summary\",\\n'\n", - " ' \"content\": \"Event: The user discussed an Nvidia driver issue, '\n", - " 'particularly its incompatibility with Linux, and the assistant '\n", - " 'provided potential solutions and resources for assistance.\"\\n'\n", + " ' \"role\": \"user\",\\n'\n", + " ' \"content\": \"i think i have to go work soon. also have this '\n", + " 'nvidia driver issue that\\'s bugging me\",\\n'\n", + " ' \"index\": 20\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"assistant\",\\n'\n", + " ' \"content\": \"Ah, bummer about the driver issue \\\\u2014 it\\'s '\n", + " 'annoying when tech stuff gets in the way of gaming. Maybe try '\n", + " \"doing a clean install of the drivers if you haven't already? It \"\n", + " 'can sometimes clear up persistent issues.\\\\n\\\\nAlso, good luck '\n", + " \"with work! Hopefully, you'll get some time later to sort out the \"\n", + " 'driver thing and jump back into some gaming. Let me know how it '\n", + " \"goes, and if you need more gaming chats or tech tips, I'm \"\n", + " 'here!\",\\n'\n", + " ' \"index\": 21\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"user\",\\n'\n", + " ' \"content\": \"nvidia and linux don\\'t go well together\",\\n'\n", + " ' \"index\": 22\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"assistant\",\\n'\n", + " ' \"content\": \"That\\'s true, Nvidia drivers can be tricky to '\n", + " 'handle on Linux due to compatibility issues sometimes. You might '\n", + " 'want to check out the latest Nvidia driver from their official '\n", + " 'site or a stable version known to work well with your specific '\n", + " 'Linux distribution. Using proprietary drivers instead of Nouveau '\n", + " 'could also potentially solve a lot of issues. Additionally, '\n", + " 'forums and community support boards like those on Ubuntu, Arch, '\n", + " 'or even broader communities like Reddit\\\\u2019s r/linux_gaming '\n", + " 'can be really helpful.\\\\n\\\\nHope that helps, and your driver woes '\n", + " 'get sorted soon so you can enjoy your gaming hassle-free!\",\\n'\n", + " ' \"index\": 23\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 24,\\n'\n", " ' \"role\": \"user\",\\n'\n", - " ' \"content\": \"yep. see u bye!\"\\n'\n", + " ' \"content\": \"yep. see u bye!\",\\n'\n", + " ' \"index\": 24\\n'\n", " ' },\\n'\n", " ' {\\n'\n", - " ' \"index\": 25,\\n'\n", " ' \"role\": \"assistant\",\\n'\n", - " ' \"content\": \"See you, take care! Bye!\"\\n'\n", + " ' \"content\": \"See you, take care! Bye!\",\\n'\n", + " ' \"index\": 25\\n'\n", " ' }\\n'\n", " ']',\n", " 'role': 'assistant'}\n" @@ -1327,11 +1408,18 @@ "source": [ "pprint(summarized_messages)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "julep", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -1345,7 +1433,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.12.1" } }, "nbformat": 4, diff --git a/agents-api/notebooks/RecSum-experiments.ipynb b/agents-api/notebooks/RecSum-experiments.ipynb index 1315533dc..466c7e6cb 100644 --- a/agents-api/notebooks/RecSum-experiments.ipynb +++ b/agents-api/notebooks/RecSum-experiments.ipynb @@ -1,18 +1,68 @@ { "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "3127f8fc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.51.0)\n", + "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.6.0)\n", + "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n", + "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.27.2)\n", + "Requirement already satisfied: jiter<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.5.0)\n", + "Requirement already satisfied: pydantic<3,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (2.9.2)\n", + "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n", + "Requirement already satisfied: tqdm>4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.66.5)\n", + "Requirement already satisfied: typing-extensions<5,>=4.11 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.2)\n", + "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n", + "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n", + "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n", + "Requirement already satisfied: h11<0.15,>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n", + "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.23.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.23.4)\n" + ] + } + ], + "source": [ + "! pip install openai" + ] + }, { "cell_type": "code", "execution_count": 2, + "id": "96efe2be", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.1)\n" + ] + } + ], + "source": [ + "! pip install python-dotenv" + ] + }, + { + "cell_type": "code", + "execution_count": 3, "id": "b03a4636-d57e-42e9-8a06-fdb7c6803708", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "True" + "False" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -23,24 +73,20 @@ "load_dotenv(\"../../.env\")" ] }, - { - "cell_type": "code", - "execution_count": 3, - "id": "eb80a352-ad21-423c-9284-32b21d271eba", - "metadata": {}, - "outputs": [], - "source": [ - "from openai import Client" - ] - }, { "cell_type": "code", "execution_count": 4, - "id": "4619f484-55f6-4122-8e26-27ec9e3506d5", + "id": "eb80a352-ad21-423c-9284-32b21d271eba", "metadata": {}, "outputs": [], "source": [ - "client = Client()" + "import openai\n", + "from openai import OpenAI\n", + "\n", + "api_key = \"YOUR_OPENAI_API_KEY\"\n", + "\n", + "openai.api_key = api_key\n", + "client = OpenAI(api_key=api_key)" ] }, { @@ -99,7 +145,7 @@ "\n", "\n", "def chat():\n", - " while (user_input := input(\"You: \")) != \"bye\":\n", + " while (user_input := input(\"You: \").lower()) != \"bye\": \n", " chat_session.append(user(user_input))\n", "\n", " result = generate(chat_session)\n", @@ -362,63 +408,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "You: hey\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GPT: Hey! How are you doing?\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You: good, how about you?\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GPT: I'm doing well, thank you for asking. Is there anything on your mind that you'd like to talk about or get some advice on?\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You: no why do you say that? did I sound troubled?\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GPT: Not at all! I just thought I'd check in and see if there's anything on your mind that you might need some advice or someone to talk to about. But if you're doing well, that's great to hear!\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You: no I didnt say I was ok just that I hadnt thought of asking for advice yet\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GPT: Ah, I see. Well, I'm here whenever you need a listening ear or some advice. Just let me know how I can help!\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You: bye\n" + "GPT: Hey there! I just wanted to remind you that it's important to take care of yourself both mentally and physically. Make sure to prioritize self-care and engage in activities that bring you joy and peace. Remember, it's okay to say no to things that don't align with your values or make you uncomfortable. Trust your instincts and surround yourself with positive influences. You deserve to be happy and fulfilled, so don't be afraid to pursue your dreams and make choices that are best for you. If you ever need a listening ear or some guidance, I'm always here for you!\n", + "GPT: I'm just a program, so I don't have feelings like humans do, but I'm here and ready to help you with anything you need. How can I support you today?\n" ] } ], @@ -442,7 +433,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 13, "id": "95431b29-73e2-4954-b6fc-1c8814a9249f", "metadata": {}, "outputs": [], @@ -452,7 +443,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "id": "1eaabfe2-f399-428b-84d2-ed8c237b7d3d", "metadata": {}, "outputs": [], @@ -475,7 +466,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "id": "2a726b3c-493c-4df5-81a7-6b7b109c222e", "metadata": {}, "outputs": [], @@ -504,7 +495,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 16, "id": "6323b7b2-0aaf-4cea-896b-0c887054ce6e", "metadata": {}, "outputs": [], @@ -596,7 +587,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 17, "id": "0c2eaabc-76a1-412f-beb3-b64510e638a2", "metadata": {}, "outputs": [ @@ -604,57 +595,74 @@ "name": "stdout", "output_type": "stream", "text": [ - "1714643926.0711672\n", - "0.0017969608306884766\n", + "1728353832.57365\n", + "0.00043010711669921875\n", "Starting CoT generation\n", "{'content': 'Planning step by step:\\n'\n", - " '- Combine entries 1 and 2 into a summary of the greeting and '\n", - " 'initial chat.\\n'\n", - " '- Summarize the conversation about Red Dead Redemption 2 from '\n", - " 'entries 3 to 10, noting key points about the game and missions '\n", - " 'discussed.\\n'\n", - " '- Combine entries 11 and 12 into a summary about transitioning to '\n", - " 'the game Helldivers 2, including initial thoughts.\\n'\n", - " '- Summarize the specific discussion about Helldivers 2 gameplay '\n", - " 'and strategy from entries 13 to 18.\\n'\n", - " '- Summarize entries 19 and 20 discussing the user having to go to '\n", - " 'work and dealing with Nvidia driver issues.\\n'\n", - " '- Combine entries 21 and 22 to summarize the Nvidia and Linux '\n", - " 'driver compatibility discussion.\\n'\n", - " '- Combine entries 23 and 24 to a summary of the farewell.',\n", + " '- We can consolidate the initial greetings and mention of Red '\n", + " 'Dead Redemption 2 into a summary.\\n'\n", + " '- The detailed discussion about RDR2 and Helldivers 2 can be '\n", + " 'summarized while retaining key elements of the conversation.\\n'\n", + " \"- The user's brief mention of work and technical issues can be \"\n", + " 'summarized into one entry to capture the issue without losing '\n", + " 'context.\\n'\n", + " '- Farewells can be combined into a single entry.\\n'\n", + " '\\n'\n", + " \"Here's how we can compact the history: \\n\"\n", + " '\\n'\n", + " '1. Summarize the greeting and initial conversation about Red Dead '\n", + " 'Redemption 2.\\n'\n", + " '2. Summarize the detailed discussion on RDR2, focusing on the '\n", + " \"user's favorite moments and questions from the assistant.\\n\"\n", + " '3. Summarize the conversation about Helldivers 2, highlighting '\n", + " 'user preferences and challenges faced in gameplay.\\n'\n", + " \"4. Combine the entries about the user's Nvidia driver issue and \"\n", + " 'the farewell into two concise entries.',\n", " 'role': 'assistant'}\n", "End CoT generation\n", - "7.267635345458984\n", - "7.2676897048950195\n", + "6.3223512172698975\n", + "6.322365999221802\n", "Starting chatml generation\n", "End chatml generation\n", - "19.629928588867188\n", + "26.040874004364014\n", "{'content': '[\\n'\n", " ' {\\n'\n", " ' \"role\": \"system\",\\n'\n", - " ' \"content\": \"User greets the assistant and mentions finishing '\n", - " 'Red Dead Redemption 2, praising the final mission. The assistant '\n", - " \"responds enthusiastically, discussing the game's ending and key \"\n", - " 'missions.\"\\n'\n", + " ' \"name\": \"summary\",\\n'\n", + " ' \"content\": \"The user greeted the assistant and shared their '\n", + " 'recent completion of Red Dead Redemption 2, expressing excitement '\n", + " 'about the game\\'s final mission.\"\\n'\n", + " ' },\\n'\n", + " ' {\\n'\n", + " ' \"role\": \"system\",\\n'\n", + " ' \"name\": \"summary\",\\n'\n", + " ' \"content\": \"The user and the assistant discussed favorite '\n", + " \"moments from Red Dead Redemption 2, focusing on the 'Blood Feuds, \"\n", + " \"Ancient and Modern' mission and Arthur's character development. \"\n", + " 'The user expressed a preference for Arthur over Dutch and '\n", + " 'mentioned completing all side quests, including the widow and '\n", + " 'bounty missions.\"\\n'\n", " ' },\\n'\n", " ' {\\n'\n", " ' \"role\": \"system\",\\n'\n", - " ' \"content\": \"The conversation shifts to Helldivers 2, with the '\n", - " 'user sharing their favorite build and the assistant suggesting '\n", - " 'strategies. They discuss gameplay dynamics and the challenges of '\n", - " 'specific missions.\"\\n'\n", + " ' \"name\": \"summary\",\\n'\n", + " ' \"content\": \"The conversation shifted to Helldivers 2, where '\n", + " 'the user described their favorite build and gameplay strategy. '\n", + " 'They discussed the challenges of facing the Charger enemy and the '\n", + " 'run-and-gun approach they use with their squad.\"\\n'\n", " ' },\\n'\n", " ' {\\n'\n", " ' \"role\": \"system\",\\n'\n", - " ' \"content\": \"User mentions having to go to work soon and '\n", - " 'dealing with an Nvidia driver issue. The assistant offers '\n", - " 'troubleshooting advice for Nvidia drivers on Linux and wishes the '\n", - " 'user good luck with work.\"\\n'\n", + " ' \"name\": \"summary\",\\n'\n", + " ' \"content\": \"The user mentioned having to go to work soon and '\n", + " 'experiencing issues with Nvidia drivers on Linux. The assistant '\n", + " 'provided suggestions for resolving driver compatibility issues.\"\\n'\n", " ' },\\n'\n", " ' {\\n'\n", " ' \"role\": \"system\",\\n'\n", - " ' \"content\": \"User acknowledges the advice and says goodbye. '\n", - " 'The assistant wishes them well.\"\\n'\n", + " ' \"name\": \"summary\",\\n'\n", + " ' \"content\": \"The user said goodbye, indicating they would see '\n", + " 'the assistant later.\"\\n'\n", " ' }\\n'\n", " ']',\n", " 'role': 'assistant'}\n" @@ -676,7 +684,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -690,7 +698,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.12.1" } }, "nbformat": 4,