|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": { |
| 6 | + "id": "0kA97_xH6hlx" |
| 7 | + }, |
| 8 | + "source": [ |
| 9 | + "# Readme Ready Example" |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "markdown", |
| 14 | + "metadata": {}, |
| 15 | + "source": [ |
| 16 | + "## Install Readme Ready" |
| 17 | + ] |
| 18 | + }, |
| 19 | + { |
| 20 | + "cell_type": "code", |
| 21 | + "execution_count": null, |
| 22 | + "metadata": { |
| 23 | + "colab": { |
| 24 | + "base_uri": "https://localhost:8080/" |
| 25 | + }, |
| 26 | + "id": "Q2mrR0s6-hfi", |
| 27 | + "outputId": "e816aa5a-8953-49b8-d5f8-37e3ac9b2206" |
| 28 | + }, |
| 29 | + "outputs": [], |
| 30 | + "source": [ |
| 31 | + "%pip install -U readme-ready huggingface_hub" |
| 32 | + ] |
| 33 | + }, |
| 34 | + { |
| 35 | + "cell_type": "markdown", |
| 36 | + "metadata": {}, |
| 37 | + "source": [ |
| 38 | + "## Set environment variables" |
| 39 | + ] |
| 40 | + }, |
| 41 | + { |
| 42 | + "cell_type": "code", |
| 43 | + "execution_count": null, |
| 44 | + "metadata": { |
| 45 | + "colab": { |
| 46 | + "base_uri": "https://localhost:8080/" |
| 47 | + }, |
| 48 | + "id": "SanQ25iEb5My", |
| 49 | + "outputId": "a0bf97d4-1548-4f2f-aac7-e4e0c37237d5" |
| 50 | + }, |
| 51 | + "outputs": [], |
| 52 | + "source": [ |
| 53 | + "import os\n", |
| 54 | + "from huggingface_hub import login\n", |
| 55 | + "HF_TOKEN = \"hf_fake_token\" # replace with your Hugging Face token\n", |
| 56 | + "OPENAI_API_KEY = \"fake_openai_api_key\" # replace with your OpenAI API key\n", |
| 57 | + "os.environ[\"OPENAI_API_KEY\"] = OPENAI_API_KEY\n", |
| 58 | + "os.environ[\"HF_TOKEN\"] = HF_TOKEN\n", |
| 59 | + "login(token=HF_TOKEN, add_to_git_credential=False)" |
| 60 | + ] |
| 61 | + }, |
| 62 | + { |
| 63 | + "cell_type": "markdown", |
| 64 | + "metadata": {}, |
| 65 | + "source": [ |
| 66 | + "## Download a sample repository" |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "code", |
| 71 | + "execution_count": null, |
| 72 | + "metadata": { |
| 73 | + "colab": { |
| 74 | + "base_uri": "https://localhost:8080/" |
| 75 | + }, |
| 76 | + "id": "MnYd5wo3lURX", |
| 77 | + "outputId": "e1536c6f-529e-4d01-c7ce-dadd8d0a6ef7" |
| 78 | + }, |
| 79 | + "outputs": [], |
| 80 | + "source": [ |
| 81 | + "!git clone https://github.com/eth-siplab/TouchPose.git" |
| 82 | + ] |
| 83 | + }, |
| 84 | + { |
| 85 | + "cell_type": "code", |
| 86 | + "execution_count": 5, |
| 87 | + "metadata": { |
| 88 | + "id": "4YuGtYkBaUbf" |
| 89 | + }, |
| 90 | + "outputs": [], |
| 91 | + "source": [ |
| 92 | + "!rm -rf ./TouchPose/.gitignore\n", |
| 93 | + "!rm -rf ./TouchPose/.git\n", |
| 94 | + "!rm -rf ./TouchPose/README.md" |
| 95 | + ] |
| 96 | + }, |
| 97 | + { |
| 98 | + "cell_type": "markdown", |
| 99 | + "metadata": {}, |
| 100 | + "source": [ |
| 101 | + "## Generate README of the sample repository" |
| 102 | + ] |
| 103 | + }, |
| 104 | + { |
| 105 | + "cell_type": "code", |
| 106 | + "execution_count": null, |
| 107 | + "metadata": { |
| 108 | + "colab": { |
| 109 | + "base_uri": "https://localhost:8080/", |
| 110 | + "height": 350 |
| 111 | + }, |
| 112 | + "id": "Jc-mYnTpOEwl", |
| 113 | + "outputId": "60eeffc4-680a-44cf-96a4-97a9ce4cf39b" |
| 114 | + }, |
| 115 | + "outputs": [], |
| 116 | + "source": [ |
| 117 | + "\"\"\"\n", |
| 118 | + "Example\n", |
| 119 | + "\"\"\"\n", |
| 120 | + "from readme_ready.query import query\n", |
| 121 | + "from readme_ready.index import index\n", |
| 122 | + "from readme_ready.types import (\n", |
| 123 | + " AutodocReadmeConfig,\n", |
| 124 | + " AutodocRepoConfig,\n", |
| 125 | + " AutodocUserConfig,\n", |
| 126 | + " LLMModels,\n", |
| 127 | + ")\n", |
| 128 | + "\n", |
| 129 | + "# Choose model from supported models\n", |
| 130 | + "model = LLMModels.LLAMA2_7B_CHAT_GPTQ\n", |
| 131 | + "\n", |
| 132 | + "# Initialize the repository configuration. `root` refers to the path to the\n", |
| 133 | + "# code repository for which you want to generate a README for. Please download\n", |
| 134 | + "# any code repository from GitHub and use that or if you have your own\n", |
| 135 | + "# repository downloaded (say 'MyRepo') you can use that as well.\n", |
| 136 | + "# Set `name` to the 'MyRepo'.\n", |
| 137 | + "# Set `root` as <path to 'MyRepo'>.\n", |
| 138 | + "# Set `repository_url` to the GitHub URL of 'MyRepo' (if any) else leave blank.\n", |
| 139 | + "# Set `output` as the path to the directory where the README and other metadata\n", |
| 140 | + "# will be generated and saved.\n", |
| 141 | + "# Set other parameters accordingly (or leave as default).\n", |
| 142 | + "\n", |
| 143 | + "repo_config = AutodocRepoConfig (\n", |
| 144 | + " name = \"TouchPose\", # Set repository name\n", |
| 145 | + " root = \"./TouchPose\", # Set path to root directory of the repository\n", |
| 146 | + " repository_url = \"https://github.com/eth-siplab/TouchPose\", # Set url\n", |
| 147 | + " output = \"./output/TouchPose\", # Set path to output directory to save\n", |
| 148 | + " llms = [model],\n", |
| 149 | + " peft_model_path = None, # Set path to PEFT model\n", |
| 150 | + " ignore = [\n", |
| 151 | + " \".*\",\n", |
| 152 | + " \"*package-lock.json\",\n", |
| 153 | + " \"*package.json\",\n", |
| 154 | + " \"node_modules\",\n", |
| 155 | + " \"*dist*\",\n", |
| 156 | + " \"*build*\",\n", |
| 157 | + " \"*test*\",\n", |
| 158 | + " \"*.svg\",\n", |
| 159 | + " \"*.md\",\n", |
| 160 | + " \"*.mdx\",\n", |
| 161 | + " \"*.toml\"\n", |
| 162 | + " ],\n", |
| 163 | + " file_prompt = \"\",\n", |
| 164 | + " folder_prompt = \"\",\n", |
| 165 | + " chat_prompt = \"\",\n", |
| 166 | + " content_type = \"docs\",\n", |
| 167 | + " target_audience = \"smart developer\",\n", |
| 168 | + " link_hosted = True,\n", |
| 169 | + " priority = None,\n", |
| 170 | + " max_concurrent_calls = 50,\n", |
| 171 | + " add_questions = False,\n", |
| 172 | + " device = \"auto\", # Select device \"cpu\" or \"auto\"\n", |
| 173 | + ")\n", |
| 174 | + "\n", |
| 175 | + "user_config = AutodocUserConfig(\n", |
| 176 | + " llms = [model]\n", |
| 177 | + ")\n", |
| 178 | + "\n", |
| 179 | + "readme_config = AutodocReadmeConfig(\n", |
| 180 | + " # Set comma separated list of README headings\n", |
| 181 | + " headings = \"Description\"\n", |
| 182 | + ")\n", |
| 183 | + "\n", |
| 184 | + "index.index(repo_config)\n", |
| 185 | + "query.generate_readme(repo_config, user_config, readme_config)" |
| 186 | + ] |
| 187 | + } |
| 188 | + ], |
| 189 | + "metadata": { |
| 190 | + "accelerator": "GPU", |
| 191 | + "colab": { |
| 192 | + "collapsed_sections": [ |
| 193 | + "7B3jLeQxcaPe" |
| 194 | + ], |
| 195 | + "gpuType": "T4", |
| 196 | + "provenance": [] |
| 197 | + }, |
| 198 | + "kernelspec": { |
| 199 | + "display_name": "gym", |
| 200 | + "language": "python", |
| 201 | + "name": "python3" |
| 202 | + }, |
| 203 | + "language_info": { |
| 204 | + "codemirror_mode": { |
| 205 | + "name": "ipython", |
| 206 | + "version": 3 |
| 207 | + }, |
| 208 | + "file_extension": ".py", |
| 209 | + "mimetype": "text/x-python", |
| 210 | + "name": "python", |
| 211 | + "nbconvert_exporter": "python", |
| 212 | + "pygments_lexer": "ipython3", |
| 213 | + "version": "3.11.9" |
| 214 | + } |
| 215 | + }, |
| 216 | + "nbformat": 4, |
| 217 | + "nbformat_minor": 0 |
| 218 | +} |
0 commit comments