{"id":16101481,"url":"https://github.com/mendhak/llm-cli-helper","last_synced_at":"2025-03-18T07:31:30.384Z","repository":{"id":181395975,"uuid":"666692622","full_name":"mendhak/llm-cli-helper","owner":"mendhak","description":"CLI helper tool to lookup commands based on a description","archived":false,"fork":false,"pushed_at":"2023-08-01T19:48:08.000Z","size":76,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T08:17:10.936Z","etag":null,"topics":["assistant","cli","gpt","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mendhak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-15T08:58:11.000Z","updated_at":"2024-12-12T17:47:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"da0291b0-e4a7-47d6-b58f-367c95a7e82e","html_url":"https://github.com/mendhak/llm-cli-helper","commit_stats":null,"previous_names":["mendhak/gpt-cli-helper","mendhak/llm-cli-helper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2Fllm-cli-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2Fllm-cli-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2Fllm-cli-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mendhak%2Fllm-cli-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mendhak","download_url":"https://codeload.github.com/mendhak/llm-cli-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243910814,"owners_count":20367545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assistant","cli","gpt","ubuntu"],"created_at":"2024-10-09T18:50:03.393Z","updated_at":"2025-03-18T07:31:28.860Z","avatar_url":"https://github.com/mendhak.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nA basic CLI lookup tool. Describe a bash command and it outputs sample line(s) by quering LLMs. It can make use of OpenAI (GPT 3.5) or Llama.cpp models.  \n\n![example](example.gif)\n\n## Usage\n\nTry a few commands\n\n```bash\n$ ? how much disk space \n\ndf -h\n\n$ ? show top processes by CPU usage\n\ntop -o %CPU\n\n```\n\nThere is a history, so the next question can be a follow up.  Example:\n\n```bash\n$ ? find .pickle files in this directory\n\nfind . -type f -name \"*.pickle\"\n\n$ ? delete them\n\nfind . -type f -name \"*.pickle\" -delete\n```\n\n\nAnother example, I didn't like the first output so asked for nc instead.\n\n```bash \n$ ? check if port 443 on example.com is open\n\necho | telnet example.com 443\n\n$ ? using nc\n\nnc -zv example.com 443\n```\n\n## Set up\n\nSet up dependencies\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n```\n\nMake a copy of the `.env.sample` file and call it `.env`\n\n## OpenAI setup (simple)\n\nGet an API key from your [OpenAI account](https://platform.openai.com/account/api-keys). Place it in the `.env` file\n\n```\nOPENAI_API_KEY=\".......................................\"\n```\n\nThere is a small cost associated with OpenAI calls, so it's a good idea to [set monthly limits](https://platform.openai.com/account/billing/limits) on usage.\n\n\n### Create an alias\n\nThe application is best used as an alias called `?`.  Add it to ~/.bashrc like so:\n\n```bash\n# add alias\necho alias ?=\"\\\"$(pwd)/.venv/bin/python3 $(realpath openai.clihelper.py)\\\"\" \u003e\u003e ~/.bashrc\n# reload bash\nexec bash\n```\n\nNow start using `?`\n\n## Llama.cpp models (uses GPU)\n\nLlama.cpp is a fast way of running local LLMs on your own computer. It is very fast with GPUs which will be my focus. It is free to use.\n\n### Install dependencies\n\nFirst, ensure that [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads?target_os=Linux\u0026target_arch=x86_64\u0026Distribution=Ubuntu\u0026target_version=22.04\u0026target_type=deb_local) is installed. \nAfter installing Cuda, add it to your path and reload bash:  \n\n```bash\necho 'export PATH=\"/usr/local/cuda/bin:$PATH\"' \u003e\u003e ~/.bashrc\nexec bash\n# test that it worked: \nnvcc --version\n```    \n\nNext install the cmake and Python dependencies, and build one specific package with GPU support. \n\n```bash\nsudo apt install make cmake\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\nCMAKE_ARGS=\"-DLLAMA_CUBLAS=on\" FORCE_CMAKE=1 pip install llama-cpp-python --force --no-cache\n```\n\n### Get some models\n\nBecause Llama is open, there are many Llama models you can choose from. Llama.cpp requires models to be in the GGML format. Here are some I tested with: \n\n[TheBloke/Llama-2-7B-Chat-GGML](https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML) - `llama-2-7b-chat.ggmlv3.q4_0.bin`   \n[TheBloke/StableBeluga-7B-GGML](https://huggingface.co/TheBloke/StableBeluga-7B-GGML) -  `stablebeluga-7b.ggmlv3.q4_0.bin`  \n\n Download these then set the path to the model in the .env file. Example: \n\n     LLAMA_MODEL_PATH=\"./models/7B/stablebeluga-7b.ggmlv3.q4_0.bin\"\n\n### Create an alias\n\nThe application is best used as an alias called `?`.  Add it to ~/.bashrc like so:\n\n```bash\n# add alias\necho alias ?=\"\\\"$(pwd)/.venv/bin/python3 $(realpath llamacpp.clihelper.py)\\\"\" \u003e\u003e ~/.bashrc\n# reload bash\nexec bash\n```\n\nNow start using `?`\n\n## Implementation notes\n\nThis was made using [langchain](https://python.langchain.com/docs/get_started/introduction.html), a library that helps make calls to large language models (LLMs) and process its output. \n\nIn this case I did a 'few shot', which is a way of showing the LLM a few examples of questions and the kind of answers to generate. \n\nI chose the `gpt-3.5-turbo` model which is the cheapest on OpenAI currently.  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmendhak%2Fllm-cli-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmendhak%2Fllm-cli-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmendhak%2Fllm-cli-helper/lists"}