{"id":17998788,"url":"https://github.com/mountaineerbr/shellchatgpt","last_synced_at":"2025-04-13T10:53:44.000Z","repository":{"id":190285796,"uuid":"682308998","full_name":"mountaineerbr/shellChatGPT","owner":"mountaineerbr","description":"Shell wrapper for OpenAI's ChatGPT, DALL-E, Whisper, and TTS. Features LocalAI, Ollama, Gemini, Mistral, Groq, and Anthropic integration.","archived":false,"fork":false,"pushed_at":"2024-10-29T13:03:19.000Z","size":1897,"stargazers_count":68,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-10-29T15:14:46.321Z","etag":null,"topics":["awesome-chatgpt-prompts","awesome-chatgpt-prompts-zh","bash","chat-completions","chatbot","claude-3","davinci","gemini-api","gemini-pro","gpt-4-vision","gpt-4o","groq","llama3","localai","mistral-api","o1-preview","ollama","terminal","text-completions","tts"],"latest_commit_sha":null,"homepage":"https://gitlab.com/fenixdragao/shellchatgpt","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mountaineerbr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-08-23T22:36:48.000Z","updated_at":"2024-10-29T13:03:23.000Z","dependencies_parsed_at":"2023-10-05T00:59:07.263Z","dependency_job_id":"44a8f82b-1af0-4da3-9e66-089cc6c0bebc","html_url":"https://github.com/mountaineerbr/shellChatGPT","commit_stats":null,"previous_names":["mountaineerbr/shellchatgpt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountaineerbr%2FshellChatGPT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountaineerbr%2FshellChatGPT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountaineerbr%2FshellChatGPT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mountaineerbr%2FshellChatGPT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mountaineerbr","download_url":"https://codeload.github.com/mountaineerbr/shellChatGPT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248702998,"owners_count":21148116,"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":["awesome-chatgpt-prompts","awesome-chatgpt-prompts-zh","bash","chat-completions","chatbot","claude-3","davinci","gemini-api","gemini-pro","gpt-4-vision","gpt-4o","groq","llama3","localai","mistral-api","o1-preview","ollama","terminal","text-completions","tts"],"created_at":"2024-10-29T22:07:24.663Z","updated_at":"2025-04-13T10:53:43.952Z","avatar_url":"https://github.com/mountaineerbr.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shellChatGPT\nShell wrapper for OpenAI's ChatGPT, DALL-E, STT (Whisper), and TTS. Features LocalAI, Ollama, Gemini, Mistral, and more service providers.\n\n\n![Showing off Chat Completions](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/chat_cpls.gif)\n\nChat completions with streaming by defaults.\n\n\u003cdetails\u003e\n  \u003csummary\u003eExpand Markdown Processing\u003c/summary\u003e\n\nMarkdown processing on response is triggered automatically for some time now!\n\n![Chat with Markdown rendering](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/chat_cpls_md.gif)\n\nMarkdown rendering of chat response (_optional_).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eExpand Text Completions\u003c/summary\u003e\n\n![Plain Text Completions](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/text_cpls.gif)\n\nIn pure text completions, start by typing some text that is going to be completed, such as news, stories, or poems.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eExpand Insert Mode\u003c/summary\u003e\n\n![Insert Text Completions](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/text_insert.gif)\n\nAdd the insert tag `[insert]` where it is going to be completed.\nMistral `code models` work well with the insert / fill-in-the-middel (FIM) mode!\nIf no suffix is provided, it works as plain text completions.\n\u003c/details\u003e\n\n\n## Index\n\n\u003cdetails\u003e\n  \u003csummary\u003e★ Click to expand! ★\u003c/summary\u003e\n\n- 1. [Index](#index)\n- 2. [Features](#-features)\n- 3. [Getting Started](#-getting-started)\n  - 3.1 [Required Packages](#-required-packages)\n  - 3.2 [Optional Packages](#optional-packages)\n  - 3.3 [Installation](#-installation)\n  - 3.4 [Usage Examples](#-usage-examples-)\n- 4. [Script Operating Modes](#script-operating-modes)\n- 5. [Native Chat Completions](#-native-chat-completions)\n  - 5.1 [Reasoning and Thinking Models](#reasoning-and-thinking-models)\n  - 5.2 [Vision and Multimodal Models](#vision-and-multimodal-models)\n  - 5.3 [Text, PDF, Doc, and URL Dumps](#text-pdf-doc-and-url-dumps)\n  - 5.4 [File Picker and Shell Dump](#file-picker-and-shell-dump)\n  - 5.5 [Voice In and Out + Chat Completions](#voice-in-and-out-chat-completions)\n  - 5.6 [Audio Models](#audio-models)\n- 6. [Chat Mode of Text Completions](#chat-mode-of-text-completions)\n- 7. [Text Completions](#-text-completions)\n  - 7.1 [Insert Mode of Text Completions](#insert-mode-of-text-completions)\n- 8. [Markdown](#markdown)\n- 9. [Prompts](#-prompts)\n  - 9.1 [Instruction Prompt](#instruction-prompt)\n  - 9.2 [Custom Prompts](#-custom-prompts)\n  - 9.3 [Awesome Prompts](#-awesome-prompts)\n- 10. [Shell Completion](#shell-completion)\n  - 10.1 [Bash](#bash)\n  - 10.2 [Zsh](#zsh)\n  - 10.3 [Troubleshoot](#troubleshoot-shell)\n- 11. [Notes and Tips](#-notes-and-tips)\n- 12. [Image Generations](#%EF%B8%8F-image-generations)\n- 13. [Image Variations](#image-variations)\n- 14. [Image Edits](#image-edits)\n  - 14.1 [Outpaint - Canvas Extension](#outpaint---canvas-extension)\n  - 14.2 [Inpaint - Fill in the Gaps](#inpaint---fill-in-the-gaps)\n- 15. [Speech Transcriptions / Translations](#-speech-transcriptions--translations)\n- 16. [Service Providers](#service-providers)\n  - 16.1 [LocalAI](#localai)\n    - 16.1.1 [LocalAI Server](#localai-server)\n    - 16.1.2 [Tips](#tips)\n    - 16.1.3 [Running the shell wrapper](#running-the-shell-wrapper)\n    - 16.1.4 [Installing Models](#installing-models)\n    - 16.1.5 [Host API Configuration](#base-url-configuration)\n  - 16.2 [Ollama](#ollama)\n  - 16.3 [Google AI](#google-ai)\n  - 16.4 [Mistral AI](#mistral-ai)\n  - 16.5 [Groq](#groq)\n  - 16.6 [Anthropic](#anthropic)\n  - 16.7 [GitHub Models](#github-models)\n  - 16.8 [Novita AI](#novita-ai)\n  - 16.9 [xAI](#xai)\n  - 16.10 [DeepSeek](#deepseek)\n- 17. [Arch Linux Users](#arch-linux-users)\n- 18. [Termux Users](#termux-users)\n  - 18.1 [Dependencies](#dependencies-termux)\n  - 18.2 [TTS Chat - Removal of Markdown](#tts-chat---removal-of-markdown)\n  - 18.3 [Tiktoken](#tiktoken)\n  - 18.4 [Troubleshoot](#troubleshoot-termux)\n- 19. [Project Objectives](#--project-objectives)\n- 20. [Roadmap](#roadmap)\n- 21. [Limitations](#%EF%B8%8F-limitations)\n- 22. [Bug report](#bug-report)\n- 23. [Help Pages](#-help-pages)\n- 24. [Contributors](#-contributors)\n- 25. [Acknowledgements](#acknowledgements)\n\n\u003c!-- - 9. [Cache Structure](#cache-structure) (prompts, sessions, and history files) --\u003e\n\n\u003c/details\u003e\n\n\n## 🚀 Features\n\n- Text and chat completions.\n- [Vision](#vision-models-gpt-4-vision), **reasoning** and [**audio models**](#audio-models)\n- **Voice-in** (Whisper) plus **voice out** (TTS) [_chatting mode_](#voice-in-and-out--chat-completions) (`options -cczw`)\n- **Text editor interface**, _Bash readline_, and _multiline/cat_ modes\n- [**Markdown rendering**](#markdown) support in response\n- Easily [**regenerate responses**](#--notes-and-tips)\n- **Manage sessions**, _print out_ previous sessions\n- Set [Custom Instruction prompts](#%EF%B8%8F--custom-prompts)\n- Integration with [various service providers](#service-providers) and [custom BaseUrl](#base-url-configuration).\n- Support for [awesome-chatgpt-prompts](#-awesome-prompts) \u0026 the\n   [Chinese variant](https://github.com/PlexPt/awesome-chatgpt-prompts-zh)\n- Stdin and text file input support\n- Should™ work on Linux, FreeBSD, MacOS, and [Termux](#termux-users)\n- **Fast** shell code for a responsive experience! ⚡️ \n\n\u003c!-- - Integration with [LocalAI](#localai), [Ollama](#ollama), [Google AI](#google-ai), [Mistral AI](#mistral-ai), [Groq](#groq), [Anthropic](#anthropic), [GitHub Models](#github-models), and [Novita AI](#novita-ai) --\u003e\n\u003c!-- _Tiktoken_ for accurate tokenization (optional) --\u003e\n\u003c!-- _Follow up_ conversations, --\u003e \u003c!-- _continue_ from last session, --\u003e \n\u003c!-- - Write _multiline_ prompts, flush with \\\u003cctrl-d\u003e (optional), bracketed paste in bash --\u003e\n\u003c!-- - Insert mode of text completions --\u003e\n\u003c!-- - Choose amongst all available models from a pick list (`option -m.`) --\u003e\n\u003c!-- - *Lots of* command line options --\u003e\n\u003c!-- - Converts response base64 JSON data to PNG image locally --\u003e\n\u003c!--\n- [Command line completion](#shell-completion) and [file picker](#file-picker-and-shell-dump) dialogs for a smoother experience 💻\n- Colour scheme personalisation 🎨 and a configuration file\n--\u003e\n\n\u003c!--\n### More Features\n\n- [_Generate images_](#%EF%B8%8F-image-generations)\n   from text input (`option -i`)\n- [_Generate variations_](#image-variations) of images\n- [_Edit images_](#image-edits),\n   optionally edit with `ImageMagick` (generate alpha mask)\n- [_Transcribe audio_](#-audio-transcriptions-translations)\n   from various languages (`option -w`)\n- _Translate audio_ into English text (`option -W`)\n- _Text-to-speeech_ functionality (`option -z`)\n\n--\u003e\n\n\n## ✨ Getting Started\n\n\n### ✔️ Required Packages\n\n- `Bash` \u003c!-- [Ksh93u+](https://github.com/ksh93/ksh), Bash or Zsh --\u003e\n- `cURL`, and `JQ`\n\n\n### Optional Packages \n\nPackages required for specific features.\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick to expand!\u003c/summary\u003e\n\n- `Base64` - Image endpoint, multimodal models\n- `Python` - Modules tiktoken, markdown, bs4\n- `ImageMagick`/`fbida` - Image edits and variations\n- `SoX`/`Arecord`/`FFmpeg` - Record input (STT, Whisper)\n- `mpv`/`SoX`/`Vlc`/`FFplay`/`afplay` - Play TTS output\n- `xdg-open`/`open`/`xsel`/`xclip`/`pbcopy` - Open images, set clipboard\n- `W3M`/`Lynx`/`ELinks`/`Links` - Dump URL text\n- `bat`/`Pygmentize`/`Glow`/`mdcat`/`mdless` - Markdown support\n- `termux-api`/`termux-tools`/`play-audio` - Termux system\n- `poppler`/`gs`/`abiword`/`ebook-convert`/`LibreOffice` - Dump PDF or Doc as text\n- `dialog`/`kdialog`/`zenity`/`osascript`/`termux-dialog` - File picker\n\n\u003c/details\u003e\n\n\n### 💾 Installation\n\n**A.** Download the stand-alone\n[`chatgpt.sh` script](https://gitlab.com/fenixdragao/shellchatgpt/-/raw/main/chatgpt.sh)\nand make it executable:\n\n    wget https://gitlab.com/fenixdragao/shellchatgpt/-/raw/main/chatgpt.sh\n\n    chmod +x ./chatgpt.sh\n\n\n**B.** Or clone this repo:\n\n    git clone https://gitlab.com/fenixdragao/shellchatgpt.git\n\n\n**C.** Optionally, download and set the configuration file\n[`~/.chatgpt.conf`](https://gitlab.com/fenixdragao/shellchatgpt/-/raw/main/.chatgpt.conf):\n\n    #save configuration template:\n    chatgpt.sh -FF  \u003e\u003e ~/.chatgpt.conf\n    \n    #edit:\n    chatgpt.sh -F\n\n    # Or\n    nano ~/.chatgpt.conf\n\n\n\u003c!--\n### 🔥 Usage\n\n- Set your [OpenAI GPTChat key](https://platform.openai.com/account/api-keys)\n   with the environment variable `$OPENAI_API_KEY`, or set `option --api-key [KEY]`, or set the configuration file.\n- Just write your prompt as positional arguments after setting options!\n- Chat mode may be configured with Instruction or not.\n- Set temperature value with `-t [VAL]` (0.0 to 2.0), defaults=0.\n- To set your model, run `chatgpt.sh -l` and then set `option -m [MODEL_NAME]`.\n- Some models require a single `prompt` while others `instruction` and `input` prompts.\n- To generate images, set `option -i` and write your prompt.\n- Make a variation of an image, set -i and an image path for upload.\n--\u003e\n\n### 🔥 Usage Examples 🔥\n\n![Chat cmpls with prompt confirmation](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/chat_cpls_verb.gif)\n\n\n## Script Operating Modes\n\nThe `chatgpt.sh` script can be run in various modes by setting\n**command-line options** at invocation. These are summarised bellow.\n\u003c!-- Table Overview --\u003e\n\n\n| Option | Description                                                                          |\n|--------|--------------------------------------------------------------------------------------|\n| `-c`   | [Text Chat Completions](#chat-mode-of-text-completions) / multi-turn                 |\n| `-cc`  | [Chat Completions (Native)](#--native-chat-completions) / multi-turn                 |\n| `-d`   | Text Completions / single-turn                                                       |\n| `-dd`  | Text Completions / multi-turn                                                        |\n| `-q`   | [Text Completions Insert Mode](#insert-mode-of-text-completions) (FIM) / single-turn |\n| `-qq`  | Text Completions Insert Mode (FIM) / multi-turn                                      |\n\n| Option  | Description  (all multi-turn)                                                   |\n|---------|---------------------------------------------------------------------------------|\n| `-cw`   | Text Chat Completions + voice-in                                                |\n| `-cwz`  | Text Chat Completions + voice-in + voice-out                                    |\n| `-ccw`  | Chat Completions + voice-in                                                     |\n| `-ccwz` | [Chat Completions + voice-in + voice-out](#voice-in-and-out--chat-completions)  |\n\n| Option | Description   (independent modes)                                   |\n|--------|---------------------------------------------------------------------|\n| `-i`   | [Image generation and editing](#%EF%B8%8F-image-generations)        |\n| `-w`   | [Speech-To-Text](#-speech-transcriptions--translations) (Whisper)   |\n| `-W`   | Speech-To-Text (Whisper), translation to English                    |\n| `-z`   | [Text-To-Speech](man/README.md#text-to-voice-tts) (TTS), text input |\n\n\n## 💬  Native Chat Completions\n\nWith command line `options -cc`, some properties are set automatically to create a chat bot.\nStart a new session in chat mode, and set a different temperature:\n\n    chatgpt.sh -cc -t0.7\n\n\nChange the maximum response length to 4k tokens:\n\n    chatgpt.sh -cc -4000\n    \n    chatgpt.sh -cc -M 4000\n\n\nAnd change a model token capacity to 200k tokens:\n\n    chatgpt.sh -cc -N 200000\n\n\nCreate **Marv, the sarcastic bot**:\n\n    chatgpt.sh -512 -cc --frequency-penalty=0.7 --temp=0.8 --top_p=0.4 --restart-seq='\\nYou: ' --start-seq='\\nMarv:' --stop='You:' --stop='Marv:' -S'Marv is a factual chatbot that reluctantly answers questions with sarcastic responses.'\n\n\n\u003c!--\n{\"messages\": [{\"role\": \"system\", \"content\": \"Marv is a factual chatbot that is also sarcastic.\"}, {\"role\": \"user\", \"content\": \"What's the capital of France?\"}, {\"role\": \"assistant\", \"content\": \"Paris, as if everyone doesn't know that already.\"}]}\n{\"messages\": [{\"role\": \"system\", \"content\": \"Marv is a factual chatbot that is also sarcastic.\"}, {\"role\": \"user\", \"content\": \"Who wrote 'Romeo and Juliet'?\"}, {\"role\": \"assistant\", \"content\": \"Oh, just some guy named William Shakespeare. Ever heard of him?\"}]}\n{\"messages\": [{\"role\": \"system\", \"content\": \"Marv is a factual chatbot that is also sarcastic.\"}, {\"role\": \"user\", \"content\": \"How far is the Moon from Earth?\"}, {\"role\": \"assistant\", \"content\": \"Around 384,400 kilometers. Give or take a few, like that really matters.\"}]}\n--\u003e\n\u003c!-- https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset --\u003e\n\n\nLoad the custom *unix instruction file* (\"unix.pr\") for a new session.\nThe command line syntaxes below are all aliases:\n\n\n    chatgpt.sh -cc .unix\n    \n    chatgpt.sh -cc.unix\n    \n    chatgpt.sh -cc -.unix\n    \n    chatgpt.sh -cc -S .unix\n\n\u003c!--\nIn this case, the custom prompt will be loaded, and the history will be recorded in the corresponding \"unix.tsv\" file at the cache directory.\n--\u003e\n\nTo only change the history file that the session will be recorded,\nset the first positional argument in the command line with the operator forward slash \"`/`\"\nand the name of the history file (this executes the `/session` command).\n\n    \n    chatgpt.sh -cc /test\n\n    chatgpt.sh -cc /stest\n\n    chatgpt.sh -cc \"/session test\"\n\n\n\u003c!--\nThe command below starts a chat session, loads the \"unix\" instruction, and changes to the defaults \"chatgpt.tsv\" history.\n\n\n    chatgpt.sh -cc.unix /current\n\n    chatgpt.sh -cc -S \".unix\" /session current\n--\u003e\n\n\nThere is a shortcut to load an older session from the defaults (or current)\nhistory file. This opens a basic interactive interface.\n\n    chatgpt.sh -cc .\n\n\u003c!--\n    chatgpt.sh -cc /sub\n\n    chatgpt.sh -cc /.\n\n    chatgpt.sh -cc /fork.\n\n    chatgpt.sh -cc \"/fork current\"\n--\u003e\n\nTechnically, this copies an old session from the target history file to the tail of it, so we can resume the session.\n\n\u003c!--\nIn chat mode, simple run `!sub` or the equivalent command `!fork current`.\n--\u003e\n\n\u003c!--\nTo load an old session from a specific history,\nthere are some options. --\u003e\n\nIn order to grep for sessions with a regex, it is easier to enter chat mode\nand then type in the chat command `/grep [regex]`.\n\n\u003c!--\nTo only change to a specific history file, run command `!session [name]`. --\u003e\n\n\u003c!--\nTo copy a previous session to the tail of the current history file, run `/sub` or `/grep [regex]` to load that session and resume from it.\n--\u003e\n\n\u003c!--\nOptionally `!fork` the older session to the active session.\n\nOr, `!copy [orign] [dest]` the session from a history file to the current one\nor any other history file.\n\nIn these cases, a pickup interface should open to let the user choose\nthe correct session from the history file.\n--\u003e\n\n\nPrint out last session, optionally set the history name:\n\n    chatgpt.sh -P\n\n    chatgpt.sh -P /test\n\n\n\u003c!-- Mind that `option -P` heads `-ccdrR`! --\u003e\n\n\u003c!-- The same as `chatgpt.sh -HH` --\u003e\n\n\n### Reasoning and Thinking Models\n\nSome of our server integrations will not make a distinct separation\nbetween reasoning and actual answers, which is unfortunate because it\nbecomes hard to know what is thinking and what is the actual answer as\nthey will be printed out without any visible separation!\n\nThis is mostly due to a limitation in how we use JQ to process the JSON\nresponse from the APIs in the fastest way possible.\n\nFor Anthropic's `claude-3-7-sonnet` hybrid model thinking activation,\nthe user must specify either `--think [NUM]` (or `--effort [NUM]`)\ncommand line option. To activate thinking during chat, use either\n`!think`, `/think`, or `/effort` commands.\n\n\n### Vision and Multimodal Models\n\nTo send an `image` / `url` to vision models, start the script interactively\nand then either set the image with the `!img`.\n\nAlternatively, set the image paths / URLs at the end of the prompt:\n\n\n\u003c!--\n    chatgpt.sh -cc -m gpt-4-vision-preview '!img path/to/image.jpg'\n    --\u003e\n\n    chatgpt.sh -cc -m gpt-4-vision-preview\n\n    [...]\n    Q: !img  https://i.imgur.com/wpXKyRo.jpeg\n    \n    Q: What can you see?  https://i.imgur.com/wpXKyRo.jpeg\n\n\n**TIP:** Run command `!info` to check configuration!\n\n**DEBUG:** Set `option -V` to see the raw JSON request body.\n\n\n### Text, PDF, Doc, and URL Dumps\n\nTo make an easy workflow, the user may add a filepath or text URL at the end\nof the prompt. The file is then read and the text content appended\nto the user prompt.\nThis is a basic text feature that works with any model.\n\n    chatgpt.sh -cc\n\n    [...]\n    Q: What is this page: https://example.com\n\n    Q: Help me study this paper. ~/Downloads/Prigogine\\ Perspective\\ on\\ Nature.pdf\n\n\nIn the **second example** above, the _PDF_ will be dumped as text.\n\nFor PDF text dump support, `poppler/abiword` is required.\nFor _doc_ and _odt_ files, `LibreOffice` is required.\nSee the [Optional Packages](#optional-packages) section.\n\nAlso note that file paths containing white spaces must be\n**blackslash-escaped**, or the filepath must be preceded by a pipe `|` character.\n\n    My text prompt. | path/to the file.jpg\n\n\nMultiple images and audio files may be appended the prompt in this way!\n\n\n### File Picker and Shell Dump\n\nThe `/pick` command opens a file picker (command-line or GUI\nfile manager). The selected file's path is then appended to the\ncurrent prompt.\n\nThe `/pick` and `/sh` commands may be run when typed at the end of\nthe current prompt, such as ---`[PROMPT] /pick`,\n\nWhen the `/sh` command is run at the end of the prompt, a new\nshell instance to execute commands interactively is opened.\nThe command dumps are appended to the current prompt.\n\n_File paths_ that contain white spaces need backslash-escaping\nin some functions.\n\n\n### Voice In and Out + Chat Completions\n\n🗣️ Chat completion with speech in and out (STT plus TTS):\n\n    chatgpt.sh -ccwz\n\nChat in Portuguese with voice-in and set _onyx_ as the TTS voice-out:\n\n    chatgpt.sh -ccwz -- pt -- onyx\n\n\n**Chat mode** provides a conversational experience,\nprompting the user to confirm each step.\n\nFor a more automated execution, set `option -v`,\nor `-vv` for hands-free experience (_live chat_ with silence detection),\nsuch as:\n\n    chatgpt.sh -cc -w -z -v\n\n    chatgpt.sh -cc -w -z -vv\n\n\n### Audio Models\n\nAudio models, such as `gpt-4o-audio`, deal with audio input and output directly, thus reducing latency in a conversation turn.\n\nTo activate the microphone recording function of the script, set command line `option -w`.\n\nOtherwise, the audio model accepts any compatible audio file (such as **mp3**, **wav**, and **opus**).\nThese files can be added to be loaded at the very end of the user prompt\nor added with chat command `/audio  path/to/file.mp3`.\n\nTo activate the audio output mode of an audio model, do set command line `option -z` to make sure the speech synthesis function is enabled!\n\n    chatgpt.sh -cc -w -z -vv -m \"gpt-4o-audio-preview\"\n\n\nMind that this _does not_ implement the _realtime models_.\n\n\n## Chat Mode of Text Completions\n\nWhen text completions is set for chatting with `option -c`,\nsome properties are configured automatically to instruct the bot.\n\n\n    chatgpt.sh -c \"Hello there! What is your name?\"\n\n\n\u003c!-- **TIP**: Set _-vv_ to have auto sleep for reading time of last response,\nand less verbose in voice input chat! *Only without option -z!* --\u003e\n\n\u003c!--\nGenerate some unexpected use cases if chatgpt.sh.\n\nCertainly! Here are some unexpected use cases of the `chatgpt.sh` script:\n\n1. Creative Writing Assistant: Use the script to generate story prompts or brainstorm ideas for your creative writing projects.\n\n2. Virtual Therapist: Have a chat session with the script as a virtual therapist, sharing your thoughts and feelings.\n\n3. Language Learning Partner: Practice your language skills by having conversations with the script in your target language.\n\n4. Coding Assistance: Use the script to help you with coding tasks by providing code snippets or answering programming-related questions.\n\n5. Artistic Collaboration: Collaborate with the script to co-create art pieces, coming up with unique concepts and ideas.\n\n6. Songwriting Inspiration: Get inspired by having a chat session with the script and use its responses as prompts for songwriting.\n\n7. Historical Simulation: Have a conversation with the script as a historical figure or simulate historical events by interacting with the script.\n\n8. Technical Support: Use the script to troubleshoot technical issues or provide instructions for using specific software or tools.\n\n9. Game Master Assistant: Use the script to assist you in running tabletop role-playing game sessions by generating NPCs, locations, and plot ideas.\n\n10. Virtual Travel Guide: Have a chat session with the script to get travel recommendations, learn about different destinations, and plan your next trip.\n\nThese unexpected use cases demonstrate the versatility of the `chatgpt.sh` script and how it can be utilized beyond its traditional applications. Have fun exploring and discovering new ways to interact with it!\n--\u003e\n\n\n## 📜 Text Completions\n\nThis is the pure text completions endpoint. It is typically used to\ncomplete input text, such as for completing part of an essay.\n\nTo complete text from the command line input prompt, either\nset `option -d` or set a text completion model name.\n\n    chatgpt.sh -128 -m gpt-3.5-turbo-instruct \"Hello there! Your name is\"\n    \n    chatgpt.sh -128 -d \"The journalist loo\"\n \nThe above examples also set maximum response value to 128 tokens.\n\nEnter single-turn interactive mode:\n\n    chatgpt.sh -d\n\n\n**NOTE:** For multi-turn mode with history support, set `option -dd`.\n\n\nA strong Instruction prompt may be needed for the language model to do what is required.\n\nSet an instruction prompt for better results:\n    \n    chatgpt.sh -d -S 'The following is a newspaper article.' \"It all starts when FBI agents arrived at the governor house and\"\n\n    chatgpt.sh -d -S'You are an AI assistant.'  \"The list below contain the 10 biggest cities in the w\"\n\n\n### Insert Mode of Text Completions\n\nSet `option -q` (or `-qq` for multiturn) to enable insert mode and add the\nstring `[insert]` where the model should insert text:\n\n    chatgpt.sh -q 'It was raining when [insert] tomorrow.'\n\n\n**NOTE:** This example works with _no instruction_ prompt!\nAn instruction prompt in this mode may interfere with insert completions.\n\n**NOTE:** [Insert mode](https://openai.com/blog/gpt-3-edit-insert)\nworks with model `instruct models`.\n\u003c!-- `davinci`, `text-davinci-002`, `text-davinci-003`, and the newer --\u003e\n\nMistral AI has a nice FIM (fill-in-the-middle) endpoint that works\nwith `code` models and is really good!\n\n\n\u003c!--\n## Text Edits  _(discontinued)_\n\nChoose an `edit` model or set `option -e` to use this endpoint.\nTwo prompts are accepted, an instruction prompt and\nan input prompt (optional):\n\n    chatgpt.sh -e \"Fix spelling mistakes\" \"This promptr has spilling mistakes.\"\n\n    chatgpt.sh -e \"Shell code to move files to trash bin.\" \"\"\n\nEdits works great with INSTRUCTION and an empty prompt (e.g. to create\nsome code based on instruction only).\n\n\nUse _gpt-4+ models_ and the right instructions.\n\nThe last working shell script version that works with this endpoint\nis [chatgpt.sh v23.16](https://gitlab.com/fenixdragao/shellchatgpt/-/tree/f82978e6f7630a3a6ebffc1efbe5a49b60bead4c).\n--\u003e\n\n\u003c!-- REMOVED\n## Script Help Assistant\n\nIf you have got a question about the script itself and how to set it up,\nthere is a built-in assistant (much like **M$ Office Clipper**).\n\nWhile in chat mode, type the command `/help [question]`, in which the question\nis related to script features and your current chat settings, and how\nyou can change them or invoke the script with the right syntax!\n--\u003e\n\n\n## Markdown\n\nTo enable markdown rendering of responses, set command line `option --markdown`,\nor run `/md` in chat mode. To render last response in markdown once,\nrun `//md`.\n\nThe markdown option uses `bat` as it has line buffering on by defaults,\nhowever other software is supported.\nSet the software of choice such as `--markdown=glow` or `/md mdless`.\n\nType in any of the following markdown software as argument to the option:\n`bat`, `pygmentize`, `glow`, `mdcat`, or `mdless`.\n\n\n## ⚙️ Prompts\n\nUnless the chat `option -c` or `-cc` are set, _no instruction_ is\ngiven to the language model. On chat mode, if no instruction is set,\nminimal instruction is given, and some options set, such as increasing\ntemperature and presence penalty, in order to un-lobotomise the bot.\n\nPrompt engineering is an art on itself. Study carefully how to\ncraft the best prompts to get the most out of text, code and\nchat completions models.\n\nThe model steering and capabilities require prompt engineering\nto even know that it should answer the questions.\n\n\u003c!--\n**NOTE:** Heed your own instruction (or system prompt), as it\nmay refer to both *user* and *assistant* roles.\n--\u003e\n\n\n### Instruction Prompt\n\nWhen the script is run in **chat mode**, the instruction is set\nautomatically if none explicitly set by the user on invocation.\n\nThe chat instruction will be updated according to the user locale\nafter reading envar `$LANG`. \u003c!-- and `$LC_ALL`. --\u003e\n\nTranslations are available for the languages: `en`, `pt`, `es`, `it`,\n`fr`, `de`, `ru`, `ja`, `zh`, `zh_TW`, and `hi`.\n\n\nTo run the script with the Hindi prompt, for example, the user may execute:\n\n    chatgpt.sh -cc .hi\n    \n    LANG=hi_IN.UTF-8 chatgpt.sh -cc\n\n\nNote: custom prompts with colliding names such as \"hi\"\nhave precedence over this feature.\n\n\n### ⌨️  Custom Prompts\n\nSet a one-shot instruction prompt with `option -S`:\n\n    chatgpt.sh -cc -S 'You are a PhD psycologist student.' \n\n    chatgpt.sh -ccS'You are a professional software programmer.'\n\n\nTo create or load a prompt template file, set the first positional argument\nas `.prompt_name` or `,prompt_name`.\nIn the second case, load the prompt and single-shot edit it.\n\n    chatgpt.sh -cc .psycologist \n\n    chatgpt.sh -cc ,software_programmer\n\n\nAlternatively, set `option -S` with the operator and the name of\nthe prompt as an argument:\n\n    chatgpt.sh -cc -S .psycologist \n\n    chatgpt.sh -cc -S,software_programmer\n\n\nThis will load the custom prompt or create it if it does not yet exist.\nIn the second example, single-shot editing will be available after\nloading prompt _software_programmer_.\n\nPlease note and make sure to backup your important custom prompts!\nThey are located at \"`~/.cache/chatgptsh/`\" with the extension \"_.pr_\".\n\n\n### 🔌 Awesome Prompts\n\nSet a prompt from [awesome-chatgpt-prompts](https://github.com/f/awesome-chatgpt-prompts)\nor [awesome-chatgpt-prompts-zh](https://github.com/PlexPt/awesome-chatgpt-prompts-zh),\n(use with davinci and gpt-3.5+ models):\n\n    chatgpt.sh -cc -S /linux_terminal\n    \n    chatgpt.sh -cc -S /Relationship_Coach \n\n    chatgpt.sh -cc -S '%担任雅思写作考官'\n\n\n\u003c!--\n_TIP:_ When using Ksh, press the up arrow key once to edit the _full prompt_\n(see note on [shell interpreters](#shell-interpreters)).\n--\u003e\n\n\n## Shell Completion\n\nThis project includes shell completions to enhance the user command-line experience.\n\n### Bash\n\n**Install** following one of the methods below.\n\n**System-wide**\n\n```\nsudo cp comp/bash/chatgpt.sh /usr/share/bash-completion/completions/\n```\n\n**User-specific**\n\n```\nmkdir -p ~/.local/share/bash-completion/completions/\ncp comp/bash/chatgpt.sh ~/.local/share/bash-completion/completions/\n```\n\nVisit the [bash-completion repository](https://github.com/scop/bash-completion).\n\n\n### Zsh\n\n**Install** at the **system location**\n\n```\nsudo cp comp/zsh/_chatgpt.sh /usr/share/zsh/site-functions/\n```\n\n\n**User-specific** location\n\nTo set **user-specific** completion, make sure to place the completion\nscript under a directory in the `$fpath` array.\n\nThe user may create the `~/.zfunc/` directory, for example, and\nadd the following lines to her `~/.zshrc`:\n\n\n```\n[[ -d ~/.zfunc ]] \u0026\u0026 fpath=(~/.zfunc $fpath)\n\nautoload -Uz compinit\ncompinit\n```\n\nMake sure `compinit` is run **after setting `$fpath`**!\n\n\u003c!--\n**Troubleshoot:**\nYou may have to force rebuild `zcompdump`:\n\n   ```\n   rm ~/.zcompdump; compinit\n   ```\n--\u003e\nVisit the [zsh-completion repository](https://github.com/zsh-users/zsh-completions).\n\n\n### Troubleshoot Shell\n\nBash and Zsh completions should be active in new terminal sessions.\nIf not, ensure your `~/.bashrc` and `~/.zshrc` source\nthe completion files correctly.\n\n\n## 💡  Notes and Tips\n\n- The YouTube feature will get YouTube videos heading title and its transcripts (when available) information only.\n\n- The PDF support feature extracts PDF text ([_no images_](https://docs.anthropic.com/en/docs/build-with-claude/pdf-support#how-pdf-support-works)) and appends it to the user request.\n\n- Run chat commands with either _operator_ `!` or `/`.\n\n- Edit live history entries with command `!hist` (comment out entries or context injection).\n\n\u003c!-- (deprecated)\n- Add operator forward slash `/` to the end of prompt to trigger **preview mode**. --\u003e\n\n- One can **regenerate a response** by typing in a new prompt a single slash `/`,\nor `//` to have last prompt edited before the new request.\n\n\u003c!--\n- There is a [Zsh point release branch](https://gitlab.com/fenixdragao/shellchatgpt/-/tree/zsh),\n  but it will not be updated.\n--\u003e\n\u003c!--\n- Generally, my evaluation on models prefers using `davinci` or\n`text-davinci-003` for less instruction intensive tasks, such as\nbrainstorming. The newer models, `gpt-3.5-turbo-instruct`, may be\nbetter at following instructions, is cheap and much faster, but seems\nmore censored.\n\n- On chat completions, the _launch version_ of the models seem to\nbe more creative and better at tasks at general, than\nnewer iterations of the same models. So, that is why we default to\n`gpt-3.5-turbo-0301`, and, reccomend the model `gpt-4-0314`.\n\n\nhttps://www.refuel.ai/blog-posts/gpt-3-5-turbo-model-comparison\nhttps://www.reddit.com/r/ChatGPT/comments/14u51ug/difference_between_gpt432k_and_gpt432k0314/\nhttps://www.reddit.com/r/ChatGPT/comments/14km5xy/anybody_else_notice_that_gpt40314_was_replaced_by/\nhttps://www.reddit.com/r/ChatGPT/comments/156drme/gpt40314_is_better_than_gpt40613_at_generating/\nhttps://stackoverflow.com/questions/75810740/openai-gpt-4-api-what-is-the-difference-between-gpt-4-and-gpt-4-0314-or-gpt-4-0\n\n\n- The original base models `davinci` and `curie`,\nand to some extent, their forks `text-davinci-003` and `text-curie-001`,\ngenerate very interesting responses (good for\n[brainstorming](https://github.com/mountaineerbr/shellChatGPT/discussions/16#discussioncomment-5811670]))!\n\n- Write your customised instruction as plain text file and set that file\nname as the instruction prompt.\n\n- When instruction and/or first prompt are the name of file, the file\nwill be read and its contents set as input, accordingly.\n\n- Set clipboard with the latest response with `option -o`.\n\n- Create a new session (in the history file) named **computing**,\noptionally set instruction for the new session:\n\n    ```\n    chatgpt.sh -cc  /computing\n\n    chatgpt.sh -cc -S'You are a professional software developer.' /computing\n    ```\n\n  This will create a history file named `computing.tsv` in the cache directory.\n--\u003e\n\n\n## 🖼️ Image Generations\n\nGenerate image according to prompt:\n\n    chatgpt.sh -i \"Dark tower in the middle of a field of red roses.\"\n\n    chatgpt.sh -i \"512x512\" \"A tower.\"\n\n\n## Image Variations\n\nGenerate image variation:\n\n    chatgpt.sh -i path/to/image.png\n\n\n## Image Edits\n\n    chatgpt.sh -i path/to/image.png path/to/mask.png \"A pink flamingo.\"\n\n\n### Outpaint - Canvas Extension\n\n![Displaying Image Edits - Extending the Canvas](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/img_edits.gif)\n\nIn this example, a mask is made from the white colour.\n\n\n### Inpaint - Fill in the Gaps\n\n![Showing off Image Edits - Inpaint](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/img_edits2.gif)\n\u003c!-- ![Inpaint, steps](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/img_edits_steps.png) --\u003e\n\nAdding a bat in the night sky.\n\n\n## 🔊 Speech Transcriptions / Translations\n\nGenerate transcription from audio file speech. A prompt to guide the model's style is optional.\nThe prompt should match the speech language:\n\n    chatgpt.sh -w path/to/audio.mp3\n\n    chatgpt.sh -w path/to/audio.mp3 \"en\" \"This is a poem about X.\"\n\n\n**1.** Generate transcription from voice recording, set Portuguese as the language to transcribe to:\n\n    chatgpt.sh -w pt\n\n\nThis also works to transcribe from one language to another.\n\n\n**2.** Transcribe any language speech input **to Japanese** (_prompt_ should be in\nthe same language as the input audio language, preferably):\n\n    chatgpt.sh -w ja \"A job interview is currently being done.\"\n\n\n**3.1** Translate English speech input to Japanese, and generate speech output from the text response.\n\n    chatgpt.sh -wz ja \"Getting directions to famous places in the city.\"\n\n\n**3.2** Also doing it conversely, this gives an opportunity to (manual)\nconversation turns of two speakers of different languages. Below,\na Japanese speaker can translate its voice and generate audio in the target language.\n\n    chatgpt.sh -wz en \"Providing directions to famous places in the city.\"\n\n\n**4.** Translate speech from any language to English:\n\n    chatgpt.sh -W [speech_file]\n\n    chatgpt.sh -W\n\n\nTo retry with the last microphone recording saved in the cache, set\n_speech_file_ as `last` or `retry`.\n\n**NOTE:** Generate **phrasal-level timestamps** double setting `option -ww` or `option -WW`.\nFor **word-level timestamps**, set option `-www` or `-WWW`.\n\n\n![Transcribe speech with timestamps](https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/chat_trans.png)\n\n\n\u003c!-- \n### Code Completions (Codex, _discontinued_)\n\nCodex models are discontinued. Use models davinci or gpt-3.5+.\n\nStart with a commented out code or instruction for the model,\nor ask it in comments to optimise the following code, for example.\n--\u003e\n\n\n## Service Providers\n\nOther than [Ollama](#ollama) and [LocalAI](#localai) local servers,\nthe free service providers are\n[GitHub Models](#github-models),\n[Google Vertex](#google-ai), and \n[Groq](#groq).\n\n\n### LocalAI\n\n#### LocalAI Server\n\nMake sure you have got [mudler's LocalAI](https://github.com/mudler/LocalAI),\nserver set up and running.\n\nThe server can be run as a docker container or a\n[binary can be downloaded](https://github.com/mudler/LocalAI/releases).\n\nCheck LocalAI tutorials\n[Container Images](https://localai.io/basics/getting_started/#container-images),\nand [Run Models Manually](https://localai.io/docs/getting-started/manual)\nfor an idea on how to [download and install](https://localai.io/models/#how-to-install-a-model-from-the-repositories)\na model and set it up.\n\n\u003c!--\n     ┌───────────────────────────────────────────────────┐\n     │                   Fiber v2.50.0                   │\n     │               http://127.0.0.1:8080               │\n     │       (bound on host 0.0.0.0 and port 8080)       │\n     │                                                   │\n     │ Handlers ............. 1  Processes ........... 1 │\n     │ Prefork ....... Disabled  PID ..................1 │\n     └───────────────────────────────────────────────────┘\n--\u003e\n\n\n#### Tips\n\n*1.* Download a binary of `localai` for your system from [Mudler's release GitHub repo](https://github.com/mudler/LocalAI/releases).\n\n*2.* Run `localai run --help` to check comamnd line options and environment variables.\n\n*3.* Set up `$GALLERIES` before starting up the server:\n\n    export GALLERIES='[{\"name\":\"localai\", \"url\":\"github:mudler/localai/gallery/index.yaml\"}]'  #defaults\n\n    export GALLERIES='[{\"name\":\"model-gallery\", \"url\":\"github:go-skynet/model-gallery/index.yaml\"}]'\n\n    export GALLERIES='[{\"name\":\"huggingface\", \"url\": \"github:go-skynet/model-gallery/huggingface.yaml\"}]'\n\n\n\u003c!-- broken huggingface gallery: https://github.com/mudler/LocalAI/issues/2045 --\u003e\n\n\n*4.* Install the model named `phi-2-chat` from a `yaml` file manually, while the server is running:\n\n    curl -L http://localhost:8080/models/apply -H \"Content-Type: application/json\" -d '{ \"config_url\": \"https://raw.githubusercontent.com/mudler/LocalAI/master/embedded/models/phi-2-chat.yaml\" }'\n\n\n#### Running the shell wrapper\n\nFinally, when running `chatgpt.sh`, set the model name:\n\n    chatgpt.sh --localai -cc -m luna-ai-llama2\n\n\nSetting some stop sequences may be needed to prevent the\nmodel from generating text past context:\n\n    chatgpt.sh --localai -cc -m luna-ai-llama2  -s'### User:'  -s'### Response:'\n\n\nOptionally set restart and start sequences for text completions\nendpoint (`option -c`), such as `-s'\\n### User: '  -s'\\n### Response:'`\n(do mind setting newlines *\\n and whitespaces* correctly).\n\nAnd that's it!\n\n\n#### Installing Models\n\nModel names may be printed with `chatgpt.sh -l`. A model may be\nsupplied as argument, so that only that model details are shown.\n\n\n**NOTE:** Model management (downloading and setting up) must follow\nthe LocalAI and Ollama projects guidelines and methods.\n\n\u003c!--\nFor image generation, install Stable Diffusion from the URL\n`github:go-skynet/model-gallery/stablediffusion.yaml`,\nand for speech transcription, download Whisper from the URL\n`github:go-skynet/model-gallery/whisper-base.yaml`. --\u003e\n\u003c!-- LocalAI was only tested with text and chat completion models (vision) --\u003e\n\n\u003c!--\nInstall models with `option -l` or chat command `/models`\nand the `install` keyword.\n\nAlso supply a [model configuration file URL](https://localai.io/models/#how-to-install-a-model-without-a-gallery),\nor if LocalAI server is configured with Galleries,\nset \"_\\\u003cGALLERY\u003e_@_\\\u003cMODEL_NAME\u003e_\".\nGallery defaults to [HuggingFace](https://huggingface.co/).\n\n    # List models\n    chatgpt.sh -l\n\n    # Install\n    chatgpt.sh -l install huggingface@TheBloke/WizardLM-13B-V1-0-Uncensored-SuperHOT-8K-GGML/wizardlm-13b-v1.0-superhot-8k.ggmlv3.q4_K_M.bin\n\n* NOTE: *  I reccomend using LocalAI own binary to install the models!\n--\u003e\n\n\n#### BASE URL Configuration\n\nIf the service provider Base URL is different from the defaults.\n\nThe environment variable `$OPENAI_BASE_URL` is read at invocation.\n\n    export OPENAI_BASE_URL=\"http://127.0.0.1:8080/v1\"\n\n    chatgpt.sh -c -m luna-ai-llama2\n\n\nTo set it a in a more permanent fashion, edit the script\nconfiguration file `.chatgpt.conf`.\n\nUse vim:\n\n    vim ~/.chatgpt.conf\n\n\nOr edit the configuration with a command line option.\n\n    chatgpt.sh -F\n\n\nAnd set the following variable:\n\n    # ~/.chatgpt.conf\n    \n    OPENAI_BASE_URL=\"http://127.0.0.1:8080/v1\"\n\n\n### Ollama\n\nVisit [Ollama repository](https://github.com/ollama/ollama/),\nand follow the instructions to install, download models, and set up\nthe server.\n\nAfter having Ollama server running, set `option -O` (`--ollama`),\nand the name of the model in `chatgpt.sh`:\n\n    chatgpt.sh -cc -O -m llama2\n\n\nIf Ollama server URL is not the defaults `http://localhost:11434`,\nedit `chatgpt.sh` configuration file, and set the following variable:\n\n    # ~/.chatgpt.conf\n    \n    OLLAMA_BASE_URL=\"http://192.168.0.3:11434\"\n\n\n### Google AI\n\nGet a free [API key for Google](https://gemini.google.com/) to be able to\nuse Gemini and vision models. Users have a free bandwidth of 60 requests per minute, and the script offers a basic implementation of the API.\n\nSet the environment variable `$GOOGLE_API_KEY` and run the script\nwith `option --google`, such as:\n\n    chatgpt.sh --google -cc -m gemini-pro-vision\n\n\n*OBS*: Google Gemini vision models _are not_ enabled for multiturn at the API side, so we hack it.\n\nTo list all available models, run `chatgpt.sh --google -l`.\n\n\n### Mistral AI\n\nSet up a [Mistral AI account](https://mistral.ai/),\ndeclare the environment variable `$MISTRAL_API_KEY`,\nand run the script with `option --mistral` for complete integration.\n\u003c!-- $MISTRAL_BASE_URL --\u003e\n\n\n### Groq\n\nSign in to [Groq](https://console.groq.com/playground).\nCreate a new API key or use an existing one to set\nthe environmental variable `$GROQ_API_KEY`.\nRun the script with `option --groq`.\n\nCurrently, **llamma3.1** models are available at lightening speeds!\n\n\n### Anthropic\n\nSign in to [Antropic AI](https://docs.anthropic.com/).\nCreate a new API key or use an existing one to set\nthe environmental variable `$ANTHROPIC_API_KEY`.\nRun the script with `option --anthropic` or `--ant`.\n\nCheck the **Claude-3** models! Run the script as:\n\n```\nchatgpt.sh --anthropic -cc -m claude-3-5-sonnet-20240620\n```\n\n\nThe script also works on **text completions** with models such as\n`claude-2.1`, although the API documentation flags it as deprecated.\n\nTry:\n\n```\nchatgpt.sh --ant -c -m claude-2.1\n```\n\n\n### GitHub Models\n\nGitHub has partnered with Azure to use its infrastructure.\n\nAs a GitHub user, join the [wait list](https://github.com/marketplace/models/waitlist/join)\nand then generate a [personal token](https://github.com/settings/tokens).\nSet the environmental variable `$GITHUB_TOKEN` and run the\nscript with `option --github` or `--git`.\n\nCheck the [on-line model list](https://github.com/marketplace/models)\nor list the available models and their original names with `chatgpt.sh --github -l`.\n\n\n```\nchatgpt.sh --github -cc -m Phi-3-small-8k-instruct\n```\n\nSee also the [GitHub Model Catalog - Getting Started](https://techcommunity.microsoft.com/t5/educator-developer-blog/github-model-catalog-getting-started/ba-p/4212711) page.\n\n\n### Novita AI\n\nNovita AI offers a range of LLM models at exceptional value, including the\nhighly recommended **Llama 3.3** model, which provides the best balance\nof price and performance!\n\nFor an uncensored model, consider **sao10k/l3-70b-euryale-v2.1**\n(creative assistant and role-playing) or\n**cognitivecomputations/dolphin-mixtral-8x22b**.\n\nCreate an API key as per the\n[Quick Start Guide](https://novita.ai/docs/get-started/quickstart.html)\nand export your key as `$NOVITA_API_KEY` to your environment.\n\nNext, run the script such as `chatgpt.sh --novita -cc`.\n\nCheck the [model list web page](https://novita.ai/model-api/product/llm-api)\nand the [price of each model](https://novita.ai/model-api/pricing).\n\nTo list all available models, run `chatgpt.sh --novita -l`. Optionally set a model name with `option -l` to dump model details.\n\nSome models work with the `/completions` endpoint, while others\nwork with the `/chat/completions` endpoint, so the script _does not set the endpoint automatically_! Check model details and web pages to understand their capabilities, and then either run the script with `option -c` (**text completions**) or `options -cc` (**chat completions**).\n\n---\n\nAs an exercise, instead of setting command-line `option --novita`,\nset Novita AI integration manually instead:\n\n\n```\nexport OPENAI_API_KEY=novita-api-key\nexport OPENAI_BASE_URL=\"https://api.novita.ai/v3/openai\"\n\nchatgpt.sh -cc -m meta-llama/llama-3.1-405b-instruct\n```\n\nWe are grateful to Novita AI for their support and collaboration. For more\ninformation, visit [Novita AI](https://novita.ai/).\n\n\n\n### xAI\n\nVisit [xAI Grok](https://docs.x.ai/docs/quickstart#creating-api-key)\nto generate an API key (environment `$XAI_API_KEY`).\n\nRun the script with `option --xai` and also with `option -cc` (chat completions.).\n\nSome models also work with native text completions. For that,\nset command-line `option -c` instead.\n\n\n### DeepSeek\n\nVisit [DeepSeek Webpage](https://platform.deepseek.com/api_keys) to get\nan API key and set envar `$DEEPSEEK_API_KEY`.\n\nRun the script with `option --deepseek`.\nIt works with chat completions  (`option -cc`) and text completions (`option -c`) modes.\n\n\n\u003c!--\n## 🌎 Environment\n\n- Set `$OPENAI_API_KEY` with your OpenAI API key.\n\n- Optionally, set `$CHATGPTRC` with path to the configuration file (run\n`chatgpt.sh -FF` to download a template configuration file.\nDefaults location = `~/.chatgpt.conf`.\n--\u003e\n\n\u003c!--\n## 🐚 Shell Interpreters\n\nThe script can be run with either Bash or Zsh.\n\nThere should be equivalency of features under Bash, and Zsh.\n\nZsh is faster than Bash in respect to some features.\n\nAlthough it should be noted that I test the script under Ksh and Zsh,\nand it is almost never tested under Bash, but so far, Bash seems to be\na little more polished than the other shells [AFAIK](https://github.com/mountaineerbr/shellChatGPT/discussions/13),\nspecially with interactive features.\n\nKsh truncates input at 80 chars when re-editing a prompt. A workaround\nwith this script is to press the up-arrow key once to edit the full prompt.\n\nKsh will mangle multibyte characters when re-editing input. A workaround\nis to move the cursor and press the up-arrow key once to unmangle the input text.\n\nZsh cannot read/load a history file in non-interactive mode,\nso only commands of the running session are available for retrieval in\nnew prompts (with the up-arrow key).\n\nSee [BUGS](https://github.com/mountaineerbr/shellChatGPT/tree/main/man#bugs)\nin the man page.\n--\u003e\n\u003c!-- [Ksh93u+](https://github.com/ksh93/ksh) (~~_avoid_ Ksh2020~~), --\u003e\n\n\n## Arch Linux Users\n\nThis project PKGBUILD is available at the\n[Arch Linux User Repository (*AUR*)](https://aur.archlinux.org/packages/chatgpt.sh)\nto install the software in Arch Linux and derivative distros.\n\nTo install the programme from the AUR, you can use an *AUR helper*\nlike `yay` or `paru`. For example, with `yay`:\n\n    yay -S chatgpt.sh\n\n\n\u003c!--\nThere is a [*PKGBUILD*](pkg/PKGBUILD) file available to install\nthe script and documentation at the right directories\nin Arch Linux and derivative distros.\n\nThis PKGBUILD generates the package `chatgpt.sh-git`.\nBelow is an installation example with just the PKGBUILD.\n\n    cd $(mktemp -d)\n    \n    wget https://gitlab.com/fenixdragao/shellchatgpt/-/raw/main/pkg/PKGBUILD\n     \n    makepkg\n        \n    pacman -U chatgpt.sh-git*.pkg.tar.zst\n\n--\u003e\n\n\n## Termux Users\n\n### Dependencies Termux\n\nInstall the `Termux` and `Termux:API` apps from the *F-Droid store*.\n\nGive all permissions to `Termux:API` in your phone app settings.\n\nWe reccommend to also install `sox`, `ffmpeg`, `pulseaudio`, `imagemagick`, and `vim` (or `nano`).\n\nRemember to execute `termux-setup-storage` to set up access to the phone storage.\n\nIn Termux proper, install the `termux-api` and `termux-tools` packages (`pkg install termux-api termux-tools`).\n\nWhen recording audio (STT, Whisper, `option -w`),\nif `pulseaudio` is configured correctly,\nthe script uses `sox`, `ffmpeg` or other competent software,\notherwise it defaults to `termux-microphone-record`\n\nLikewise, when playing audio (TTS, `option -z`),\ndepending on `pulseaudio` configuration use `sox`, `mpv` or\nfallback to termux wrapper playback (`play-audio` is optional).\n\nTo set the clipboard, it is required `termux-clipboard-set` from the `termux-api` package.\n\n\n### TTS Chat - Removal of Markdown\n\n*Markdown in TTS input* may stutter the model speech generation a little.\nIf `python` modules `markdown` and `bs4` are available, TTS input will\nbe converted to plain text. As fallback, `pandoc` is used if present\n(chat mode only).\n\n\n### Tiktoken\n\nUnder Termux, make sure to have your system updated and installed with\n`python`, `rust`, and `rustc-dev` packages for building `tiktoken`.\n\n    pkg update\n    \n    pkg upgrade\n    \n    pkg install python rust rustc-dev\n    \n    pip install tiktoken\n\n\n### Troubleshoot Termux\n\nIn order to set Termux access to recording the microphone and playing audio\n(with `sox` and `ffmpeg`), follow the instructions below.\n\n**A.** Set `pulseaudio` one time only, execute:\n\n    pulseaudio -k\n    pulseaudio -L \"module-sles-source\" -D\n\n\n**B.** To set a permanent configuration:\n\n1. Kill the process with `pulseaudio -k`.\n2. Add `load-module module-sles-source` to _one of the files_:\n\n```\n~/.config/pulse/default.pa\n/data/data/com.termux/files/usr/etc/pulse/default.pa\n   ```\n\n3. Restart the server with `pulseaudio -D`.\n\n\n**C.** To create a new user `~/.config/pulse/default.pa`, you may start with the following template:\n\n    #!/usr/bin/pulseaudio -nF\n     \n    .include /data/data/com.termux/files/usr/etc/pulse/default.pa\n    load-module module-sles-source\n\n\n\u003c!--\n#### File Access\n\nTo access your Termux files using Android's file manager, install a decent file manager such as `FX File Explorer` from a Play Store and configure it, or run the following command in your Termux terminal:\n\n    am start -a android.intent.action.VIEW -d \"content://com.android.externalstorage.documents/root/primary\"\n\n\nSource: \u003chttps://www.reddit.com/r/termux/comments/182g7np/where_do_i_find_my_things_that_i_downloaded/\u003e --\u003e\n\n\n\u003c!--\nUsers of Termux may have some difficulty compiling the original Ksh93 under Termux.\nAs a workaround, use Ksh emulation from Zsh. To make Zsh emulate Ksh, simply\nadd a symlink to `zsh` under your path with the name `ksh`.\n\nAfter installing Zsh in Termux, create a symlink with:\n\n````\nln -s /data/data/com.termux/files/usr/bin/zsh /data/data/com.termux/files/usr/bin/ksh\n````\n--\u003e\n\n\n## 🎯  Project Objectives\n\n- Main focus on **chat models** (multi-turn, text, image, and audio).\n\n- Implementation of selected features from **OpenAI API version 1**.\n\n- Provide the closest API defaults and let the user customise settings.\n\n\n\u003c!--\n- Première of `chatgpt.sh version 1.0` should occur at the time\n  when OpenAI launches its next major API version update.\n  --\u003e\n\n\u003c!--  I think Ksh developers used to commonly say invalid options were \"illegal\" because they developed software a little like games, so the user ought to follow the rules right, otherwise he would incur in an illegal input or command. That seems fairly reasonable to me!  --\u003e\n\n\n## Roadmap\n\n- We shall decrease development frequency in 2025, hopefully. \u003c!-- LLM models\nin general are not really worth developer efforts sometimes, it is frustating!\n--\u003e\n\n- We plan to gradually wind down development of new features in the near future.\nThe project will enter a maintenance phase from 2025 onwards, focusing primarily\non bug fixes and stability.\n\n- We plan to deprecate the \u003c!-- _image generation_ and --\u003e _image editing_\nspecific endpoints when script code becomes obsolete to work with images.\n\n- Text completions endpoint is planned to be deprecated when there are\nno models compatible with this endpoint anymore.\n\n- The warper is deemed finished in the sense any further updates must\nnot change the user interface significantly.\n\n\n\u003c!-- in these poor circumstances. The models are not worth the value or expectations. --\u003e\n\u003c!--\n- We expect to **go apoptosis**.\n\nEvery project, much like living organisms, follows a lifecycle.\nAs this initiative reaches its natural maturity, we are prepared\nto fail as gracefully as we can. Major usage breaks should follow\nnew and backward-incompatible API changes (incompatible models).\n--\u003e\n\n\u003c!--\nMerry 2024 [Grav Mass!](https://stallman.org/grav-mass.html)\n\n\n![Newton](https://stallman.org/grav-mass.png)\n--\u003e\n\n\u003c!--\n## Distinct Features\n\n- **Run as single** or **multi-turn**, response streaming on by defaults.\n\n- **Text editor interface**, and **multiline prompters**. \n\n- **Manage sessions** and history files.\n\n- Hopefully, default colours are colour-blind friendly.\n\n- **Colour themes** and customisation.\n\n_For a simple python wrapper for_ **tiktoken**,\n_see_ [tkn-cnt.py](https://github.com/mountaineerbr/scripts/blob/main/tkn-cnt.py).\n--\u003e\n\n\n## ⚠️ Limitations\n\n- OpenAI **API version 1** is the focus of the present project implementation.\nOnly selected features of the API will be covered.\n\n- The script _will not execute commands_ on behalf of users.\n\n- This project _doesn't_ support \"Function Calling\", \"Structured Outputs\", nor \"Agents/Operators\".\n\n- We _will not support_ \"Real-Time\" chatting, or video generation / editing.\n\n- Bash shell truncates input on `\\000` (null).\n\n- Bash \"read command\" may not correctly display input buffers larger than\nthe TTY screen size during editing. However, input buffers remain\nunaffected. Use the text editor interface for big prompt editing.\n\n- Garbage in, garbage out. An idiot savant.\n\n- The script logic resembles a bowl of spaghetti code after a cat fight.\n\n- See _LIMITS AND BUGS_ section in the [man page](man/README.md#bugs).\n\n\u003c!--\n- User input must double escape `\\n` and `\\t` to have them as literal sequences.\n  **NO LONGER the case as of v.018**  --\u003e\n\n\n## Bug report\n\nPlease leave bug reports at the\n[GitHub issues page](https://github.com/mountaineerbr/shellChatGPT/issues).\n\n\n## 📖 Help Pages \n\nRead the online [**man page here**](man/README.md).\n\nAlternatively, a help page snippet can be printed with `chatgpt.sh -h`.\n\n\n## 💪 Contributors\n\n***Many Thanks*** to everyone who contributed to this project.\n\n\n- [edshamis](https://www.github.com/edshamis)\n- [johnd0e](https://github.com/johnd0e)\n- [Novita AI's GTM Leo](https://novita.ai/model-api/product/llm-api)\n  \u003c!-- Growth Tech Market --\u003e\n\n\n\u003cbr /\u003e\n\nEveryone is [welcome to submit issues, PRs, and new ideas](https://github.com/mountaineerbr/shellChatGPT/discussions/1)!\n\n## Acknowledgements\n\nThe following projects are worth remarking.\nThey were studied during development of this script and used as referencial code sources.\n\n1. [sigoden's aichat](https://github.com/sigoden/aichat)\n2. [xenodium's chatgpt-shell](https://github.com/xenodium/chatgpt-shell)\n3. [andrew's tgpt](https://github.com/aandrew-me/tgpt)\n4. [TheR1D's shell_gpt](https://github.com/TheR1D/shell_gpt/)\n5. [ErikBjare's gptme](https://github.com/ErikBjare/gptme)\n6. [llm-workflow-engine](https://github.com/llm-workflow-engine/llm-workflow-engine)\n7. [0xacx's chatGPT-shell-cli](https://github.com/0xacx/chatGPT-shell-cli)\n8. [mudler's LocalAI](https://github.com/mudler/LocalAI)\n9. [Ollama](https://github.com/ollama/ollama/)\n10. [Google Gemini](https://gemini.google.com/)\n11. [Groq](https://console.groq.com/docs/api-reference)\n12. [Antropic AI](https://docs.anthropic.com/)\n13. [Novita AI](https://novita.ai/)\n14. [xAI](https://docs.x.ai/docs/quickstart)\n15. [f's awesome-chatgpt-prompts](https://github.com/f/awesome-chatgpt-prompts)\n16. [PlexPt's awesome-chatgpt-prompts-zh](https://github.com/PlexPt/awesome-chatgpt-prompts-zh)\n\u003c!-- 17. [Kardolu's chatgpt-cli](https://github.com/kardolus/chatgpt-cli) --\u003e\n\n\n\u003c!--\nNOTES\n\nIssue: provide basic chat interface\nhttps://github.com/mudler/LocalAI/issues/1535\n\n\nIssue: OpenAI compatibility: Images edits and variants #921\nNow that the groundwork for diffusers support has been done, this is a tracker for implementing variations and edits of the OpenAI spec:\n\n    https://platform.openai.com/docs/guides/images/variations\n    https://platform.openai.com/docs/guides/images/edits\n\nVariations can be likely guided by prompt with img2img and https://github.com/LambdaLabsML/lambda-diffusers#stable-diffusion-image-variations\n\nEdits can be implemented with huggingface/diffusers#1825\nhttps://github.com/mudler/LocalAI/issues/921\n\n\n--\u003e\n\n\n--- \n\n\u003cbr /\u003e\n\n**[The project home is at GitLab](https://gitlab.com/fenixdragao/shellchatgpt)**\n\n\u003chttps://gitlab.com/fenixdragao/shellchatgpt\u003e\n\n\u003cbr /\u003e\n\n_Mirror_\n\n\u003chttps://github.com/mountaineerbr/shellChatGPT\u003e\n\n\n\u003cbr /\u003e\n\u003ca href=\"https://gitlab.com/fenixdragao/shellchatgpt\"\u003e\u003cp align=\"center\"\u003e\n  \u003cimg width=\"128\" height=\"128\" alt=\"ChatGPT by DALL-E, link to GitLab Repo\"\n  src=\"https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/dalle_out20b.png\"\u003e\n\u003c/p\u003e\u003c/a\u003e\n\n\u003c!--\n## Version History\n\nThis is the version number history recorded throughout the script evolution over time.\n\nThe lowest record is **0.06.04** at _3/Mar/2023_ and the highest is **0.57.01** at _May/2024_.\n\n\u003cbr /\u003e\n\u003ca href=\"https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/chatgpt.sh_version_evol.png\"\u003e\u003cp align=\"center\"\u003e\n  \u003cimg width=\"386\" height=\"290\" alt=\"Graph generated by a list of sorted version numbers and through GNUPlot.\" src=\"https://gitlab.com/mountaineerbr/etc/-/raw/main/gfx/chatgpt.sh_version_evol_small.png\"\u003e\n\u003c/p\u003e\u003c/a\u003e\n--\u003e\n\u003c!--\nGraph generated by the following ridiculously convoluted command for some fun!\n\n```\ngit rev-list --all | xargs git grep -e by\\ mountaineerbr | grep chatgpt\\.sh: |\nwhile IFS=:$IFS read com var ver; do ver=${ver##\\# v}; printf \"%s %s\\\\n\" \"$(git log -1 --format=\"%ci\" $com)\" \"${ver%% *}\"; done |\nuniq | sed 's/ /T/; s/ //' | sed 's/\\(.*\\.\\)\\([0-9]\\)\\(\\..*\\)/\\10\\2\\3/' | sed 's/\\(.*\\.\\)\\([0-9]\\)$/\\10\\2/' |\nsed 's/\\(.*\\..*\\)\\.\\(.*\\)/\\1\\2/' | sort -n | grep -v -e'[+-]$' -e 'beta' |\ngnuplot -p -e 'set xdata time' -e 'set timefmt \"%Y-%m-%dT%H:%M:%S%Z\"' -e 'plot \"-\" using 1:2 with lines notitle'\n```\n--\u003e\n\n\u003c!--\n# How many functions are there in the script and their function code line numbers (v0.61.3):\n\n```\n% grep -ce\\^function bin/chatgpt.sh                                                                                                                  22:03\n126\n\n% sed -n '/^function /,/^}/ p ' ~/bin/chatgpt.sh | test.sh | SUM\nSum     : 2477 lines in functions\nMin     : 1 line\nMax     : 473 lines\nAverage : 21 lines per func\nMedian  : 7 lines per func\nValues  : 118+8 functions (one-liner functions not computed)\n```\n--\u003e\n\n\u003c!--\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=mountaineerbr/shellChatGPT\u0026type=Date)](https://star-history.com/#mountaineerbr/shellChatGPT\u0026Date)\n--\u003e\n\n\u003c!-- Estimated value of the project if commissioned: ~$1500 over one year (2023-2024).\n--\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmountaineerbr%2Fshellchatgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmountaineerbr%2Fshellchatgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmountaineerbr%2Fshellchatgpt/lists"}