{ "cells": [ { "metadata": {}, "cell_type": "markdown", "source": [ "### How to run\n", "\n", "* Install libraries using the cell below (for grazie-api-gateway-client you will have to add a custom JB repository)\n", "* Put the production prompt to file `data/prod_prompt.txt`\n", "* Environment variables:\n", " - `GRAZIE_API_JWT_TOKEN` -- JWT token for grazie (check `api_wrappers/grazie_wrapper.py` to adjust the client initialization if necessary)\n", " - `HF_TOKEN` -- should _not_ be required; however, if it is, set it to a valid Hugging Face token" ], "id": "77d51d55b41735cf" }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-20T16:09:07.968406Z", "start_time": "2024-06-20T16:09:07.955405Z" } }, "cell_type": "code", "source": [ "# !pip install grazie-api-gateway-client\n", "# !pip install tqdm\n", "# !pip install pandas\n", "# !pip install datasets" ], "id": "91fa273e8987f6f6", "outputs": [], "execution_count": 1 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-20T16:09:10.353479Z", "start_time": "2024-06-20T16:09:07.970405Z" } }, "cell_type": "code", "source": [ "from api_wrappers.grazie_wrapper import generate_for_prompt\n", "from api_wrappers.hf_data_loader import load_full_commit_with_predictions_as_pandas\n", "from tqdm import tqdm\n", "\n", "tqdm.pandas()" ], "id": "ce11a4c781c152e", "outputs": [], "execution_count": 2 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-20T16:09:10.368996Z", "start_time": "2024-06-20T16:09:10.354434Z" } }, "cell_type": "code", "source": [ "with open(\"data/prod_prompt.txt\") as f:\n", "\tPROD_PROMPT = f.read().strip()\n", "\n", "def prod_prompt(diff):\n", "\treturn PROD_PROMPT.replace(\"$diff\", diff).replace(\"$text\", \"\")\n", "\n", "def generate_commit_message_prod(diff):\n", "\treturn generate_for_prompt(prod_prompt(diff))" ], "id": "84a769c8765a7b64", "outputs": [], "execution_count": 3 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-20T16:09:10.384590Z", "start_time": "2024-06-20T16:09:10.371410Z" } }, "cell_type": "code", "source": "generate_commit_message_prod(\"TEST\")", "id": "af2f20def94b0490", "outputs": [ { "data": { "text/plain": [ "\"Certainly! I'll need to see the specific code differences (diffs) you would like to have summarized into a commit message. Please provide the diffs so I can assist you properly.\"" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 4 }, { "metadata": { "ExecuteTime": { "end_time": "2024-06-20T16:09:22.224167Z", "start_time": "2024-06-20T16:09:10.388409Z" } }, "cell_type": "code", "source": [ "DATA = load_full_commit_with_predictions_as_pandas()[[\"mods\", \"prediction\"]].rename(columns={\"mods\": \"diff\", \"prediction\": \"prediction_current\"})\n", "DATA.head()" ], "id": "a49cabf576c9d692", "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Using the latest cached version of the dataset since JetBrains-Research/lca-commit-message-generation couldn't be found on the Hugging Face Hub\n", "Found the latest cached dataset configuration 'commitchronicle-py-long' at cache\\JetBrains-Research___lca-commit-message-generation\\commitchronicle-py-long\\0.0.0\\58dcef83a63cccebacd3e786afd73181cc9175e5 (last modified on Sun Apr 7 11:16:22 2024).\n", "Using the latest cached version of the dataset since JetBrains-Research/lca-results couldn't be found on the Hugging Face Hub\n", "Found the latest cached dataset configuration 'cmg_gpt_4_0613' at cache\\JetBrains-Research___lca-results\\cmg_gpt_4_0613\\0.0.0\\4b56bbf7243da371b3e0a42a0c9db1f37af98c39 (last modified on Fri May 31 16:00:33 2024).\n" ] }, { "data": { "text/plain": [ " diff \\\n", "0 [{'change_type': 'MODIFY', 'old_path': 'cupy/c... \n", "1 [{'change_type': 'MODIFY', 'old_path': 'tests/... \n", "2 [{'change_type': 'MODIFY', 'old_path': 'numpy/... \n", "3 [{'change_type': 'MODIFY', 'old_path': 'numpy/... \n", "4 [{'change_type': 'MODIFY', 'old_path': 'numpy/... \n", "\n", " prediction_current \n", "0 Extend memory management to consider CUDA stre... \n", "1 Implement utility methods for parameterized te... \n", "2 Update numpy function imports to use numpy as ... \n", "3 Switch to using internal implementation method... \n", "4 Add type hints and refine array API wrappers\\n... " ], "text/html": [ "
\n", " | diff | \n", "prediction_current | \n", "
---|---|---|
0 | \n", "[{'change_type': 'MODIFY', 'old_path': 'cupy/c... | \n", "Extend memory management to consider CUDA stre... | \n", "
1 | \n", "[{'change_type': 'MODIFY', 'old_path': 'tests/... | \n", "Implement utility methods for parameterized te... | \n", "
2 | \n", "[{'change_type': 'MODIFY', 'old_path': 'numpy/... | \n", "Update numpy function imports to use numpy as ... | \n", "
3 | \n", "[{'change_type': 'MODIFY', 'old_path': 'numpy/... | \n", "Switch to using internal implementation method... | \n", "
4 | \n", "[{'change_type': 'MODIFY', 'old_path': 'numpy/... | \n", "Add type hints and refine array API wrappers\\n... | \n", "