{"id":20627424,"url":"https://github.com/florianmgs/gpt-cli","last_synced_at":"2025-04-15T15:22:03.732Z","repository":{"id":146779567,"uuid":"617994186","full_name":"FlorianMgs/gpt-cli","owner":"FlorianMgs","description":"Bring ChatGPT \u0026 Dall-E 2 into your CLI as a specialized personal assistant.","archived":false,"fork":false,"pushed_at":"2023-03-30T03:58:29.000Z","size":2120,"stargazers_count":10,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-26T20:49:20.097Z","etag":null,"topics":["bash","chatgpt","cli","dalle2","openai","ruby","unix"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FlorianMgs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-03-23T14:36:55.000Z","updated_at":"2024-01-17T16:04:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"846ed96e-feaf-4487-a59d-ef26e586b2ff","html_url":"https://github.com/FlorianMgs/gpt-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianMgs%2Fgpt-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianMgs%2Fgpt-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianMgs%2Fgpt-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlorianMgs%2Fgpt-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FlorianMgs","download_url":"https://codeload.github.com/FlorianMgs/gpt-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249095146,"owners_count":21211871,"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":["bash","chatgpt","cli","dalle2","openai","ruby","unix"],"created_at":"2024-11-16T13:16:45.620Z","updated_at":"2025-04-15T15:22:03.726Z","avatar_url":"https://github.com/FlorianMgs.png","language":"Ruby","readme":"# GPTCLI\n\nThis library provides a UNIX-ey interface to OpenAI.  \nSay hello to your own highly specialized GPT4 personal assistant, directly in your terminal!  \nProductivity stonks 📈📈📈   \n\nConsider 🌟 this repo if you find this tool useful 🔥  \n\n## Features\n- Use the pipe to pass commands output to GPT or Dall-E 2.  \n- Choose your GPT model, GPT4 supported if you have access.  \n- Dall-E 2 support: generate images directly in your terminal.  \n- Contexts prompts tailored for your needs: add/update predefined context prompts or write your own when running the command.  \n- Conversation history: have chat sessions with GPT just like [chat.openai.com](https://chat.openai.com/) but in your terminal. Currently limited to 4097 token limit for GPT3.5.\n\nSee [Installation](#installation) and [Setup](#setup) below, but first, some examples.\n\n## Examples\n\n```console\n$ gpt \"what is your role?\"\nAs your personal assistant, my role is to assist you in various tasks and answer your questions related to my areas of expertise, which include UNIX systems, bash, Python, Django, SQL, Javascript, ReactJS. I can help you with programming and development, server administration, debugging your code or scripts, optimizing performance, code review, providing recommendations for best practices, and more.\n```\n\nUse Dall-E:\n```console\n$ gpt give me a very short description of the moon landscape | gpt --dalle\nImage saved in current directory to 7db7ab2e8914175d4f4819e033226563.png\n```\n\u003cimg src=\"https://raw.githubusercontent.com/FlorianMgs/gpt-cli/master/.github/7db7ab2e8914175d4f4819e033226563.png\" height=256 width=256\u003e\u003c/img\u003e\n\n```console\n$ uptime | gpt convert this to json\n{\n        \"time_of_measurement\": \"13:48:26\",\n        \"up_time\": \"30 days, 18:07\",\n        \"users\": 3,\n        \"load_average\": [\n                0.46,\n                0.61,\n                0.79\n        ]\n}\n```\n\n```console\n$ gpt list the nine planets as JSON | gpt convert this to XML but in French | tee planets.fr.xml\n\u003cPlanètes\u003e\n   \u003cPlanète\u003eMercure\u003c/Planète\u003e\n   \u003cPlanète\u003eVénus\u003c/Planète\u003e\n   \u003cPlanète\u003eLa Terre\u003c/Planète\u003e\n   \u003cPlanète\u003eMars\u003c/Planète\u003e\n   \u003cPlanète\u003eJupiter\u003c/Planète\u003e\n   \u003cPlanète\u003eSaturne\u003c/Planète\u003e\n   \u003cPlanète\u003eUranus\u003c/Planète\u003e\n   \u003cPlanète\u003eNeptune\u003c/Planète\u003e\n   \u003cPlanète\u003ePluton\u003c/Planète\u003e\n\u003c/Planètes\u003e\n```\n\n```console\n$ gpt -c \"you are Vitalik Buterin, the creator of Ethereum. You know very well the whole EVM ecosystem and how to write perfectly optimized Solidity smart contracts\" -p \"Write a simple ERC20 token smart contract using OpenZeppelin library, respond only by the smart contract, do no write explanations\" \u003e erc20.sol\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract MyToken is ERC20 {\n    constructor(uint256 initialSupply) ERC20(\"MyToken\", \"MTK\") {\n        _mint(msg.sender, initialSupply);\n    }\n}\n```\n\n```console\n$ curl -sL \"https://en.wikipedia.org/wiki/cats\" | head -n 5 | gpt extract just the title of this webpage | figlet\n  ____      _            __        ___ _    _                _ _\n / ___|__ _| |_          \\ \\      / (_) | _(_)_ __   ___  __| (_) __ _\n| |   / _` | __|  _____   \\ \\ /\\ / /| | |/ / | '_ \\ / _ \\/ _` | |/ _` |\n| |__| (_| | |_  |_____|   \\ V  V / | |   \u003c| | |_) |  __/ (_| | | (_| |\n \\____\\__,_|\\__|            \\_/\\_/  |_|_|\\_\\_| .__/ \\___|\\__,_|_|\\__,_|\n                                             |_|\n```\n\n```console\n$ ls | gpt What is this directory for?\nThis directory contains the source code for a Ruby-based project called gpt-cli. It includes files related to the project's license (LICENSE.txt), changelog (CHANGELOG.md), dependencies (Gemfile and Gemfile.lock), executables (bin and exe), libraries (lib), signature (sig) and tests (spec). There is also a Rakefile and a README.md file which provide information about how to build and install the project, as well as its features and usage. Finally, it includes the gpt-cli-0.1.0.gem and gpt-cli.gemspec files which are used to build the gem which can be installed on other systems.\n```\n\n```console\n$ ls -l | gpt which of these are directories?\nbin, exe, lib, sig, spec\n```\n\n```console\n$ ls | gpt \"For each of these files, provide a description of what is likely to be their contents?\"\nbin - Likely contains compiled binary executable files.\nCHANGELOG.md - Likely contains a log of changes/modifications, such as bug fixes and new features, that have been made to the project.\nexe - Likely contains executable files.\nfrench_planets.xml - Likely contains an XML file containing data related to planets, likely in French.\nGemfile - Likely contains Ruby code for the project's dependencies.\nGemfile.lock - Likely contains a snapshot of the dependencies of the project and versions of those dependencies.\nlib - Likely contains the Ruby source code (e.g. classes and modules) for the project.\nLICENSE.txt - Likely contains the terms of use/license for the project.\ngpt-cli-0.1.0.gem - Likely contains a gem that gathers information from the OpenAI API.\ngpt-cli.gemspec - Likely contains configuration details for the gem.\nplanets.lst - Likely contains a list of planets.\npoem.txt - Likely contains a text file containing a poem.\nRakefile - Likely contains Ruby tasks and dependencies that can be used in projects.\nREADME.md - Likely contains general information about the project and usage instructions.\nreverse.lst - Likely contains a list of words or items that are in reverse order.\nsig - Likely contains digital signatures to validate individual files.\nspec - Likely contains Ruby specs (i.e. tests) for the project.\nuptime.json - Likely contains a file with information regarding system uptime of a computer.\n```\n\n```console\n$ git commit -m \"$(git status | gpt write me a commit message for these changes)\"\n[master 7d0271f] Add new files and modify README.md\n```\n\n```console\n$ git status | tee /dev/tty | gpt write me a sonnet about the status of this git repository\nOn branch master\nUntracked files:\n  (use \"git add \u003cfile\u003e...\" to include in what will be committed)\n        gpt-cli-0.1.0.gem\n\nnothing added to commit but untracked files present (use \"git add\" to track)\n\nMy master branch may lack to thee its kin\nFor change it holds the only force within\nThé untracked files, they still remain unnamed\n‘Tis fervent hope thé change will soon be claimed\n\nFraught with the choice to leave or to persist\nThe repository wavers ‘tween future and past\nThe gpt-cli-0.1.0 gem stands out\nWaiting to be added, not yet about\n\nThe commit awaits for brave new changes bold\nWhile time’s old force is ever unfurled\nCommit forth young mind, furrow not to crawl\nFrom untracked files, a future stands tall.\n```\n\n```console\n% history | gpt what was the last thing I did\nThe last command you entered was 'history'.\n```\nn.b. somehow it sees history-esque output and determines that history was typed -- the history command does not itself include the history command in the output.\n\n```console\n$ history | gpt what was the last thing I did before typing history\nThe last thing you did was amend a README.md file.\n```\nn.b. here it determines the amend was for README.md not from the previous command but from ones prior that edited README.md.\n\n```console\n$ cat lib/gpt-cli/version.rb | gpt rewrite this file with just the minor version incremented | sponge \u003e lib/gpt-cli/version.rb\n$ git diff\ndiff --git a/lib/gpt-cli/version.rb b/lib/gpt-cli/version.rb\nindex 0f82357..cc57fab 100644\n--- a/lib/gpt-cli/version.rb\n+++ b/lib/gpt-cli/version.rb\n@@ -1,5 +1,5 @@\n # frozen_string_literal: true\n\n module GPTCLI\n-  VERSION = \"0.1.0\"\n+  VERSION = \"0.1.1\"\n end\n```\n\n```console\n$ ruby -e \"$(gpt write me a python script that prints the current month | gpt translate this into ruby)\" | gpt translate this into French\nLe mois courant est Décembre.\n```\n\n## Installation\n\nInstall the gem by executing:\n\n    $ gem install gpt-cli\n\n## Setup\n\nThis library uses [quick_openai](https://github.com/Aesthetikx/quick_openai) which itself uses [ruby-openai](https://github.com/alexrudall/ruby-openai), so you may want to familiarise yourself with those projects first.\n\nThis library uses OpenAI GPT to generate responses, so you will need to have your access token available in ENV. In .bashrc or equivalent,\n```bash\nexport OPENAI_ACCESS_TOKEN=mytoken\n```\nSet the model you want to use in ENV:\n```bash\nexport OPENAI_MODEL=\"gpt-3.5-turbo\"\n```\nCopy `gpt_contexts.sample.json` somewhere, for example `~/Documents/gpt_contexts.json`, then put the file path in ENV (don't forget to rename the file to `gpt_contexts.json`):\n```bash\nexport OPENAI_CONTEXTS_PATH=\"path/to/gpt_contexts.json\"\n```\n(Optional) set the default context prompt you want to use, see `gpt_contexts.sample.json` for examples:\n```bash\nexport OPENAI_DEFAULT_CONTEXT=\"python\"\n```\nBy default the executable is called `gpt-cli`. It is reccommended to alias this command to something shorter in .bashrc or equivalent, e.g.\n```bash\nalias gpt=\"gpt-cli\"\n```\n\n## Usage\n\nThere's optional parameters you can set when running `gpt`:  \n`gpt -c \u003ccustom_context_prompt\u003e -p \u003cyour prompt\u003e`  \n\n`--context -c`: this will be the context prompt, see basic contexts in `gpt_contexts.sample.json`. You can put a key from `gpt_contexts.json` or a custom context. Default to ENV `OPENAI_DEFAULT_CONTEXT` if not set. Add your own context prompts in `gpt_contexts.json`.  \n\n`--prompt -p`: your actual prompt.  \n\n`--history -h`: print conversation history.  \n\n`--dalle -d`: Generate an image from your prompt with Dall-E.  \n\n`--clear`: clear conversation history.  \n\nYou can also run gpt without any arguments, just with your prompt. In this case, the context prompt will default to the one defined by ENV var `OPENAI_DEFAULT_CONTEXT` if it exists. If not, no context will be added.  \nSee examples above for an overview of some usecases. Possibilities are endless.  \n\n## Notes\n\nThis is made on top of [openai_pipe](https://github.com/Aesthetikx/openai_pipe), created by [Aesthetikx](https://github.com/Aesthetikx/), kudos to him for his awesome work!  \nBe aware that there is a cost associated every time GPT is invoked, so be mindful of your account usage. Also be wary of sending sensitive data to OpenAI, and also wary of arbitrarily executing scripts or programs that GPT generates.\nAlso, this is my very first time working in Ruby. So please be indulgent 🙏  \n\n## TODO\n\n- Add internet search support to feed prompt more accurately  \n- Add proper documentation  \n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/FlorianMgs/gpt-cli.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianmgs%2Fgpt-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorianmgs%2Fgpt-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianmgs%2Fgpt-cli/lists"}