diff --git a/agent_synthesis/Examine Synthetic Interactions-2.ipynb b/agent_synthesis/Examine Synthetic Interactions-2.ipynb new file mode 100644 index 0000000..0598827 --- /dev/null +++ b/agent_synthesis/Examine Synthetic Interactions-2.ipynb @@ -0,0 +1,173 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "545f5ee4", + "metadata": {}, + "outputs": [], + "source": [ + "import pickle\n", + "from collections import Counter\n", + "import matplotlib.pyplot as plt\n", + "from langchain.schema import HumanMessage, AIMessage, SystemMessage\n", + "import json" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "ae886211", + "metadata": {}, + "outputs": [], + "source": [ + "# Replace 'your_file.json' with the path to your JSON file\n", + "file_path = '/Users/allanniemerg/spikes/agentbenchwork/os_syn-datasyntype_2.json'\n", + "\n", + "# Read the JSON file and convert it to a Python object\n", + "with open(file_path, 'r') as file:\n", + " conversations = json.load(file)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "11053574", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1082" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(conversations)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "af8a56f0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'conversations': [{'from': 'human',\n", + " 'value': \"Now, I will start a new problem in a new OS. My problem is:\\n\\nI'd like to know how many files in my home directory were modified in the last 7 days.\",\n", + " 'loss': False},\n", + " {'from': 'gpt',\n", + " 'value': \"Think: To find out how many files were modified in the last week, I would use the 'find' command, specifying the home directory, modification time of 7 days, and file type as regular files.\\n\\nAct: bash\\n\\n```bash\\nfind ~ -type f -mtime -7\\n```\",\n", + " 'loss': True},\n", + " {'from': 'human',\n", + " 'value': 'The output of the OS:\\n\\n/root/project1/task1.txt\\r\\n/root/song2.mp3\\r\\n/root/project2/report.docx\\r\\n\\x1b]0;root@2da38cafd6c5: /\\x07root@2da38cafd6c5:/# \\x1b[K',\n", + " 'loss': False},\n", + " {'from': 'gpt',\n", + " 'value': 'Think: Now I have the list of all the files modified within the last 7 days. I will now count the number of files by piping my previous command to wc -l\\n\\nAct: bash\\n\\n```bash\\nfind ~ -type f -mtime -7 | wc -l\\n```',\n", + " 'loss': True},\n", + " {'from': 'human',\n", + " 'value': 'The output of the OS:\\n\\n3\\r\\n\\x1b]0;root@2da38cafd6c5: /\\x07root@2da38cafd6c5:/# \\x1b[K',\n", + " 'loss': False},\n", + " {'from': 'gpt',\n", + " 'value': 'Think: Now I get the answer, it is 3.\\n\\nAct: answer(3)',\n", + " 'loss': True}]}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "conversations[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "7bfe9d6b", + "metadata": {}, + "outputs": [], + "source": [ + "import html\n", + "from IPython.display import HTML, display\n", + "import pdfkit\n", + "import html\n", + "\n", + "def format_single_chat(chat_data):\n", + " formatted_html = '