From d3b3605402a132f40238097e6c0687c42c8ef5ca Mon Sep 17 00:00:00 2001 From: tj-cycyota Date: Thu, 18 Apr 2024 22:43:29 +0000 Subject: [PATCH] Outputs of DBRX notebook --- notebook/agentchat_databricks_dbrx.ipynb | 516 ++++++++++++++++++++++- 1 file changed, 507 insertions(+), 9 deletions(-) diff --git a/notebook/agentchat_databricks_dbrx.ipynb b/notebook/agentchat_databricks_dbrx.ipynb index 85a40605dc28..48ea3a9526ae 100644 --- a/notebook/agentchat_databricks_dbrx.ipynb +++ b/notebook/agentchat_databricks_dbrx.ipynb @@ -60,7 +60,16 @@ } } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001B[43mNote: you may need to restart the kernel using %restart_python or dbutils.library.restartPython() to use updated packages.\u001B[0m\nCollecting pyautogen==0.2.25\n Downloading pyautogen-0.2.25-py3-none-any.whl (257 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 257.1/257.1 kB 4.5 MB/s eta 0:00:00\nCollecting openai==1.21.2\n Downloading openai-1.21.2-py3-none-any.whl (309 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 309.9/309.9 kB 32.8 MB/s eta 0:00:00\nCollecting typing_extensions==4.11.0\n Downloading typing_extensions-4.11.0-py3-none-any.whl (34 kB)\nRequirement already satisfied: numpy<2,>=1.17.0 in /databricks/python3/lib/python3.10/site-packages (from pyautogen==0.2.25) (1.23.5)\nCollecting diskcache\n Downloading diskcache-5.6.3-py3-none-any.whl (45 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.5/45.5 kB 1.4 MB/s eta 0:00:00\nCollecting termcolor\n Downloading termcolor-2.4.0-py3-none-any.whl (7.7 kB)\nRequirement already satisfied: pydantic!=2.6.0,<3,>=1.10 in /databricks/python3/lib/python3.10/site-packages (from pyautogen==0.2.25) (1.10.6)\nCollecting tiktoken\n Downloading tiktoken-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 63.5 MB/s eta 0:00:00\nCollecting docker\n Downloading docker-7.0.0-py3-none-any.whl (147 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 147.6/147.6 kB 6.7 MB/s eta 0:00:00\nCollecting python-dotenv\n Downloading python_dotenv-1.0.1-py3-none-any.whl (19 kB)\nCollecting flaml\n Downloading FLAML-2.1.2-py3-none-any.whl (296 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 296.7/296.7 kB 31.8 MB/s eta 0:00:00\nRequirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from openai==1.21.2) (1.7.0)\nRequirement already satisfied: sniffio in /databricks/python3/lib/python3.10/site-packages (from openai==1.21.2) (1.2.0)\nCollecting tqdm>4\n Downloading tqdm-4.66.2-py3-none-any.whl (78 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 kB 13.3 MB/s eta 0:00:00\nRequirement already satisfied: anyio<5,>=3.5.0 in /databricks/python3/lib/python3.10/site-packages (from openai==1.21.2) (3.5.0)\nCollecting httpx<1,>=0.23.0\n Downloading httpx-0.27.0-py3-none-any.whl (75 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.6/75.6 kB 14.0 MB/s eta 0:00:00\nRequirement already satisfied: idna>=2.8 in /databricks/python3/lib/python3.10/site-packages (from anyio<5,>=3.5.0->openai==1.21.2) (3.4)\nCollecting httpcore==1.*\n Downloading httpcore-1.0.5-py3-none-any.whl (77 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.9/77.9 kB 10.3 MB/s eta 0:00:00\nRequirement already satisfied: certifi in /databricks/python3/lib/python3.10/site-packages (from httpx<1,>=0.23.0->openai==1.21.2) (2022.12.7)\nCollecting h11<0.15,>=0.13\n Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 8.2 MB/s eta 0:00:00\nRequirement already satisfied: packaging>=14.0 in /databricks/python3/lib/python3.10/site-packages (from docker->pyautogen==0.2.25) (23.2)\nRequirement already satisfied: requests>=2.26.0 in /databricks/python3/lib/python3.10/site-packages (from docker->pyautogen==0.2.25) (2.28.1)\nRequirement already satisfied: urllib3>=1.26.0 in /databricks/python3/lib/python3.10/site-packages (from docker->pyautogen==0.2.25) (1.26.14)\nCollecting regex>=2022.1.18\n Downloading regex-2024.4.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (773 kB)\n ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 774.0/774.0 kB 57.9 MB/s eta 0:00:00\nRequirement already satisfied: charset-normalizer<3,>=2 in /databricks/python3/lib/python3.10/site-packages (from requests>=2.26.0->docker->pyautogen==0.2.25) (2.0.4)\nInstalling collected packages: typing_extensions, tqdm, termcolor, regex, python-dotenv, h11, flaml, diskcache, tiktoken, httpcore, docker, httpx, openai, pyautogen\n Attempting uninstall: typing_extensions\n Found existing installation: typing_extensions 4.4.0\n Not uninstalling typing-extensions at /databricks/python3/lib/python3.10/site-packages, outside environment /local_disk0/.ephemeral_nfs/envs/pythonEnv-9b4660e6-9fa1-4c88-b2c5-de7d6abe0cfb\n Can't uninstall 'typing_extensions'. No files were found to uninstall.\nSuccessfully installed diskcache-5.6.3 docker-7.0.0 flaml-2.1.2 h11-0.14.0 httpcore-1.0.5 httpx-0.27.0 openai-1.21.2 pyautogen-0.2.25 python-dotenv-1.0.1 regex-2024.4.16 termcolor-2.4.0 tiktoken-0.6.0 tqdm-4.66.2 typing_extensions-4.11.0\n\u001B[43mNote: you may need to restart the kernel using %restart_python or dbutils.library.restartPython() to use updated packages.\u001B[0m\n" + ] + } + ], "source": [ "%pip install pyautogen==0.2.25 openai==1.21.2 typing_extensions==4.11.0 --upgrade\n", "dbutils.library.restartPython()" @@ -164,7 +173,37 @@ "title": "" } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001B[33muser\u001B[0m (to assistant):\n\nWhat is MLflow?\n\n--------------------------------------------------------------------------------\n\u001B[33massistant\u001B[0m (to user):\n\nSure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\n\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\n\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\n```python\n# filename: mlflow_example.py\n\nimport mlflow\nimport numpy as np\n\n# Log a parameter (e.g., number of trees in a random forest)\nmlflow.log_param(\"num_trees\", 100)\n\n# Log a metric (e.g., accuracy of a model)\naccuracy = np.random.rand()\nmlflow.log_metric(\"accuracy\", accuracy)\n\n# Log the model\nmlflow.sklearn.log_model(model, \"model\")\n\n# End the run\nmlflow.end_run()\n```\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\n```\npip install mlflow\n```\nThen, you can run the code using the following command:\n```\npython mlflow_example.py\n```\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\n\nI hope this helps! Let me know if you have any other questions.\n\n--------------------------------------------------------------------------------\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Provide feedback to assistant. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: exit" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "ChatResult(chat_id=None, chat_history=[{'content': 'What is MLflow?', 'role': 'assistant'}, {'content': 'Sure, I\\'d be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\"num_trees\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\"accuracy\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \"model\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.', 'role': 'user'}], summary='Sure, I\\'d be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\"num_trees\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\"accuracy\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \"model\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.', cost={'usage_including_cached_inference': {'total_cost': 0, 'dbrx-instruct-032724': {'cost': 0, 'prompt_tokens': 478, 'completion_tokens': 409, 'total_tokens': 887}}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['exit'])" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import autogen\n", "\n", @@ -223,7 +262,16 @@ "title": "" } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "coding\n" + ] + } + ], "source": [ "from pathlib import Path\n", "workdir = Path(\"coding\")\n", @@ -269,7 +317,26 @@ "title": "" } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001B[33mUser\u001B[0m (to DBRX Assistant):\n\nCount how many prime numbers from 1 to 10000.\n\n--------------------------------------------------------------------------------\n\u001B[33mDBRX Assistant\u001B[0m (to User):\n\nSure, I can help you with that. We can write a Python script to count the number of prime numbers from 1 to 10000. Here's the script:\n\n```python\n# filename: count_primes.py\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i += 6\n return True\n\ndef count_primes(end):\n count = 0\n for num in range(1, end + 1):\n if is_prime(num):\n count += 1\n return count\n\nprint(count_primes(10000))\n```\n\nThis script first defines a helper function `is_prime(n)` to check if a number `n` is prime. Then, it defines the main function `count_primes(end)` to count the number of prime numbers up to `end`. Finally, it prints the number of prime numbers from 1 to 10000.\n\nTo run the script, save it to a file named `count_primes.py`, and then execute it using the command `python count_primes.py` in a terminal or command prompt. The script will print the number of prime numbers from 1 to 10000.\n\nLet me know if you encounter any issues or errors when running the script.\n\n--------------------------------------------------------------------------------\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "Provide feedback to DBRX Assistant. Press enter to skip and use auto-reply, or type 'exit' to end the conversation: exit" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "from autogen import AssistantAgent, UserProxyAgent\n", "# Setting up the agents.\n", @@ -323,7 +390,16 @@ "title": "" } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "count_primes.py\n" + ] + } + ], "source": [ "%sh ls coding" ] @@ -343,7 +419,16 @@ "title": "" } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "# filename: count_primes.py\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n" + ] + } + ], "source": [ "%sh head coding/count_primes.py" ] @@ -383,7 +468,24 @@ "title": "" } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001B[33mStudent_Agent\u001B[0m (to Teacher_Agent):\n\nHow does deep learning relate to artificial intelligence?\n\n--------------------------------------------------------------------------------\n\u001B[31m\n>>>>>>>> USING AUTO REPLY...\u001B[0m\n\u001B[33mTeacher_Agent\u001B[0m (to Student_Agent):\n\nHello there! I'm glad you asked about the relationship between deep learning and artificial intelligence (AI).\n\nDeep learning is actually a subset of AI, which is a broader field dedicated to creating algorithms and systems that can perform tasks that would normally require human intelligence. Other subsets of AI include rule-based systems, machine learning, natural language processing, and computer vision, among others.\n\nDeep learning, on the other hand, is a specific approach to building AI systems that is inspired by the structure and function of the human brain. In deep learning, we use artificial neural networks, which are composed of interconnected nodes or \"neurons,\" to learn patterns in data and make predictions or decisions without being explicitly programmed to do so.\n\nDeep learning has been particularly successful in recent years due to several factors, including the availability of large amounts of data, powerful computational resources, and advances in neural network architectures and training algorithms. As a result, deep learning has achieved state-of-the-art performance in a wide range of tasks, such as image and speech recognition, natural language processing, and game playing.\n\nSo, in summary, deep learning is a specific approach to building AI systems that has gained a lot of attention in recent years due to its impressive performance on a variety of tasks. However, it is just one of many approaches to building AI systems, and it is important to understand the broader context of AI in order to fully appreciate the potential and limitations of deep learning.\n\n--------------------------------------------------------------------------------\n" + ] + }, + { + "output_type": "stream", + "name": "stderr", + "output_type": "stream", + "text": [ + "/Workspace/Repos/tj.cycyota@databricks.com/autogen/autogen/agentchat/conversable_agent.py:1149: UserWarning: Cannot extract summary using reflection_with_llm: Error code: 400 - {'error_code': 'BAD_REQUEST', 'message': \"Bad request: rpc error: code = InvalidArgument desc = Chat message input must end with a 'user' role\\n\"}. Using an empty str as summary.\n warnings.warn(\n" + ] + } + ], "source": [ "from autogen import ConversableAgent\n", "\n", @@ -522,7 +624,166 @@ "title": "" } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "Logging session ID: 7b8c21ec-d892-47d6-be13-c872bb990f0e\n\u001B[33muser\u001B[0m (to assistant):\n\nWhat is MLflow?\n\n--------------------------------------------------------------------------------\n\u001B[33massistant\u001B[0m (to user):\n\nSure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\n\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\n\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\n```python\n# filename: mlflow_example.py\n\nimport mlflow\nimport numpy as np\n\n# Log a parameter (e.g., number of trees in a random forest)\nmlflow.log_param(\"num_trees\", 100)\n\n# Log a metric (e.g., accuracy of a model)\naccuracy = np.random.rand()\nmlflow.log_metric(\"accuracy\", accuracy)\n\n# Log the model\nmlflow.sklearn.log_model(model, \"model\")\n\n# End the run\nmlflow.end_run()\n```\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\n```\npip install mlflow\n```\nThen, you can run the code using the following command:\n```\npython mlflow_example.py\n```\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\n\nI hope this helps! Let me know if you have any other questions.\n\n--------------------------------------------------------------------------------\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/html": [ + "
idinvocation_idclient_idwrapper_idsession_idrequestresponseis_cachedcoststart_timeend_time
1daa80d02-beeb-475d-a6cb-31256d9615a61404104177720481404104177735847b8c21ec-d892-47d6-be13-c872bb990f0e{\"messages\": [{\"content\": \"You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \\\"TERMINATE\\\" in the end when everything is done.\\n \", \"role\": \"system\"}, {\"content\": \"What is MLflow?\", \"role\": \"user\"}], \"model\": \"databricks-dbrx-instruct\"}{\n", + " \"id\": \"59b5e537-e14a-4afd-9b1f-d046f5372af7\",\n", + " \"choices\": [\n", + " {\n", + " \"finish_reason\": \"stop\",\n", + " \"index\": 0,\n", + " \"logprobs\": null,\n", + " \"message\": {\n", + " \"content\": \"Sure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\\\"num_trees\\\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\\\"accuracy\\\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \\\"model\\\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.\",\n", + " \"role\": \"assistant\",\n", + " \"function_call\": null,\n", + " \"tool_calls\": null\n", + " }\n", + " }\n", + " ],\n", + " \"created\": 1713446636,\n", + " \"model\": \"dbrx-instruct-032724\",\n", + " \"object\": \"chat.completion\",\n", + " \"system_fingerprint\": null,\n", + " \"usage\": {\n", + " \"completion_tokens\": 409,\n", + " \"prompt_tokens\": 478,\n", + " \"total_tokens\": 887\n", + " },\n", + " \"cost\": 0,\n", + " \"message_retrieval_function\": \"def message_retrieval(\\n self, response: Union[ChatCompletion, Completion]\\n ) -> Union[List[str], List[ChatCompletionMessage]]:\\n \\\"\\\"\\\"Retrieve the messages from the response.\\\"\\\"\\\"\\n choices = response.choices\\n if isinstance(response, Completion):\\n return [choice.text for choice in choices] # type: ignore [union-attr]\\n\\n if TOOL_ENABLED:\\n return [ # type: ignore [return-value]\\n (\\n choice.message # type: ignore [union-attr]\\n if choice.message.function_call is not None or choice.message.tool_calls is not None # type: ignore [union-attr]\\n else choice.message.content\\n ) # type: ignore [union-attr]\\n for choice in choices\\n ]\\n else:\\n return [ # type: ignore [return-value]\\n choice.message if choice.message.function_call is not None else choice.message.content # type: ignore [union-attr]\\n for choice in choices\\n ]\"\n", + "}10.02024-04-18 15:17:15.1636622024-04-18 15:17:15.164820
" + ] + }, + "metadata": { + "application/vnd.databricks.v1+output": { + "addedWidgets": {}, + "aggData": [], + "aggError": "", + "aggOverflow": false, + "aggSchema": [], + "aggSeriesLimitReached": false, + "aggType": "", + "arguments": {}, + "columnCustomDisplayInfos": {}, + "data": [ + [ + 1, + "daa80d02-beeb-475d-a6cb-31256d9615a6", + 140410417772048, + 140410417773584, + "7b8c21ec-d892-47d6-be13-c872bb990f0e", + "{\"messages\": [{\"content\": \"You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \\\"TERMINATE\\\" in the end when everything is done.\\n \", \"role\": \"system\"}, {\"content\": \"What is MLflow?\", \"role\": \"user\"}], \"model\": \"databricks-dbrx-instruct\"}", + "{\n \"id\": \"59b5e537-e14a-4afd-9b1f-d046f5372af7\",\n \"choices\": [\n {\n \"finish_reason\": \"stop\",\n \"index\": 0,\n \"logprobs\": null,\n \"message\": {\n \"content\": \"Sure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\\\"num_trees\\\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\\\"accuracy\\\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \\\"model\\\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.\",\n \"role\": \"assistant\",\n \"function_call\": null,\n \"tool_calls\": null\n }\n }\n ],\n \"created\": 1713446636,\n \"model\": \"dbrx-instruct-032724\",\n \"object\": \"chat.completion\",\n \"system_fingerprint\": null,\n \"usage\": {\n \"completion_tokens\": 409,\n \"prompt_tokens\": 478,\n \"total_tokens\": 887\n },\n \"cost\": 0,\n \"message_retrieval_function\": \"def message_retrieval(\\n self, response: Union[ChatCompletion, Completion]\\n ) -> Union[List[str], List[ChatCompletionMessage]]:\\n \\\"\\\"\\\"Retrieve the messages from the response.\\\"\\\"\\\"\\n choices = response.choices\\n if isinstance(response, Completion):\\n return [choice.text for choice in choices] # type: ignore [union-attr]\\n\\n if TOOL_ENABLED:\\n return [ # type: ignore [return-value]\\n (\\n choice.message # type: ignore [union-attr]\\n if choice.message.function_call is not None or choice.message.tool_calls is not None # type: ignore [union-attr]\\n else choice.message.content\\n ) # type: ignore [union-attr]\\n for choice in choices\\n ]\\n else:\\n return [ # type: ignore [return-value]\\n choice.message if choice.message.function_call is not None else choice.message.content # type: ignore [union-attr]\\n for choice in choices\\n ]\"\n}", + 1, + 0.0, + "2024-04-18 15:17:15.163662", + "2024-04-18 15:17:15.164820" + ] + ], + "datasetInfos": [], + "dbfsResultPath": null, + "isJsonSchema": true, + "metadata": {}, + "overflow": false, + "plotOptions": { + "customPlotOptions": {}, + "displayType": "table", + "pivotAggregation": null, + "pivotColumns": null, + "xColumns": null, + "yColumns": null + }, + "removedWidgets": [], + "schema": [ + { + "metadata": "{}", + "name": "id", + "type": "\"long\"" + }, + { + "metadata": "{}", + "name": "invocation_id", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "client_id", + "type": "\"long\"" + }, + { + "metadata": "{}", + "name": "wrapper_id", + "type": "\"long\"" + }, + { + "metadata": "{}", + "name": "session_id", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "request", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "response", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "is_cached", + "type": "\"long\"" + }, + { + "metadata": "{}", + "name": "cost", + "type": "\"double\"" + }, + { + "metadata": "{}", + "name": "start_time", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "end_time", + "type": "\"string\"" + } + ], + "type": "table" + } + }, + "output_type": "display_data" + } + ], "source": [ "assistant = autogen.AssistantAgent(name=\"assistant\", llm_config=llm_config)\n", "user_proxy = autogen.UserProxyAgent(name=\"user\", code_execution_config=False)\n", @@ -576,7 +837,244 @@ "title": "" } }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "output_type": "stream", + "text": [ + "Logs sucessfully written to table shared.tjc.autogent_logs in append mode\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/html": [ + "
idinvocation_idclient_idwrapper_idsession_idrequestresponseis_cachedcoststart_timeend_time
71f970a66-05e9-40bb-bb82-4a517bf9255f1404104494122081404104496182720707ff11-f65e-4d4e-8993-499be5716bf8{\"messages\": [{\"content\": \"You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \\\"TERMINATE\\\" in the end when everything is done.\\n \", \"role\": \"system\"}, {\"content\": \"What is MLflow?\", \"role\": \"user\"}], \"model\": \"databricks-dbrx-instruct\"}{\n", + " \"id\": \"59b5e537-e14a-4afd-9b1f-d046f5372af7\",\n", + " \"choices\": [\n", + " {\n", + " \"finish_reason\": \"stop\",\n", + " \"index\": 0,\n", + " \"logprobs\": null,\n", + " \"message\": {\n", + " \"content\": \"Sure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\\\"num_trees\\\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\\\"accuracy\\\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \\\"model\\\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.\",\n", + " \"role\": \"assistant\",\n", + " \"function_call\": null,\n", + " \"tool_calls\": null\n", + " }\n", + " }\n", + " ],\n", + " \"created\": 1713446636,\n", + " \"model\": \"dbrx-instruct-032724\",\n", + " \"object\": \"chat.completion\",\n", + " \"system_fingerprint\": null,\n", + " \"usage\": {\n", + " \"completion_tokens\": 409,\n", + " \"prompt_tokens\": 478,\n", + " \"total_tokens\": 887\n", + " },\n", + " \"cost\": 0,\n", + " \"message_retrieval_function\": \"def message_retrieval(\\n self, response: Union[ChatCompletion, Completion]\\n ) -> Union[List[str], List[ChatCompletionMessage]]:\\n \\\"\\\"\\\"Retrieve the messages from the response.\\\"\\\"\\\"\\n choices = response.choices\\n if isinstance(response, Completion):\\n return [choice.text for choice in choices] # type: ignore [union-attr]\\n\\n if TOOL_ENABLED:\\n return [ # type: ignore [return-value]\\n (\\n choice.message # type: ignore [union-attr]\\n if choice.message.function_call is not None or choice.message.tool_calls is not None # type: ignore [union-attr]\\n else choice.message.content\\n ) # type: ignore [union-attr]\\n for choice in choices\\n ]\\n else:\\n return [ # type: ignore [return-value]\\n choice.message if choice.message.function_call is not None else choice.message.content # type: ignore [union-attr]\\n for choice in choices\\n ]\"\n", + "}10.02024-04-18 15:08:45.3876732024-04-18 15:08:45.388880
6716ca620-bf76-464c-940a-2a1e382a0fb414011164919515214011165042496018b0040c-68f9-4aa8-b3a8-deba1e8cead5{\"messages\": [{\"content\": \"You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \\\"TERMINATE\\\" in the end when everything is done.\\n \", \"role\": \"system\"}, {\"content\": \"What is MLflow?\", \"role\": \"user\"}], \"model\": \"databricks-dbrx-instruct\"}{\n", + " \"id\": \"59b5e537-e14a-4afd-9b1f-d046f5372af7\",\n", + " \"choices\": [\n", + " {\n", + " \"finish_reason\": \"stop\",\n", + " \"index\": 0,\n", + " \"logprobs\": null,\n", + " \"message\": {\n", + " \"content\": \"Sure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\\\"num_trees\\\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\\\"accuracy\\\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \\\"model\\\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.\",\n", + " \"role\": \"assistant\",\n", + " \"function_call\": null,\n", + " \"tool_calls\": null\n", + " }\n", + " }\n", + " ],\n", + " \"created\": 1713446636,\n", + " \"model\": \"dbrx-instruct-032724\",\n", + " \"object\": \"chat.completion\",\n", + " \"system_fingerprint\": null,\n", + " \"usage\": {\n", + " \"completion_tokens\": 409,\n", + " \"prompt_tokens\": 478,\n", + " \"total_tokens\": 887\n", + " },\n", + " \"cost\": 0,\n", + " \"message_retrieval_function\": \"def message_retrieval(\\n self, response: Union[ChatCompletion, Completion]\\n ) -> Union[List[str], List[ChatCompletionMessage]]:\\n \\\"\\\"\\\"Retrieve the messages from the response.\\\"\\\"\\\"\\n choices = response.choices\\n if isinstance(response, Completion):\\n return [choice.text for choice in choices] # type: ignore [union-attr]\\n\\n if TOOL_ENABLED:\\n return [ # type: ignore [return-value]\\n (\\n choice.message # type: ignore [union-attr]\\n if choice.message.function_call is not None or choice.message.tool_calls is not None # type: ignore [union-attr]\\n else choice.message.content\\n ) # type: ignore [union-attr]\\n for choice in choices\\n ]\\n else:\\n return [ # type: ignore [return-value]\\n choice.message if choice.message.function_call is not None else choice.message.content # type: ignore [union-attr]\\n for choice in choices\\n ]\"\n", + "}10.02024-04-18 15:03:59.6506932024-04-18 15:03:59.652671
5b070b6f8-5f70-4b78-9521-f7686dd7da321401116547108801401116547504805171cdf8-0c98-4187-94d5-33de3a165054{\"messages\": [{\"content\": \"You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \\\"TERMINATE\\\" in the end when everything is done.\\n \", \"role\": \"system\"}, {\"content\": \"What is MLflow?\", \"role\": \"user\"}], \"model\": \"databricks-dbrx-instruct\"}{\n", + " \"id\": \"59b5e537-e14a-4afd-9b1f-d046f5372af7\",\n", + " \"choices\": [\n", + " {\n", + " \"finish_reason\": \"stop\",\n", + " \"index\": 0,\n", + " \"logprobs\": null,\n", + " \"message\": {\n", + " \"content\": \"Sure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\\\"num_trees\\\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\\\"accuracy\\\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \\\"model\\\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.\",\n", + " \"role\": \"assistant\",\n", + " \"function_call\": null,\n", + " \"tool_calls\": null\n", + " }\n", + " }\n", + " ],\n", + " \"created\": 1713446636,\n", + " \"model\": \"dbrx-instruct-032724\",\n", + " \"object\": \"chat.completion\",\n", + " \"system_fingerprint\": null,\n", + " \"usage\": {\n", + " \"completion_tokens\": 409,\n", + " \"prompt_tokens\": 478,\n", + " \"total_tokens\": 887\n", + " },\n", + " \"cost\": 0,\n", + " \"message_retrieval_function\": \"def message_retrieval(\\n self, response: Union[ChatCompletion, Completion]\\n ) -> Union[List[str], List[ChatCompletionMessage]]:\\n \\\"\\\"\\\"Retrieve the messages from the response.\\\"\\\"\\\"\\n choices = response.choices\\n if isinstance(response, Completion):\\n return [choice.text for choice in choices] # type: ignore [union-attr]\\n\\n if TOOL_ENABLED:\\n return [ # type: ignore [return-value]\\n (\\n choice.message # type: ignore [union-attr]\\n if choice.message.function_call is not None or choice.message.tool_calls is not None # type: ignore [union-attr]\\n else choice.message.content\\n ) # type: ignore [union-attr]\\n for choice in choices\\n ]\\n else:\\n return [ # type: ignore [return-value]\\n choice.message if choice.message.function_call is not None else choice.message.content # type: ignore [union-attr]\\n for choice in choices\\n ]\"\n", + "}10.02024-04-18 15:02:36.0580462024-04-18 15:02:36.060058
" + ] + }, + "metadata": { + "application/vnd.databricks.v1+output": { + "addedWidgets": {}, + "aggData": [], + "aggError": "", + "aggOverflow": false, + "aggSchema": [], + "aggSeriesLimitReached": false, + "aggType": "", + "arguments": {}, + "columnCustomDisplayInfos": {}, + "data": [ + [ + 7, + "1f970a66-05e9-40bb-bb82-4a517bf9255f", + 140410449412208, + 140410449618272, + "0707ff11-f65e-4d4e-8993-499be5716bf8", + "{\"messages\": [{\"content\": \"You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \\\"TERMINATE\\\" in the end when everything is done.\\n \", \"role\": \"system\"}, {\"content\": \"What is MLflow?\", \"role\": \"user\"}], \"model\": \"databricks-dbrx-instruct\"}", + "{\n \"id\": \"59b5e537-e14a-4afd-9b1f-d046f5372af7\",\n \"choices\": [\n {\n \"finish_reason\": \"stop\",\n \"index\": 0,\n \"logprobs\": null,\n \"message\": {\n \"content\": \"Sure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\\\"num_trees\\\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\\\"accuracy\\\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \\\"model\\\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.\",\n \"role\": \"assistant\",\n \"function_call\": null,\n \"tool_calls\": null\n }\n }\n ],\n \"created\": 1713446636,\n \"model\": \"dbrx-instruct-032724\",\n \"object\": \"chat.completion\",\n \"system_fingerprint\": null,\n \"usage\": {\n \"completion_tokens\": 409,\n \"prompt_tokens\": 478,\n \"total_tokens\": 887\n },\n \"cost\": 0,\n \"message_retrieval_function\": \"def message_retrieval(\\n self, response: Union[ChatCompletion, Completion]\\n ) -> Union[List[str], List[ChatCompletionMessage]]:\\n \\\"\\\"\\\"Retrieve the messages from the response.\\\"\\\"\\\"\\n choices = response.choices\\n if isinstance(response, Completion):\\n return [choice.text for choice in choices] # type: ignore [union-attr]\\n\\n if TOOL_ENABLED:\\n return [ # type: ignore [return-value]\\n (\\n choice.message # type: ignore [union-attr]\\n if choice.message.function_call is not None or choice.message.tool_calls is not None # type: ignore [union-attr]\\n else choice.message.content\\n ) # type: ignore [union-attr]\\n for choice in choices\\n ]\\n else:\\n return [ # type: ignore [return-value]\\n choice.message if choice.message.function_call is not None else choice.message.content # type: ignore [union-attr]\\n for choice in choices\\n ]\"\n}", + 1, + 0.0, + "2024-04-18 15:08:45.387673", + "2024-04-18 15:08:45.388880" + ], + [ + 6, + "716ca620-bf76-464c-940a-2a1e382a0fb4", + 140111649195152, + 140111650424960, + "18b0040c-68f9-4aa8-b3a8-deba1e8cead5", + "{\"messages\": [{\"content\": \"You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \\\"TERMINATE\\\" in the end when everything is done.\\n \", \"role\": \"system\"}, {\"content\": \"What is MLflow?\", \"role\": \"user\"}], \"model\": \"databricks-dbrx-instruct\"}", + "{\n \"id\": \"59b5e537-e14a-4afd-9b1f-d046f5372af7\",\n \"choices\": [\n {\n \"finish_reason\": \"stop\",\n \"index\": 0,\n \"logprobs\": null,\n \"message\": {\n \"content\": \"Sure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\\\"num_trees\\\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\\\"accuracy\\\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \\\"model\\\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.\",\n \"role\": \"assistant\",\n \"function_call\": null,\n \"tool_calls\": null\n }\n }\n ],\n \"created\": 1713446636,\n \"model\": \"dbrx-instruct-032724\",\n \"object\": \"chat.completion\",\n \"system_fingerprint\": null,\n \"usage\": {\n \"completion_tokens\": 409,\n \"prompt_tokens\": 478,\n \"total_tokens\": 887\n },\n \"cost\": 0,\n \"message_retrieval_function\": \"def message_retrieval(\\n self, response: Union[ChatCompletion, Completion]\\n ) -> Union[List[str], List[ChatCompletionMessage]]:\\n \\\"\\\"\\\"Retrieve the messages from the response.\\\"\\\"\\\"\\n choices = response.choices\\n if isinstance(response, Completion):\\n return [choice.text for choice in choices] # type: ignore [union-attr]\\n\\n if TOOL_ENABLED:\\n return [ # type: ignore [return-value]\\n (\\n choice.message # type: ignore [union-attr]\\n if choice.message.function_call is not None or choice.message.tool_calls is not None # type: ignore [union-attr]\\n else choice.message.content\\n ) # type: ignore [union-attr]\\n for choice in choices\\n ]\\n else:\\n return [ # type: ignore [return-value]\\n choice.message if choice.message.function_call is not None else choice.message.content # type: ignore [union-attr]\\n for choice in choices\\n ]\"\n}", + 1, + 0.0, + "2024-04-18 15:03:59.650693", + "2024-04-18 15:03:59.652671" + ], + [ + 5, + "b070b6f8-5f70-4b78-9521-f7686dd7da32", + 140111654710880, + 140111654750480, + "5171cdf8-0c98-4187-94d5-33de3a165054", + "{\"messages\": [{\"content\": \"You are a helpful AI assistant.\\nSolve tasks using your coding and language skills.\\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user.\\nIf you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user.\\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\\nReply \\\"TERMINATE\\\" in the end when everything is done.\\n \", \"role\": \"system\"}, {\"content\": \"What is MLflow?\", \"role\": \"user\"}], \"model\": \"databricks-dbrx-instruct\"}", + "{\n \"id\": \"59b5e537-e14a-4afd-9b1f-d046f5372af7\",\n \"choices\": [\n {\n \"finish_reason\": \"stop\",\n \"index\": 0,\n \"logprobs\": null,\n \"message\": {\n \"content\": \"Sure, I'd be happy to explain MLflow to you. MLflow is an open-source platform for managing machine learning workflows. It was developed by Databricks and was open-sourced in 2018. MLflow provides a number of features to help data scientists and machine learning engineers manage the end-to-end machine learning lifecycle, including:\\n\\n1. **MLflow Tracking**: This is a logging API that allows you to record and query experiments, including code, data, config, and results.\\n2. **MLflow Projects**: This is a format for packaging reusable and reproducible data science code, which can be run on different platforms.\\n3. **MLflow Models**: This is a convention for packaging machine learning models in multiple formats, making it easy to deploy in different environments.\\n4. **MLflow Model Registry**: This is a central repository to store, manage, and serve machine learning models.\\n\\nHere is a Python code example of how you might use MLflow Tracking to log a simple experiment:\\n```python\\n# filename: mlflow_example.py\\n\\nimport mlflow\\nimport numpy as np\\n\\n# Log a parameter (e.g., number of trees in a random forest)\\nmlflow.log_param(\\\"num_trees\\\", 100)\\n\\n# Log a metric (e.g., accuracy of a model)\\naccuracy = np.random.rand()\\nmlflow.log_metric(\\\"accuracy\\\", accuracy)\\n\\n# Log the model\\nmlflow.sklearn.log_model(model, \\\"model\\\")\\n\\n# End the run\\nmlflow.end_run()\\n```\\nTo run this code, you would need to have MLflow installed and running on your machine. You can install MLflow using pip:\\n```\\npip install mlflow\\n```\\nThen, you can run the code using the following command:\\n```\\npython mlflow_example.py\\n```\\nThis will create a new experiment in MLflow and log the parameters, metrics, and model. You can then view the experiment in the MLflow UI.\\n\\nI hope this helps! Let me know if you have any other questions.\",\n \"role\": \"assistant\",\n \"function_call\": null,\n \"tool_calls\": null\n }\n }\n ],\n \"created\": 1713446636,\n \"model\": \"dbrx-instruct-032724\",\n \"object\": \"chat.completion\",\n \"system_fingerprint\": null,\n \"usage\": {\n \"completion_tokens\": 409,\n \"prompt_tokens\": 478,\n \"total_tokens\": 887\n },\n \"cost\": 0,\n \"message_retrieval_function\": \"def message_retrieval(\\n self, response: Union[ChatCompletion, Completion]\\n ) -> Union[List[str], List[ChatCompletionMessage]]:\\n \\\"\\\"\\\"Retrieve the messages from the response.\\\"\\\"\\\"\\n choices = response.choices\\n if isinstance(response, Completion):\\n return [choice.text for choice in choices] # type: ignore [union-attr]\\n\\n if TOOL_ENABLED:\\n return [ # type: ignore [return-value]\\n (\\n choice.message # type: ignore [union-attr]\\n if choice.message.function_call is not None or choice.message.tool_calls is not None # type: ignore [union-attr]\\n else choice.message.content\\n ) # type: ignore [union-attr]\\n for choice in choices\\n ]\\n else:\\n return [ # type: ignore [return-value]\\n choice.message if choice.message.function_call is not None else choice.message.content # type: ignore [union-attr]\\n for choice in choices\\n ]\"\n}", + 1, + 0.0, + "2024-04-18 15:02:36.058046", + "2024-04-18 15:02:36.060058" + ] + ], + "datasetInfos": [], + "dbfsResultPath": null, + "isJsonSchema": true, + "metadata": {}, + "overflow": false, + "plotOptions": { + "customPlotOptions": {}, + "displayType": "table", + "pivotAggregation": null, + "pivotColumns": null, + "xColumns": null, + "yColumns": null + }, + "removedWidgets": [], + "schema": [ + { + "metadata": "{}", + "name": "id", + "type": "\"long\"" + }, + { + "metadata": "{}", + "name": "invocation_id", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "client_id", + "type": "\"long\"" + }, + { + "metadata": "{}", + "name": "wrapper_id", + "type": "\"long\"" + }, + { + "metadata": "{}", + "name": "session_id", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "request", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "response", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "is_cached", + "type": "\"long\"" + }, + { + "metadata": "{}", + "name": "cost", + "type": "\"double\"" + }, + { + "metadata": "{}", + "name": "start_time", + "type": "\"string\"" + }, + { + "metadata": "{}", + "name": "end_time", + "type": "\"string\"" + } + ], + "type": "table" + } + }, + "output_type": "display_data" + } + ], "source": [ "# Use 3-layer namespace: catalog.schema.table. The table will be created if it does not exist.\n", "target_delta_table = \"your_catalog.your_schema.autogen_logs\"\n",