[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-TheR1D--shell_gpt":3,"tool-TheR1D--shell_gpt":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",152630,2,"2026-04-12T23:33:54",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":79,"owner_twitter":80,"owner_website":81,"owner_url":82,"languages":83,"stars":96,"forks":97,"last_commit_at":98,"license":99,"difficulty_score":32,"env_os":100,"env_gpu":101,"env_ram":101,"env_deps":102,"category_tags":107,"github_topics":108,"view_count":32,"oss_zip_url":125,"oss_zip_packed_at":125,"status":17,"created_at":126,"updated_at":127,"faqs":128,"releases":159},7001,"TheR1D\u002Fshell_gpt","shell_gpt","A command-line productivity tool powered by AI large language models like GPT-5, will help you accomplish your tasks faster and more efficiently.","ShellGPT 是一款由大型语言模型驱动的智能命令行效率工具，旨在帮助开发者在终端内快速完成各类任务。它彻底改变了传统工作中需要频繁切换窗口、打开浏览器搜索语法或查阅文档的低效模式，让用户只需输入自然语言描述，即可直接生成精准的 Shell 命令、代码片段、技术文档甚至分析日志内容。\n\n无论是忘记复杂的 `find` 命令语法，还是需要根据代码差异自动生成 Git 提交信息，亦或是快速排查 Docker 容器报错，ShellGPT 都能即时提供解决方案。其独特之处在于具备强大的环境感知能力，能自动识别用户当前的操作系统（如 Linux、macOS 或 Windows）及 Shell 类型（如 Bash、Zsh 或 PowerShell），从而生成完全适配当前环境的指令。例如，同样的“更新系统”请求，在 macOS 上会生成 `softwareupdate` 命令，而在 Ubuntu 上则会自动转换为 `apt` 指令。此外，它还支持灵活的标准输入输出流操作，可轻松集成到现有的管道工作流中。\n\n这款工具特别适合经常与终端打交道的软件开发人员、运维工程师及技术研究人员。虽然默认配置需调用","ShellGPT 是一款由大型语言模型驱动的智能命令行效率工具，旨在帮助开发者在终端内快速完成各类任务。它彻底改变了传统工作中需要频繁切换窗口、打开浏览器搜索语法或查阅文档的低效模式，让用户只需输入自然语言描述，即可直接生成精准的 Shell 命令、代码片段、技术文档甚至分析日志内容。\n\n无论是忘记复杂的 `find` 命令语法，还是需要根据代码差异自动生成 Git 提交信息，亦或是快速排查 Docker 容器报错，ShellGPT 都能即时提供解决方案。其独特之处在于具备强大的环境感知能力，能自动识别用户当前的操作系统（如 Linux、macOS 或 Windows）及 Shell 类型（如 Bash、Zsh 或 PowerShell），从而生成完全适配当前环境的指令。例如，同样的“更新系统”请求，在 macOS 上会生成 `softwareupdate` 命令，而在 Ubuntu 上则会自动转换为 `apt` 指令。此外，它还支持灵活的标准输入输出流操作，可轻松集成到现有的管道工作流中。\n\n这款工具特别适合经常与终端打交道的软件开发人员、运维工程师及技术研究人员。虽然默认配置需调用 OpenAI API，但它也兼容本地部署的开源模型，为注重隐私或有离线需求的用户提供了更多选择。通过 ShellGPT，你可以将更多精力专注于核心逻辑，让繁琐的命令行操作变得简单高效。","# ShellGPT\nA command-line productivity tool powered by AI large language models (LLM). This command-line tool offers streamlined generation of **shell commands, code snippets, documentation**, eliminating the need for external resources (like Google search). Supports Linux, macOS, Windows and compatible with all major Shells like PowerShell, CMD, Bash, Zsh, etc.\n\nhttps:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fassets\u002F16740832\u002F721ddb19-97e7-428f-a0ee-107d027ddd59\n\n## Installation\n```shell\npip install shell-gpt\n```\nBy default, ShellGPT uses OpenAI's API and GPT-4 model. You'll need an API key, you can generate one [here](https:\u002F\u002Fplatform.openai.com\u002Fapi-keys). You will be prompted for your key which will then be stored in `~\u002F.config\u002Fshell_gpt\u002F.sgptrc`. OpenAI API is not free of charge, please refer to the [OpenAI pricing](https:\u002F\u002Fopenai.com\u002Fpricing) for more information.\n\n> [!TIP]\n> Alternatively, you can use locally hosted open source models which are available for free. To use local models, you will need to run your own LLM backend server such as [Ollama](https:\u002F\u002Fgithub.com\u002Follama\u002Follama). To set up ShellGPT with Ollama, please follow this comprehensive [guide](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FOllama).\n>\n> **❗️Note that ShellGPT is not optimized for local models and may not work as expected.**\n\n## Usage\n**ShellGPT** is designed to quickly analyse and retrieve information. It's useful for straightforward requests ranging from technical configurations to general knowledge.\n```shell\nsgpt \"What is the fibonacci sequence\"\n# -> The Fibonacci sequence is a series of numbers where each number ...\n```\n\nShellGPT accepts prompt from both stdin and command line argument. Whether you prefer piping input through the terminal or specifying it directly as arguments, `sgpt` got you covered. For example, you can easily generate a git commit message based on a diff:\n```shell\ngit diff | sgpt \"Generate git commit message, for my changes\"\n# -> Added main feature details into README.md\n```\n\nYou can analyze logs from various sources by passing them using stdin, along with a prompt. For instance, we can use it to quickly analyze logs, identify errors and get suggestions for possible solutions:\n```shell\ndocker logs -n 20 my_app | sgpt \"check logs, find errors, provide possible solutions\"\n```\n```text\nError Detected: Connection timeout at line 7.\nPossible Solution: Check network connectivity and firewall settings.\nError Detected: Memory allocation failed at line 12.\nPossible Solution: Consider increasing memory allocation or optimizing application memory usage.\n```\n\nYou can also use all kind of redirection operators to pass input:\n```shell\nsgpt \"summarise\" \u003C document.txt\n# -> The document discusses the impact...\nsgpt \u003C\u003C EOF\nWhat is the best way to lear Golang?\nProvide simple hello world example.\nEOF\n# -> The best way to learn Golang...\nsgpt \u003C\u003C\u003C \"What is the best way to learn shell redirects?\"\n# -> The best way to learn shell redirects is through...\n```\n\n\n### Shell commands\nHave you ever found yourself forgetting common shell commands, such as `find`, and needing to look up the syntax online? With `--shell` or shortcut `-s` option, you can quickly generate and execute the commands you need right in the terminal.\n```shell\nsgpt --shell \"find all json files in current folder\"\n# -> find . -type f -name \"*.json\"\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\nShell GPT is aware of OS and `$SHELL` you are using, it will provide shell command for specific system you have. For instance, if you ask `sgpt` to update your system, it will return a command based on your OS. Here's an example using macOS:\n```shell\nsgpt -s \"update my system\"\n# -> sudo softwareupdate -i -a\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\nThe same prompt, when used on Ubuntu, will generate a different suggestion:\n```shell\nsgpt -s \"update my system\"\n# -> sudo apt update && sudo apt upgrade -y\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\nLet's try it with Docker:\n```shell\nsgpt -s \"start nginx container, mount .\u002Findex.html\"\n# -> docker run -d -p 80:80 -v $(pwd)\u002Findex.html:\u002Fusr\u002Fshare\u002Fnginx\u002Fhtml\u002Findex.html nginx\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\nWe can still use pipes to pass input to `sgpt` and generate shell commands:\n```shell\nsgpt -s \"POST localhost with\" \u003C data.json\n# -> curl -X POST -H \"Content-Type: application\u002Fjson\" -d '{\"a\": 1, \"b\": 2}' http:\u002F\u002Flocalhost\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\nApplying additional shell magic in our prompt, in this example passing file names to `ffmpeg`:\n```shell\nls\n# -> 1.mp4 2.mp4 3.mp4\nsgpt -s \"ffmpeg combine $(ls -m) into one video file without audio.\"\n# -> ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -filter_complex \"[0:v] [1:v] [2:v] concat=n=3:v=1 [v]\" -map \"[v]\" out.mp4\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\nIf you would like to pass generated shell command using pipe, you can use `--no-interaction` option. This will disable interactive mode and will print generated command to stdout. In this example we are using `pbcopy` to copy generated command to clipboard:\n```shell\nsgpt -s \"find all json files in current folder\" --no-interaction | pbcopy\n```\n\n\n### Shell integration\nThis is a **very handy feature**, which allows you to use `sgpt` shell completions directly in your terminal, without the need to type `sgpt` with prompt and arguments. Shell integration enables the use of ShellGPT with hotkeys in your terminal, supported by both Bash and ZSH shells. This feature puts `sgpt` completions directly into terminal buffer (input line), allowing for immediate editing of suggested commands.\n\nhttps:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fassets\u002F16740832\u002Fbead0dab-0dd9-436d-88b7-6abfb2c556c1\n\nTo install shell integration, run `sgpt --install-integration` and restart your terminal to apply changes. This will add few lines to your `.bashrc` or `.zshrc` file. After that, you can use `Ctrl+l` (by default) to invoke ShellGPT. When you press `Ctrl+l` it will replace you current input line (buffer) with suggested command. You can then edit it and just press `Enter` to execute.\n\n### Generating code\nBy using the `--code` or `-c` parameter, you can specifically request pure code output, for instance:\n```shell\nsgpt --code \"solve fizz buzz problem using python\"\n```\n\n```python\nfor i in range(1, 101):\n    if i % 3 == 0 and i % 5 == 0:\n        print(\"FizzBuzz\")\n    elif i % 3 == 0:\n        print(\"Fizz\")\n    elif i % 5 == 0:\n        print(\"Buzz\")\n    else:\n        print(i)\n```\nSince it is valid python code, we can redirect the output to a file:  \n```shell\nsgpt --code \"solve classic fizz buzz problem using Python\" > fizz_buzz.py\npython fizz_buzz.py\n# 1\n# 2\n# Fizz\n# 4\n# Buzz\n# ...\n```\n\nWe can also use pipes to pass input:\n```shell\ncat fizz_buzz.py | sgpt --code \"Generate comments for each line of my code\"\n```\n```python\n# Loop through numbers 1 to 100\nfor i in range(1, 101):\n    # Check if number is divisible by both 3 and 5\n    if i % 3 == 0 and i % 5 == 0:\n        # Print \"FizzBuzz\" if number is divisible by both 3 and 5\n        print(\"FizzBuzz\")\n    # Check if number is divisible by 3\n    elif i % 3 == 0:\n        # Print \"Fizz\" if number is divisible by 3\n        print(\"Fizz\")\n    # Check if number is divisible by 5\n    elif i % 5 == 0:\n        # Print \"Buzz\" if number is divisible by 5\n        print(\"Buzz\")\n    # If number is not divisible by 3 or 5, print the number itself\n    else:\n        print(i)\n```\n\n### Chat Mode \nOften it is important to preserve and recall a conversation. `sgpt` creates conversational dialogue with each LLM completion requested. The dialogue can develop one-by-one (chat mode) or interactively, in a REPL loop (REPL mode). Both ways rely on the same underlying object, called a chat session. The session is located at the [configurable](#runtime-configuration-file) `CHAT_CACHE_PATH`.\n\nTo start a conversation, use the `--chat` option followed by a unique session name and a prompt.\n```shell\nsgpt --chat conversation_1 \"please remember my favorite number: 4\"\n# -> I will remember that your favorite number is 4.\nsgpt --chat conversation_1 \"what would be my favorite number + 4?\"\n# -> Your favorite number is 4, so if we add 4 to it, the result would be 8.\n```\n\nYou can use chat sessions to iteratively improve GPT suggestions by providing additional details.  It is possible to use `--code` or `--shell` options to initiate `--chat`:\n```shell\nsgpt --chat conversation_2 --code \"make a request to localhost using python\"\n```\n```python\nimport requests\n\nresponse = requests.get('http:\u002F\u002Flocalhost')\nprint(response.text)\n```\n\nLet's ask LLM to add caching to our request:\n```shell\nsgpt --chat conversation_2 --code \"add caching\"\n```\n```python\nimport requests\nfrom cachecontrol import CacheControl\n\nsess = requests.session()\ncached_sess = CacheControl(sess)\n\nresponse = cached_sess.get('http:\u002F\u002Flocalhost')\nprint(response.text)\n```\n\nSame applies for shell commands:\n```shell\nsgpt --chat conversation_3 --shell \"what is in current folder\"\n# -> ls\nsgpt --chat conversation_3 \"Sort by name\"\n# -> ls | sort\nsgpt --chat conversation_3 \"Concatenate them using FFMPEG\"\n# -> ffmpeg -i \"concat:$(ls | sort | tr '\\n' '|')\" -codec copy output.mp4\nsgpt --chat conversation_3 \"Convert the resulting file into an MP3\"\n# -> ffmpeg -i output.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 final_output.mp3\n```\n\nTo list all the sessions from either conversational mode, use the `--list-chats` or `-lc` option:  \n```shell\nsgpt --list-chats\n# ...\u002Fshell_gpt\u002Fchat_cache\u002Fconversation_1  \n# ...\u002Fshell_gpt\u002Fchat_cache\u002Fconversation_2\n```\n\nTo show all the messages related to a specific conversation, use the `--show-chat` option followed by the session name:\n```shell\nsgpt --show-chat conversation_1\n# user: please remember my favorite number: 4\n# assistant: I will remember that your favorite number is 4.\n# user: what would be my favorite number + 4?\n# assistant: Your favorite number is 4, so if we add 4 to it, the result would be 8.\n```\n\n### REPL Mode  \nThere is very handy REPL (read–eval–print loop) mode, which allows you to interactively chat with GPT models. To start a chat session in REPL mode, use the `--repl` option followed by a unique session name. You can also use \"temp\" as a session name to start a temporary REPL session. Note that `--chat` and `--repl` are using same underlying object, so you can use `--chat` to start a chat session and then pick it up with `--repl` to continue the conversation in REPL mode.\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fs10.gifyu.com\u002Fimages\u002Frepl-demo.gif\" alt=\"gif\">\n\u003C\u002Fp>\n\n```text\nsgpt --repl temp\nEntering REPL mode, press Ctrl+C to exit.\n>>> What is REPL?\nREPL stands for Read-Eval-Print Loop. It is a programming environment ...\n>>> How can I use Python with REPL?\nTo use Python with REPL, you can simply open a terminal or command prompt ...\n```\n\nREPL mode can work with `--shell` and `--code` options, which makes it very handy for interactive shell commands and code generation:\n```text\nsgpt --repl temp --shell\nEntering shell REPL mode, type [e] to execute commands or press Ctrl+C to exit.\n>>> What is in current folder?\nls\n>>> Show file sizes\nls -lh\n>>> Sort them by file sizes\nls -lhS\n>>> e (enter just e to execute commands, or d to describe them)\n```\n\nTo provide multiline prompt use triple quotes `\"\"\"`:\n```text\nsgpt --repl temp\nEntering REPL mode, press Ctrl+C to exit.\n>>> \"\"\"\n... Explain following code:\n... import random\n... print(random.randint(1, 10))\n... \"\"\"\nIt is a Python script that uses the random module to generate and print a random integer.\n```\n\nYou can also enter REPL mode with initial prompt by passing it as an argument or stdin or even both:\n```shell\nsgpt --repl temp \u003C my_app.py\n```\n```text\nEntering REPL mode, press Ctrl+C to exit.\n──────────────────────────────────── Input ────────────────────────────────────\nname = input(\"What is your name?\")\nprint(f\"Hello {name}\")\n───────────────────────────────────────────────────────────────────────────────\n>>> What is this code about?\nThe snippet of code you've provided is written in Python. It prompts the user...\n>>> Follow up questions...\n```\n\n### Function calling  \n[Function calls](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Ffunction-calling) is a powerful feature OpenAI provides. It allows LLM to execute functions in your system, which can be used to accomplish a variety of tasks. To install [default functions](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Ftree\u002Fmain\u002Fsgpt\u002Fllm_functions\u002F) run:\n```shell\nsgpt --install-functions\n```\n\nShellGPT has a convenient way to define functions and use them. In order to create your custom function, navigate to `~\u002F.config\u002Fshell_gpt\u002Ffunctions` and create a new .py file with the function name. Inside this file, you can define your function using this [example](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fblob\u002Fmain\u002Fsgpt\u002Fllm_functions\u002Fcommon\u002Fexecute_shell.py).\n\nThe docstring comment inside the class will be passed to OpenAI API as a description for the function, along with the `title` attribute and parameters descriptions. The `execute` function will be called if LLM decides to use your function. In this case we are allowing LLM to execute any Shell commands in our system. Since we are returning the output of the command, LLM will be able to analyze it and decide if it is a good fit for the prompt. Here is an example how the function might be executed by LLM:\n```shell\nsgpt \"What are the files in \u002Ftmp folder?\"\n# -> @FunctionCall execute_shell_command(shell_command=\"ls \u002Ftmp\")\n# -> The \u002Ftmp folder contains the following files and directories:\n# -> test.txt\n# -> test.json\n```\n\nNote that if for some reason the function (execute_shell_command) will return an error, LLM might try to accomplish the task based on the output. Let's say we don't have installed `jq` in our system, and we ask LLM to parse JSON file:\n```shell\nsgpt \"parse \u002Ftmp\u002Ftest.json file using jq and return only email value\"\n# -> @FunctionCall execute_shell_command(shell_command=\"jq -r '.email' \u002Ftmp\u002Ftest.json\")\n# -> It appears that jq is not installed on the system. Let me try to install it using brew.\n# -> @FunctionCall execute_shell_command(shell_command=\"brew install jq\")\n# -> jq has been successfully installed. Let me try to parse the file again.\n# -> @FunctionCall execute_shell_command(shell_command=\"jq -r '.email' \u002Ftmp\u002Ftest.json\")\n# -> The email value in \u002Ftmp\u002Ftest.json is johndoe@example.\n```\n\nIt is also possible to chain multiple function calls in the prompt:\n```shell\nsgpt \"Play music and open hacker news\"\n# -> @FunctionCall play_music()\n# -> @FunctionCall open_url(url=\"https:\u002F\u002Fnews.ycombinator.com\")\n# -> Music is now playing, and Hacker News has been opened in your browser. Enjoy!\n```\n\nThis is just a simple example of how you can use function calls. It is truly a powerful feature that can be used to accomplish a variety of complex tasks. We have dedicated [category](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fdiscussions\u002Fcategories\u002Ffunctions) in GitHub Discussions for sharing and discussing functions. \nLLM might execute destructive commands, so please use it at your own risk❗️\n\n### Roles\nShellGPT allows you to create custom roles, which can be utilized to generate code, shell commands, or to fulfill your specific needs. To create a new role, use the `--create-role` option followed by the role name. You will be prompted to provide a description for the role, along with other details. This will create a JSON file in `~\u002F.config\u002Fshell_gpt\u002Froles` with the role name. Inside this directory, you can also edit default `sgpt` roles, such as **shell**, **code**, and **default**. Use the `--list-roles` option to list all available roles, and the `--show-role` option to display the details of a specific role. Here's an example of a custom role:\n```shell\nsgpt --create-role json_generator\n# Enter role description: Provide only valid json as response.\nsgpt --role json_generator \"random: user, password, email, address\"\n```\n```json\n{\n  \"user\": \"JohnDoe\",\n  \"password\": \"p@ssw0rd\",\n  \"email\": \"johndoe@example.com\",\n  \"address\": {\n    \"street\": \"123 Main St\",\n    \"city\": \"Anytown\",\n    \"state\": \"CA\",\n    \"zip\": \"12345\"\n  }\n}\n```\n\nIf the description of the role contains the words \"APPLY MARKDOWN\" (case sensitive), then chats will be displayed using markdown formatting unless it is explicitly turned off with `--no-md`.\n\n### Request cache\nControl cache using `--cache` (default) and `--no-cache` options. This caching applies for all `sgpt` requests to OpenAI API:\n```shell\nsgpt \"what are the colors of a rainbow\"\n# -> The colors of a rainbow are red, orange, yellow, green, blue, indigo, and violet.\n```\nNext time, same exact query will get results from local cache instantly. Note that `sgpt \"what are the colors of a rainbow\" --temperature 0.5` will make a new request, since we didn't provide `--temperature` (same applies to `--top-probability`) on previous request.\n\nThis is just some examples of what we can do using OpenAI GPT models, I'm sure you will find it useful for your specific use cases.\n\n### Runtime configuration file\nYou can setup some parameters in runtime configuration file `~\u002F.config\u002Fshell_gpt\u002F.sgptrc`:\n```text\n# API key, also it is possible to define OPENAI_API_KEY env.\nOPENAI_API_KEY=your_api_key\n# Base URL of the backend server. If \"default\" URL will be resolved based on --model.\nAPI_BASE_URL=default\n# Max amount of cached message per chat session.\nCHAT_CACHE_LENGTH=100\n# Chat cache folder.\nCHAT_CACHE_PATH=\u002Ftmp\u002Fshell_gpt\u002Fchat_cache\n# Request cache length (amount).\nCACHE_LENGTH=100\n# Request cache folder.\nCACHE_PATH=\u002Ftmp\u002Fshell_gpt\u002Fcache\n# Request timeout in seconds.\nREQUEST_TIMEOUT=60\n# Default OpenAI model to use.\nDEFAULT_MODEL=gpt-4o\n# Default color for shell and code completions.\nDEFAULT_COLOR=magenta\n# When in --shell mode, default to \"Y\" for no input.\nDEFAULT_EXECUTE_SHELL_CMD=false\n# Disable streaming of responses\nDISABLE_STREAMING=false\n# The pygment theme to view markdown (default\u002Fdescribe role).\nCODE_THEME=default\n# Path to a directory with functions.\nOPENAI_FUNCTIONS_PATH=\u002FUsers\u002Fuser\u002F.config\u002Fshell_gpt\u002Ffunctions\n# Print output of functions when LLM uses them.\nSHOW_FUNCTIONS_OUTPUT=false\n# Allows LLM to use functions.\nOPENAI_USE_FUNCTIONS=true\n# Enforce LiteLLM usage (for local LLMs).\nUSE_LITELLM=false\n```\nPossible options for `DEFAULT_COLOR`: black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white.\nPossible options for `CODE_THEME`: https:\u002F\u002Fpygments.org\u002Fstyles\u002F\n\n### Full list of arguments\n```text\n╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────╮\n│   prompt      [PROMPT]  The prompt to generate completions for.                                          │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ --model            TEXT                       Large language model to use. [default: gpt-4o]             │\n│ --temperature      FLOAT RANGE [0.0\u003C=x\u003C=2.0]  Randomness of generated output. [default: 0.0]             │\n│ --top-p            FLOAT RANGE [0.0\u003C=x\u003C=1.0]  Limits highest probable tokens (words). [default: 1.0]     │\n│ --md             --no-md                      Prettify markdown output. [default: md]                    │\n│ --editor                                      Open $EDITOR to provide a prompt. [default: no-editor]     │\n│ --cache                                       Cache completion results. [default: cache]                 │\n│ --version                                     Show version.                                              │\n│ --help                                        Show this message and exit.                                │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ Assistance Options ─────────────────────────────────────────────────────────────────────────────────────╮\n│ --shell           -s                      Generate and execute shell commands.                           │\n│ --interaction         --no-interaction    Interactive mode for --shell option. [default: interaction]    │\n│ --describe-shell  -d                      Describe a shell command.                                      │\n│ --code            -c                      Generate only code.                                            │\n│ --functions           --no-functions      Allow function calls. [default: functions]                     │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ Chat Options ───────────────────────────────────────────────────────────────────────────────────────────╮\n│ --chat                 TEXT  Follow conversation with id, use \"temp\" for quick session. [default: None]  │\n│ --repl                 TEXT  Start a REPL (Read–eval–print loop) session. [default: None]                │\n│ --show-chat            TEXT  Show all messages from provided chat id. [default: None]                    │\n│ --list-chats  -lc            List all existing chat ids.                                                 │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ Role Options ───────────────────────────────────────────────────────────────────────────────────────────╮\n│ --role                  TEXT  System role for GPT model. [default: None]                                 │\n│ --create-role           TEXT  Create role. [default: None]                                               │\n│ --show-role             TEXT  Show role. [default: None]                                                 │\n│ --list-roles   -lr            List roles.                                                                │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n```\n\n## Docker\nRun the container using the `OPENAI_API_KEY` environment variable, and a docker volume to store cache. Consider to set the environment variables `OS_NAME` and `SHELL_NAME` according to your preferences.\n```shell\ndocker run --rm \\\n           --env OPENAI_API_KEY=api_key \\\n           --env OS_NAME=$(uname -s) \\\n           --env SHELL_NAME=$(echo $SHELL) \\\n           --volume gpt-cache:\u002Ftmp\u002Fshell_gpt \\\n       ghcr.io\u002Fther1d\u002Fshell_gpt -s \"update my system\"\n```\n\nExample of a conversation, using an alias and the `OPENAI_API_KEY` environment variable:\n```shell\nalias sgpt=\"docker run --rm --volume gpt-cache:\u002Ftmp\u002Fshell_gpt --env OPENAI_API_KEY --env OS_NAME=$(uname -s) --env SHELL_NAME=$(echo $SHELL) ghcr.io\u002Fther1d\u002Fshell_gpt\"\nexport OPENAI_API_KEY=\"your OPENAI API key\"\nsgpt --chat rainbow \"what are the colors of a rainbow\"\nsgpt --chat rainbow \"inverse the list of your last answer\"\nsgpt --chat rainbow \"translate your last answer in french\"\n```\n\nYou also can use the provided `Dockerfile` to build your own image:\n```shell\ndocker build -t sgpt .\n```\n\n### Docker + Ollama\n\nIf you want to send your requests to an Ollama instance and run ShellGPT inside a Docker container, you need to adjust the Dockerfile and build the container yourself: the litellm package is needed and env variables need to be set correctly.\n\nExample Dockerfile:\n```\nFROM python:3-slim\n\nENV DEFAULT_MODEL=ollama\u002Fmistral:7b-instruct-v0.2-q4_K_M\nENV API_BASE_URL=http:\u002F\u002F10.10.10.10:11434\nENV USE_LITELLM=true\nENV OPENAI_API_KEY=bad_key\nENV SHELL_INTERACTION=false\nENV PRETTIFY_MARKDOWN=false\nENV OS_NAME=\"Arch Linux\"\nENV SHELL_NAME=auto\n\nWORKDIR \u002Fapp\nCOPY . \u002Fapp\n\nRUN apt-get update && apt-get install -y gcc\nRUN pip install --no-cache \u002Fapp[litellm] && mkdir -p \u002Ftmp\u002Fshell_gpt\n\nVOLUME \u002Ftmp\u002Fshell_gpt\n\nENTRYPOINT [\"sgpt\"]\n```\n\n\n## Additional documentation\n* [Azure integration](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FAzure)\n* [Ollama integration](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FOllama)\n","# ShellGPT\n一款由人工智能大型语言模型（LLM）驱动的命令行生产力工具。该命令行工具能够高效生成**Shell 命令、代码片段和文档**，从而无需借助外部资源（如 Google 搜索）。支持 Linux、macOS 和 Windows 系统，并兼容所有主流 Shell，例如 PowerShell、CMD、Bash、Zsh 等。\n\nhttps:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fassets\u002F16740832\u002F721ddb19-97e7-428f-a0ee-107d027ddd59\n\n## 安装\n```shell\npip install shell-gpt\n```\n默认情况下，ShellGPT 使用 OpenAI 的 API 和 GPT-4 模型。您需要一个 API 密钥，可以在[这里](https:\u002F\u002Fplatform.openai.com\u002Fapi-keys)生成。系统会提示您输入密钥，该密钥将被存储在 `~\u002F.config\u002Fshell_gpt\u002F.sgptrc` 文件中。OpenAI API 并非免费，请参阅 [OpenAI 定价](https:\u002F\u002Fopenai.com\u002Fpricing) 以获取更多信息。\n\n> [!TIP]\n> 或者，您也可以使用本地部署的开源模型，这些模型是免费的。要使用本地模型，您需要运行自己的 LLM 后端服务器，例如 [Ollama](https:\u002F\u002Fgithub.com\u002Follama\u002Follama)。要将 ShellGPT 与 Ollama 配合使用，请按照这份全面的[指南](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FOllama)进行操作。\n>\n> **❗️请注意，ShellGPT 并未针对本地模型进行优化，可能无法按预期工作。**\n\n## 使用方法\n**ShellGPT** 旨在快速分析和检索信息。它适用于从技术配置到通用知识等各类简单请求。\n```shell\nsgpt \"什么是斐波那契数列\"\n# -> 斐波那契数列是一系列数字，其中每个数字 ...\n```\n\nShellGPT 可以接受来自标准输入和命令行参数的提示。无论您是喜欢通过终端管道传递输入，还是直接将其作为参数指定，`sgpt` 都能满足您的需求。例如，您可以根据差异轻松生成 Git 提交信息：\n```shell\ngit diff | sgpt \"为我的更改生成 Git 提交信息\"\n# -> 在 README.md 中添加了主要功能详情\n```\n\n您可以通过标准输入将来自不同来源的日志传递给 ShellGPT，并附上提示，从而对其进行分析。例如，我们可以用它快速分析日志、识别错误并提供可能的解决方案：\n```shell\ndocker logs -n 20 my_app | sgpt \"检查日志，查找错误，并提供可能的解决方案\"\n```\n```text\n检测到错误：第 7 行出现连接超时。\n可能的解决方案：检查网络连接和防火墙设置。\n检测到错误：第 12 行内存分配失败。\n可能的解决方案：考虑增加内存分配或优化应用程序的内存使用。\n```\n\n您还可以使用各种重定向运算符来传递输入：\n```shell\nsgpt \"总结\" \u003C document.txt\n# -> 该文档讨论了影响...\nsgpt \u003C\u003C EOF\n学习 Go 语言的最佳方式是什么？\n请提供一个简单的 Hello World 示例。\nEOF\n# -> 学习 Go 语言的最佳方式...\nsgpt \u003C\u003C\u003C \"学习 Shell 重定向的最佳方式是什么？\"\n# -> 学习 Shell 重定向的最佳方式是通过...\"\n```\n\n\n### Shell 命令\n您是否曾经忘记过一些常用的 Shell 命令，比如 `find`，不得不上网查找语法？借助 `--shell` 或简写 `-s` 选项，您可以在终端中快速生成并执行所需的命令。\n```shell\nsgpt --shell \"查找当前目录下的所有 JSON 文件\"\n# -> find . -type f -name \"*.json\"\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\nShell GPT 会识别您使用的操作系统和 `$SHELL` 环境变量，并为您所在的具体系统提供相应的 Shell 命令。例如，如果您让 `sgpt` 更新您的系统，它会根据您的操作系统返回一条命令。以下是在 macOS 上的一个示例：\n```shell\nsgpt -s \"更新我的系统\"\n# -> sudo softwareupdate -i -a\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\n同样的提示，在 Ubuntu 上则会产生不同的建议：\n```shell\nsgpt -s \"更新我的系统\"\n# -> sudo apt update && sudo apt upgrade -y\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\n让我们再试试 Docker：\n```shell\nsgpt -s \"启动 Nginx 容器，挂载 .\u002Findex.html\"\n# -> docker run -d -p 80:80 -v $(pwd)\u002Findex.html:\u002Fusr\u002Fshare\u002Fnginx\u002Fhtml\u002Findex.html nginx\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\n我们仍然可以使用管道将输入传递给 `sgpt` 并生成 Shell 命令：\n```shell\nsgpt -s \"向 localhost 发送 POST 请求，数据为\" \u003C data.json\n# -> curl -X POST -H \"Content-Type: application\u002Fjson\" -d '{\"a\": 1, \"b\": 2}' http:\u002F\u002Flocalhost\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\n在提示中应用额外的 Shell 技巧，例如将文件名传递给 `ffmpeg`：\n```shell\nls\n# -> 1.mp4 2.mp4 3.mp4\nsgpt -s \"使用 ffmpeg 将 $(ls -m) 合并成一个不含音频的视频文件。\"\n# -> ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -filter_complex \"[0:v] [1:v] [2:v] concat=n=3:v=1 [v]\" -map \"[v]\" out.mp4\n# -> [E]xecute, [D]escribe, [A]bort: e\n```\n\n如果您希望通过管道传递生成的 Shell 命令，可以使用 `--no-interaction` 选项。这将禁用交互模式，并将生成的命令输出到标准输出。在下面的例子中，我们使用 `pbcopy` 将生成的命令复制到剪贴板：\n```shell\nsgpt -s \"查找当前目录下的所有 JSON 文件\" --no-interaction | pbcopy\n```\n\n\n### Shell 集成\n这是一项**非常实用的功能**，它允许您直接在终端中使用 `sgpt` 的 Shell 补全功能，而无需键入 `sgpt` 及其提示和参数。Shell 集成使您能够在终端中通过快捷键使用 ShellGPT，Bash 和 ZSH 壳都支持此功能。该功能会将 `sgpt` 的补全内容直接插入终端缓冲区（输入行），以便您立即编辑建议的命令。\n\nhttps:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fassets\u002F16740832\u002Fbead0dab-0dd9-436d-88b7-6abfb2c556c1\n\n要安装 Shell 集成，请运行 `sgpt --install-integration`，然后重启终端以使更改生效。这将在您的 `.bashrc` 或 `.zshrc` 文件中添加几行内容。之后，您可以使用 `Ctrl+l`（默认快捷键）调用 ShellGPT。按下 `Ctrl+l` 后，当前的输入行（缓冲区）将被建议的命令替换。您可以对其进行编辑，然后直接按 `Enter` 执行。\n\n### 生成代码\n通过使用 `--code` 或 `-c` 参数，您可以专门请求纯代码输出，例如：\n```shell\nsgpt --code \"用 Python 解决 Fizz Buzz 问题\"\n```\n\n```python\nfor i in range(1, 101):\n    if i % 3 == 0 and i % 5 == 0:\n        print(\"FizzBuzz\")\n    elif i % 3 == 0:\n        print(\"Fizz\")\n    elif i % 5 == 0:\n        print(\"Buzz\")\n    else:\n        print(i)\n```\n由于这是有效的 Python 代码，我们可以将其重定向到一个文件：\n```shell\nsgpt --code \"用 Python 解决经典的 Fizz Buzz 问题\" > fizz_buzz.py\npython fizz_buzz.py\n# 1\n# 2\n# Fizz\n# 4\n# Buzz\n# ...\n```\n\n我们也可以使用管道传递输入：\n```shell\ncat fizz_buzz.py | sgpt --code \"为我代码的每一行生成注释\"\n```\n```python\n\n# 遍历数字 1 到 100\nfor i in range(1, 101):\n    # 检查数字是否同时能被 3 和 5 整除\n    if i % 3 == 0 and i % 5 == 0:\n        # 如果数字能被 3 和 5 整除，打印 \"FizzBuzz\"\n        print(\"FizzBuzz\")\n    # 检查数字是否能被 3 整除\n    elif i % 3 == 0:\n        # 如果数字能被 3 整除，打印 \"Fizz\"\n        print(\"Fizz\")\n    # 检查数字是否能被 5 整除\n    elif i % 5 == 0:\n        # 如果数字能被 5 整除，打印 \"Buzz\"\n        print(\"Buzz\")\n    # 如果数字既不能被 3 整除，也不能被 5 整除，就打印该数字本身\n    else:\n        print(i)\n```\n\n### 聊天模式  \n在很多情况下，保存和回顾对话非常重要。`sgpt` 在每次请求 LLM 完成时都会创建一个对话记录。这些对话可以逐条进行（聊天模式），也可以通过 REPL 循环以交互方式展开（REPL 模式）。这两种方式都依赖于同一个底层对象，称为聊天会话。会话存储在可配置的 `CHAT_CACHE_PATH` 中。\n\n要开始一次对话，使用 `--chat` 选项，后接唯一的会话名称和提示语。\n```shell\nsgpt --chat conversation_1 \"请记住我最喜欢的数字是：4\"\n# -> 我会记住你最喜欢的数字是4。\nsgpt --chat conversation_1 \"那我最喜欢的数字加4是多少呢？\"\n# -> 你最喜欢的数字是4，所以加上4就是8。\n```\n\n你可以利用聊天会话逐步完善 GPT 的建议，提供更多的细节。还可以结合 `--code` 或 `--shell` 选项来启动聊天：\n```shell\nsgpt --chat conversation_2 --code \"用 Python 向 localhost 发送请求\"\n```\n```python\nimport requests\n\nresponse = requests.get('http:\u002F\u002Flocalhost')\nprint(response.text)\n```\n\n现在我们让 LLM 为我们的请求添加缓存功能：\n```shell\nsgpt --chat conversation_2 --code \"添加缓存\"\n```\n```python\nimport requests\nfrom cachecontrol import CacheControl\n\nsess = requests.session()\ncached_sess = CacheControl(sess)\n\nresponse = cached_sess.get('http:\u002F\u002Flocalhost')\nprint(response.text)\n```\n\n同样的方法也适用于 Shell 命令：\n```shell\nsgpt --chat conversation_3 --shell \"当前目录下有什么内容？\"\n# -> ls\nsgpt --chat conversation_3 \"按文件名排序\"\n# -> ls | sort\nsgpt --chat conversation_3 \"用 FFMPEG 将它们拼接起来\"\n# -> ffmpeg -i \"concat:$(ls | sort | tr '\\n' '|')\" -codec copy output.mp4\nsgpt --chat conversation_3 \"将生成的文件转换为 MP3\"\n# -> ffmpeg -i output.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 final_output.mp3\n```\n\n要列出所有会话，无论是聊天模式还是其他模式，都可以使用 `--list-chats` 或 `-lc` 选项：\n```shell\nsgpt --list-chats\n# ...\u002Fshell_gpt\u002Fchat_cache\u002Fconversation_1  \n# ...\u002Fshell_gpt\u002Fchat_cache\u002Fconversation_2\n```\n\n要查看特定会话的所有消息，使用 `--show-chat` 选项并指定会话名称：\n```shell\nsgpt --show-chat conversation_1\n# 用户: 请记住我最喜欢的数字是：4\n# 助手: 我会记住你最喜欢的数字是4。\n# 用户: 那我最喜欢的数字加4是多少呢？\n# 助手: 你最喜欢的数字是4，所以加上4就是8。\n```\n\n### REPL 模式  \n还有一种非常方便的 REPL（读取-求值-打印循环）模式，允许你与 GPT 模型进行交互式对话。要在 REPL 模式下启动聊天会话，使用 `--repl` 选项并指定一个唯一的会话名称。你也可以使用“temp”作为会话名称来启动一个临时的 REPL 会话。需要注意的是，`--chat` 和 `--repl` 使用的是同一个底层对象，因此你可以先用 `--chat` 启动一个会话，然后再用 `--repl` 继续以 REPL 模式进行对话。\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fs10.gifyu.com\u002Fimages\u002Frepl-demo.gif\" alt=\"gif\">\n\u003C\u002Fp>\n\n```text\nsgpt --repl temp\n进入 REPL 模式，按 Ctrl+C 退出。\n>>> 什么是 REPL？\nREPL 是指读取-求值-打印循环。它是一种编程环境…\n>>> 如何在 REPL 中使用 Python？\n要在 REPL 中使用 Python，只需打开终端或命令提示符…\n```\n\nREPL 模式可以配合 `--shell` 和 `--code` 选项使用，这使得它非常适合交互式 Shell 命令和代码生成：\n```text\nsgpt --repl temp --shell\n进入 Shell REPL 模式，输入 [e] 执行命令，或按 Ctrl+C 退出。\n>>> 当前目录下有什么内容？\nls\n>>> 显示文件大小\nls -lh\n>>> 按文件大小排序\nls -lhS\n>>> e（只需输入 e 即可执行命令，或输入 d 描述命令）\n```\n\n如果需要多行提示，可以使用三重引号 `\"\"\"`：\n```text\nsgpt --repl temp\n进入 REPL 模式，按 Ctrl+C 退出。\n>>> \"\"\"\n... 解释以下代码：\n... import random\n... print(random.randint(1, 10))\n... \"\"\"\n这是一个 Python 脚本，使用 random 模块生成并打印一个随机整数。\n```\n\n你还可以通过传递参数、标准输入，甚至两者结合的方式，直接进入带有初始提示的 REPL 模式：\n```shell\nsgpt --repl temp \u003C my_app.py\n```\n```text\n进入 REPL 模式，按 Ctrl+C 退出。\n──────────────────────────────────── 输入 ────────────────────────────────────\nname = input(\"你的名字是什么？\")\nprint(f\"你好，{name}\")\n───────────────────────────────────────────────────────────────────────────────\n>>> 这段代码是关于什么的？\n你提供的这段代码是用 Python 编写的。它会提示用户…\n>>> 接下来的问题…\n```\n\n### 函数调用  \n[函数调用](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Ffunction-calling)是 OpenAI 提供的一项强大功能。它允许 LLM 在你的系统中执行函数，从而完成各种任务。要安装默认函数，请运行：\n```shell\nsgpt --install-functions\n```\n\nShellGPT 提供了一种便捷的方式来定义和使用函数。要创建自定义函数，导航到 `~\u002F.config\u002Fshell_gpt\u002Ffunctions` 目录，然后创建一个新的 `.py` 文件，文件名即为函数名称。在这个文件中，你可以参考这个示例来定义你的函数：\n```python\n# 示例：execute_shell.py\nclass ExecuteShell:\n    \"\"\"执行任意 Shell 命令，并返回输出结果。\n    参数:\n        shell_command (str): 要执行的 Shell 命令。\n    返回:\n        str: Shell 命令的输出结果。\n    \"\"\"\n\n    def __init__(self, shell_command):\n        self.shell_command = shell_command\n\n    def execute(self):\n        import subprocess\n        result = subprocess.run(self.shell_command, shell=True, capture_output=True, text=True)\n        return result.stdout\n```\n\n类中的文档字符串注释会作为函数描述传递给 OpenAI API，同时还会包含 `title` 属性及参数说明。当 LLM 决定调用你的函数时，就会执行 `execute` 方法。例如，我们这里允许 LLM 在系统中执行任何 Shell 命令。由于我们会返回命令的输出结果，LLM 可以分析这些结果，判断是否符合当前的提示要求。以下是 LLM 调用此函数的一个示例：\n```shell\nsgpt \"请问 \u002Ftmp 目录下有哪些文件？\"\n# -> @FunctionCall execute_shell_command(shell_command=\"ls \u002Ftmp\")\n# -> \u002Ftmp 目录下有以下文件和目录：\n# -> test.txt\n\n# -> test.json\n```\n\n请注意，如果由于某种原因函数（execute_shell_command）会返回错误，LLM 可能会尝试根据输出来完成任务。假设我们的系统中没有安装 `jq`，而我们让 LLM 解析 JSON 文件：\n```shell\nsgpt \"使用 jq 解析 \u002Ftmp\u002Ftest.json 文件，并只返回 email 值\"\n# -> @FunctionCall execute_shell_command(shell_command=\"jq -r '.email' \u002Ftmp\u002Ftest.json\")\n# -> 似乎系统中未安装 jq。让我尝试用 brew 安装它。\n# -> @FunctionCall execute_shell_command(shell_command=\"brew install jq\")\n# -> jq 已成功安装。让我再试一次解析文件。\n# -> @FunctionCall execute_shell_command(shell_command=\"jq -r '.email' \u002Ftmp\u002Ftest.json\")\n# -> \u002Ftmp\u002Ftest.json 中的 email 值是 johndoe@example.com。\n```\n\n在提示中也可以串联多个函数调用：\n```shell\nsgpt \"播放音乐并打开 Hacker News\"\n# -> @FunctionCall play_music()\n# -> @FunctionCall open_url(url=\"https:\u002F\u002Fnews.ycombinator.com\")\n# -> 音乐正在播放，Hacker News 已在您的浏览器中打开。祝您享受！\n```\n\n这只是一个简单的示例，展示了如何使用函数调用。它确实是一项强大的功能，可用于完成各种复杂任务。我们在 GitHub Discussions 中专门设立了[类别](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fdiscussions\u002Fcategories\u002Ffunctions)，用于分享和讨论函数。\n\n需要注意的是，LLM 可能会执行破坏性命令，请务必自行承担风险❗️\n\n### 角色\nShellGPT 允许您创建自定义角色，这些角色可以用来生成代码、Shell 命令，或满足您的特定需求。要创建新角色，使用 `--create-role` 选项，后接角色名称。系统会提示您提供该角色的描述以及其他详细信息。这将在 `~\u002F.config\u002Fshell_gpt\u002Froles` 目录下创建一个以角色名称命名的 JSON 文件。在此目录中，您还可以编辑默认的 `sgpt` 角色，例如 **shell**、**code** 和 **default**。使用 `--list-roles` 选项列出所有可用角色，使用 `--show-role` 选项显示特定角色的详细信息。以下是一个自定义角色的示例：\n```shell\nsgpt --create-role json_generator\n# 输入角色描述：仅提供有效的 JSON 作为响应。\nsgpt --role json_generator \"random: user, password, email, address\"\n```\n```json\n{\n  \"user\": \"JohnDoe\",\n  \"password\": \"p@ssw0rd\",\n  \"email\": \"johndoe@example.com\",\n  \"address\": {\n    \"street\": \"123 Main St\",\n    \"city\": \"Anytown\",\n    \"state\": \"CA\",\n    \"zip\": \"12345\"\n  }\n}\n```\n\n如果角色描述中包含“APPLY MARKDOWN”（区分大小写），则聊天将以 Markdown 格式显示，除非使用 `--no-md` 显式关闭。\n\n### 请求缓存\n使用 `--cache`（默认）和 `--no-cache` 选项控制缓存。此缓存适用于所有向 OpenAI API 发出的 `sgpt` 请求：\n```shell\nsgpt \"彩虹有哪些颜色\"\n# -> 彩虹的颜色有红色、橙色、黄色、绿色、蓝色、靛色和紫色。\n```\n下次输入完全相同的查询时，结果将立即从本地缓存中获取。请注意，`sgpt \"彩虹有哪些颜色\" --temperature 0.5` 将发起新的请求，因为在之前的请求中我们没有提供 `--temperature`（同样适用于 `--top-probability`）。\n\n以上只是利用 OpenAI GPT 模型所能实现的一些示例，我相信它们对您的具体用法也会很有帮助。\n\n### 运行时配置文件\n您可以在运行时配置文件 `~\u002F.config\u002Fshell_gpt\u002F.sgptrc` 中设置一些参数：\n```text\n# API 密钥，也可以通过 OPENAI_API_KEY 环境变量定义。\nOPENAI_API_KEY=your_api_key\n# 后端服务器的基础 URL。若为\"default\"，URL 将根据 --model 自动解析。\nAPI_BASE_URL=default\n# 每次聊天会话中缓存的消息最大数量。\nCHAT_CACHE_LENGTH=100\n# 聊天缓存文件夹。\nCHAT_CACHE_PATH=\u002Ftmp\u002Fshell_gpt\u002Fchat_cache\n# 请求缓存的数量上限。\nCACHE_LENGTH=100\n# 请求缓存文件夹。\nCACHE_PATH=\u002Ftmp\u002Fshell_gpt\u002Fcache\n# 请求超时时间（秒）。\nREQUEST_TIMEOUT=60\n# 默认使用的 OpenAI 模型。\nDEFAULT_MODEL=gpt-4o\n# Shell 和代码补全的默认颜色。\nDEFAULT_COLOR=magenta\n# 在 --shell 模式下，默认为\"N\"表示无需输入。\nDEFAULT_EXECUTE_SHELL_CMD=false\n# 禁用响应流式传输。\nDISABLE_STREAMING=false\n# 查看 Markdown 时使用的 Pygments 主题（默认\u002F角色描述）。\nCODE_THEME=default\n# 函数目录的路径。\nOPENAI_FUNCTIONS_PATH=\u002FUsers\u002Fuser\u002F.config\u002Fshell_gpt\u002Ffunctions\n# 当 LLM 使用函数时，打印函数的输出。\nSHOW_FUNCTIONS_OUTPUT=false\n# 允许 LLM 使用函数。\nOPENAI_USE_FUNCTIONS=true\n# 强制使用 LiteLLM（用于本地 LLM）。\nUSE_LITELLM=false\n```\n\n`DEFAULT_COLOR` 的可选值包括：黑色、红色、绿色、黄色、蓝色、洋红、青色、白色、亮黑色、亮红色、亮绿色、亮黄色、亮蓝色、亮洋红、亮青色、亮白色。\n\n`CODE_THEME` 的可选值请参考：https:\u002F\u002Fpygments.org\u002Fstyles\u002F\n\n### 参数完整列表\n```text\n╭─ 参数 ──────────────────────────────────────────────────────────────────────────────────────────────╮\n│   prompt      [PROMPT]  用于生成补全的提示词。                                          │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ 选项 ────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ --model            TEXT                       使用的大语言模型。[默认值：gpt-4o]             │\n│ --temperature      FLOAT RANGE [0.0\u003C=x\u003C=2.0]  生成输出的随机性。[默认值：0.0]             │\n│ --top-p            FLOAT RANGE [0.0\u003C=x\u003C=1.0]  限制最可能的标记（单词）。[默认值：1.0]     │\n│ --md             --no-md                      格式化 Markdown 输出。[默认值：md]                    │\n│ --editor                                      打开 $EDITOR 提供提示词。[默认值：不使用编辑器]     │\n│ --cache                                       缓存补全结果。[默认值：缓存]                 │\n│ --version                                     显示版本信息。                                              │\n│ --help                                        显示此消息并退出。                                │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ 辅助选项 ─────────────────────────────────────────────────────────────────────────────────────────────╮\n│ --shell           -s                      生成并执行 Shell 命令。                           │\n│ --interaction         --no-interaction    --shell 选项的交互模式。[默认值：交互]    │\n│ --describe-shell  -d                      描述一个 Shell 命令。                                      │\n│ --code            -c                      仅生成代码。                                            │\n│ --functions           --no-functions      允许函数调用。[默认值：允许函数调用]                     │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ 聊天选项 ───────────────────────────────────────────────────────────────────────────────────────────╮\n│ --chat                 TEXT  按照会话 ID 继续对话，使用 \"temp\" 进行快速会话。[默认值：无]  │\n│ --repl                 TEXT  启动 REPL（读取-求值-打印循环）会话。[默认值：无]                │\n│ --show-chat            TEXT  显示指定会话 ID 的所有消息。[默认值：无]                    │\n│ --list-chats  -lc            列出所有现有的会话 ID。                                                 │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ 角色选项 ───────────────────────────────────────────────────────────────────────────────────────────╮\n│ --role                  TEXT  GPT 模型的系统角色。[默认值：无]                                 │\n│ --create-role           TEXT  创建角色。[默认值：无]                                               │\n│ --show-role             TEXT  显示角色。[默认值：无]                                                 │\n│ --list-roles   -lr            列出角色。                                                                │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n```\n\n## Docker\n使用 `OPENAI_API_KEY` 环境变量和一个 Docker 卷来存储缓存，运行容器。可以根据自己的偏好设置 `OS_NAME` 和 `SHELL_NAME` 环境变量。\n```shell\ndocker run --rm \\\n           --env OPENAI_API_KEY=api_key \\\n           --env OS_NAME=$(uname -s) \\\n           --env SHELL_NAME=$(echo $SHELL) \\\n           --volume gpt-cache:\u002Ftmp\u002Fshell_gpt \\\n       ghcr.io\u002Fther1d\u002Fshell_gpt -s \"update my system\"\n```\n\n使用别名和 `OPENAI_API_KEY` 环境变量进行对话的示例：\n```shell\nalias sgpt=\"docker run --rm --volume gpt-cache:\u002Ftmp\u002Fshell_gpt --env OPENAI_API_KEY --env OS_NAME=$(uname -s) --env SHELL_NAME=$(echo $SHELL) ghcr.io\u002Fther1d\u002Fshell_gpt\"\nexport OPENAI_API_KEY=\"your OPENAI API key\"\nsgpt --chat rainbow \"what are the colors of a rainbow\"\nsgpt --chat rainbow \"inverse the list of your last answer\"\nsgpt --chat rainbow \"translate your last answer in french\"\n```\n\n你也可以使用提供的 `Dockerfile` 构建自己的镜像：\n```shell\ndocker build -t sgpt .\n```\n\n### Docker + Ollama\n\n如果你想将请求发送到 Ollama 实例，并在 Docker 容器中运行 ShellGPT，你需要调整 Dockerfile 并自行构建容器：需要安装 litellm 包，并正确设置环境变量。\n\n示例 Dockerfile：\n```\nFROM python:3-slim\n\nENV DEFAULT_MODEL=ollama\u002Fmistral:7b-instruct-v0.2-q4_K_M\nENV API_BASE_URL=http:\u002F\u002F10.10.10.10:11434\nENV USE_LITELLM=true\nENV OPENAI_API_KEY=bad_key\nENV SHELL_INTERACTION=false\nENV PRETTIFY_MARKDOWN=false\nENV OS_NAME=\"Arch Linux\"\nENV SHELL_NAME=auto\n\nWORKDIR \u002Fapp\nCOPY . \u002Fapp\n\nRUN apt-get update && apt-get install -y gcc\nRUN pip install --no-cache \u002Fapp[litellm] && mkdir -p \u002Ftmp\u002Fshell_gpt\n\nVOLUME \u002Ftmp\u002Fshell_gpt\n\nENTRYPOINT [\"sgpt\"]\n```\n\n\n## 更多文档\n* [Azure 集成](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FAzure)\n* [Ollama 集成](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FOllama)","# ShellGPT 快速上手指南\n\nShellGPT 是一款由大语言模型（LLM）驱动的命令行生产力工具，可直接在终端生成 **Shell 命令、代码片段和技术文档**，无需切换浏览器搜索。支持 Linux、macOS、Windows 及主流 Shell（Bash, Zsh, PowerShell 等）。\n\n## 环境准备\n\n- **操作系统**：Linux、macOS 或 Windows\n- **依赖环境**：已安装 Python 及 `pip`\n- **API 密钥**：\n  - 默认使用 OpenAI GPT-4 模型，需准备 [OpenAI API Key](https:\u002F\u002Fplatform.openai.com\u002Fapi-keys)（注意：OpenAI 服务非免费）。\n  - *可选*：若希望免费使用，可自行部署本地开源模型后端（如 [Ollama](https:\u002F\u002Fgithub.com\u002Follama\u002Follama)），但需注意官方提示：ShellGPT 尚未针对本地模型进行深度优化，效果可能不如预期。\n\n## 安装步骤\n\n1. 通过 pip 安装工具：\n   ```shell\n   pip install shell-gpt\n   ```\n   > 💡 **国内加速建议**：若下载缓慢，可使用国内镜像源安装：\n   > ```shell\n   > pip install shell-gpt -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n   > ```\n\n2. 运行任意 `sgpt` 命令，系统将提示输入 API Key。输入后，密钥将自动保存至 `~\u002F.config\u002Fshell_gpt\u002F.sgptrc`。\n\n## 基本使用\n\n### 1. 直接问答与查询\n直接在命令行输入自然语言问题，获取技术解答或通用知识：\n```shell\nsgpt \"What is the fibonacci sequence\"\n```\n\n### 2. 生成并执行 Shell 命令\n使用 `--shell` (或 `-s`) 参数生成命令。工具会自动识别当前操作系统并生成对应指令。生成后会提示 `[E]xecute` (执行), `[D]escribe` (解释), `[A]bort` (取消)。\n\n**示例：查找当前目录下的 JSON 文件**\n```shell\nsgpt --shell \"find all json files in current folder\"\n# 输出: find . -type f -name \"*.json\"\n# 提示: [E]xecute, [D]escribe, [A]bort: e (输入 e 回车即可直接执行)\n```\n\n**示例：根据系统更新指令（自动适配 macOS 或 Ubuntu）**\n```shell\nsgpt -s \"update my system\"\n```\n\n### 3. 管道输入与分析\n支持通过管道 (`|`) 传递内容，适合分析日志或生成 Git 提交信息：\n\n**分析 Docker 日志：**\n```shell\ndocker logs -n 20 my_app | sgpt \"check logs, find errors, provide possible solutions\"\n```\n\n**生成 Git 提交信息：**\n```shell\ngit diff | sgpt \"Generate git commit message, for my changes\"\n```\n\n### 4. 生成代码\n使用 `--code` (或 `-c`) 参数仅输出纯代码，可直接重定向到文件：\n\n**生成 Python 脚本：**\n```shell\nsgpt --code \"solve fizz buzz problem using python\" > fizz_buzz.py\n```\n\n**为现有代码添加注释：**\n```shell\ncat fizz_buzz.py | sgpt --code \"Generate comments for each line of my code\"\n```\n\n### 5. 进阶技巧：对话模式与 Shell 集成\n- **多轮对话**：使用 `--chat \u003C会话名>` 保留上下文，逐步优化命令或代码。\n  ```shell\n  sgpt --chat dev \"write a curl command to post json\"\n  sgpt --chat dev \"add authentication header\"\n  ```\n- **Shell 集成（推荐）**：运行 `sgpt --install-integration` 并重启终端。之后可在终端按 `Ctrl+l` 直接唤起 ShellGPT，生成的命令会填入当前输入行，方便编辑后执行。","一位后端开发工程师在深夜排查生产环境 Docker 容器异常，急需快速定位错误根源并执行修复命令。\n\n### 没有 shell_gpt 时\n- 面对复杂的 Docker 报错日志，需要手动复制粘贴到搜索引擎或文档网站，反复切换窗口查找含义。\n- 忘记特定的 `find` 或 `jq` 命令语法来提取关键信息，不得不查阅大量在线教程才能拼凑出正确指令。\n- 在不同操作系统（如 macOS 开发机与 Linux 服务器）间切换时，容易混淆系统更新或包管理命令，导致操作失败。\n- 从分析日志到生成修复命令耗时过长，打断了排查思路，增加了故障恢复的平均时间（MTTR）。\n\n### 使用 shell_gpt 后\n- 直接通过管道将 `docker logs` 输出传递给 shell_gpt，它能瞬间分析日志并指出具体的连接超时或内存分配错误及解决方案。\n- 只需输入自然语言描述（如“找出当前目录下所有修改过的 JSON 文件”），shell_gpt 立即生成精准的 Shell 命令供确认执行。\n- 自动识别当前操作系统环境，针对“更新系统”这类模糊指令，在 macOS 上生成 `softwareupdate` 命令，而在 Ubuntu 上则生成 `apt` 命令，无需人工区分。\n- 整个排查与修复过程在终端内一气呵成，无需离开命令行界面，显著提升了运维效率与专注度。\n\nshell_gpt 将繁琐的搜索与记忆负担转化为流畅的自然语言交互，让开发者能专注于解决核心问题而非命令语法。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FTheR1D_shell_gpt_440b2d78.png","TheR1D","Farkhod Sadykov","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FTheR1D_458cbf0c.jpg","Infinite loops master","NBCUniversal | Sky","Prague, Czech Republic","Farkhod.Sadykov@gmail.com","ther1d","sadykov.dev","https:\u002F\u002Fgithub.com\u002FTheR1D",[84,88,92],{"name":85,"color":86,"percentage":87},"Python","#3572A5",99.3,{"name":89,"color":90,"percentage":91},"Shell","#89e051",0.4,{"name":93,"color":94,"percentage":95},"Dockerfile","#384d54",0.3,11961,950,"2026-04-12T17:50:10","MIT","Linux, macOS, Windows","未说明",{"notes":103,"python":101,"dependencies":104},"默认使用 OpenAI API（需付费及 API Key）；支持通过 Ollama 运行本地开源模型，但官方提示该工具未针对本地模型优化，可能无法按预期工作；安装后需配置 API Key 至 ~\u002F.config\u002Fshell_gpt\u002F.sgptrc；支持 Bash、Zsh、PowerShell 和 CMD 等主流 Shell。",[105,106],"openai (通过 API 调用)","ollama (可选，用于本地模型)",[52,14,35],[109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124],"cheat-sheet","cli","gpt-3","openai","productivity","shell","chatgpt","python","terminal","linux","commands","gpt-4","llm","llama","ollama","gpt-5",null,"2026-03-27T02:49:30.150509","2026-04-13T13:36:22.312858",[129,134,139,144,149,154],{"id":130,"question_zh":131,"answer_zh":132,"source_url":133},31533,"遇到 'HTTPError: 429 Too Many Requests' 错误怎么办？","这通常是因为 OpenAI API 的免费额度已过期或耗尽。请注意：\n1. ChatGPT Plus 订阅（$20\u002F月）仅适用于网页版 (chat.openai.com)，不包含 API 访问权限。\n2. API 需要单独在 OpenAI 平台购买信用额度（Pay-as-you-go）。\n3. 即使网页版能正常使用，如果 API 额度不足或过期，也会报 429 错误。\n解决方案：登录 https:\u002F\u002Fplatform.openai.com\u002Faccount\u002Fbilling\u002Foverview 检查余额并充值，充值后可能需要等待几分钟生效。","https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fissues\u002F75",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},31534,"为什么我有 ChatGPT Plus 会员，使用 API 时仍然报错或无法访问特定模型（如 gpt-4-32k）？","ChatGPT Plus 订阅和 API 访问是分开计费的。Plus 会员只覆盖网页端的使用，不包含 API 调用权限。\n如果遇到 404 错误或无法使用特定模型：\n1. 确保已在 OpenAI 平台单独购买了 API 信用额度。\n2. 某些模型可能对账户有限制，OpenAI 的模型开放策略不透明。\n3. 替代方案：可以使用 OpenRouter 作为代理。配置方法如下：\n   - 注册 OpenRouter 账号并获取 Key。\n   - 修改配置文件 `~\u002F.config\u002Fshell_gpt\u002F.sgptrc`：\n     OPENAI_API_HOST=https:\u002F\u002Fapi.openrouter.ai\n     OPENAI_API_KEY=\u003C你的 openrouter_key>\n     OPENAI_BASE_URL=https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1\n   - 在 OpenRouter 设置中将默认模型设为所需模型（如 gpt4-32k）。","https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fissues\u002F420",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},31535,"如何在 ZSH 中修复 shell 集成绑定键错误？","如果在配置 ZSH 集成时遇到错误，尝试修改绑定命令。\n将配置行改为：\nbindkey '^l' _sgpt_zsh\n如果仍然无效，建议直接使用 sgpt 命令查询具体的解决方法，或检查是否正确加载了初始化脚本。","https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fissues\u002F582",{"id":145,"question_zh":146,"answer_zh":147,"source_url":148},31536,"执行命令时是否可以不加引号？","默认情况下可能需要引号，但可以通过设置别名（alias）或 shell 函数来避免每次手动输入引号。\n示例（Linux Fish Shell）：\n在 `~\u002F.config\u002Ffish\u002Fconfig.fish` 中添加别名，将参数自动包裹。\n示例（Windows Cmder）：\n在 `user_aliases.cmd` 中添加：\ns=sgpt --shell \"$*\"\n这样只需输入 `s 你的自然语言指令` 即可，无需手动加引号。对于复杂场景，也可以编写包装脚本（wrapper script）来处理环境激活和参数传递。","https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fissues\u002F128",{"id":150,"question_zh":151,"answer_zh":152,"source_url":153},31537,"如何在 REPL 模式下提交多行代码块而不是逐行执行？","在 REPL 模式下，直接粘贴多行代码可能会被逐行执行。要提交整个代码块进行调试或修复，通常需要特定的结束符或操作方式。\n虽然具体操作取决于版本，但一般可以尝试：\n1. 粘贴代码后，使用特定的快捷键或输入结束标记（如 Ctrl+D 或单独一行的特定字符）来表示输入结束。\n2. 如果当前版本不支持，可以考虑将代码保存为文件，然后让 sgpt 读取文件内容进行分析。","https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fissues\u002F143",{"id":155,"question_zh":156,"answer_zh":157,"source_url":158},31538,"输出结果没有 Markdown 格式渲染，如何使其更易读？","默认输出可能未格式化。为了提高可读性，用户可以结合外部工具使用。\n建议方案：\n1. 安装 Markdown 渲染工具，例如 `glow` (Go 语言编写) 或其他终端 Markdown 查看器。\n2. 将 sgpt 的输出通过管道传递给这些工具。\n注意：目前工具本身可能尚未内置完美的 Markdown 渲染功能，社区正在讨论相关增强特性，暂时推荐通过管道配合外部工具实现。","https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fissues\u002F333",[160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255],{"id":161,"version":162,"summary_zh":163,"released_at":164},238636,"1.5.0","1.5.0\n\n## 变更内容\n* 迁移到 OpenAI v2 版本的 SDK #744\n* 在 #566 中添加了修改生成的 Shell 命令的功能（非常实用）\n* 确保保留第一条聊天消息，以避免出现“无法确定聊天角色”的错误 #633\n* 在响应分块中添加了对空选项的检查 #738\n* 从依赖项中移除了 `instructor` 包\n* LLM 功能优化\n\n\n由于已将 `instructor` 包从依赖项中移除，请注意：如果您在此版本发布之前使用过 [函数调用](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt?tab=readme-ov-file#function-calling)，则需要重新安装默认函数 `sgpt --install-functions`，并更新您的自定义函数。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fcompare\u002F1.4.5...1.5.0","2026-01-28T00:57:48",{"id":166,"version":167,"summary_zh":168,"released_at":169},238637,"1.4.5","## 变更内容\n* @abhishekbhakat 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F604 中增加了对所有 LiteLLM 支持模型的支持\n* @florian-lnx 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F513 中修复了 `--show-chat` 和 `--repl` 选项，使其能够正确尊重 `--no-md` 参数\n* @TheR1D 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F671 中更新了 Python 版本要求及依赖项\n* 修复：在聊天缓存中保留系统消息 —— @EmVee381 和 @TheR1D 共同完成，相关 PR 分别为 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F669 和 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F683\n\n## 新贡献者\n* @abhishekbhakat 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F604 中完成了首次贡献\n* @carlsmedstad 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F554 中完成了首次贡献\n* @florian-lnx 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F513 中完成了首次贡献\n* @EmVee381 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F669 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fcompare\u002F1.4.4...1.4.5","2025-04-08T10:50:58",{"id":171,"version":172,"summary_zh":173,"released_at":174},238638,"1.4.4","## 变更内容\n* 由 @counterapparatus 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F544 中进行的 Shell 识别小修复\n* 由 @alissonperez 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F580 中将默认模型更新为 gpt-4o\n* 采用 [新的函数调用格式](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Ffunction-calling\u002Fstep-3-pass-your-function-definitions-as-available-tools-to-the-model-along-with-the-messages)，并在 Groq 等其他模型上支持函数调用，由 @tijszwinkels 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F569 中实现\n* 由 @Robinsane 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F540 中进行的容器改进\n\n## 新贡献者\n* @counterapparatus 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F544 中完成了首次贡献\n* @alissonperez 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F580 中完成了首次贡献\n* @keidarcy 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F539 中完成了首次贡献\n* @tijszwinkels 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F569 中完成了首次贡献\n* @Robinsane 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F540 中完成了首次贡献\n\n**完整变更日志**: https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fcompare\u002F1.4.3...1.4.4","2024-08-10T23:32:04",{"id":176,"version":177,"summary_zh":178,"released_at":179},238639,"1.4.3","## 变更内容\n\n* 修复了解析包含多个等号“=”的配置文件 **.sgptrc** 时的 bug https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F504\n* 在 REPL 模式下，当 LLM 主动流式生成响应时，支持通过 Ctrl + C 中断 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fissues\u002F319\n* 修复了由于缓存导致函数调用无法正常工作的 bug https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fissues\u002F485\n\n特别感谢所有贡献者：@keiththomps、@artsparkAI、@save196。","2024-04-06T16:55:47",{"id":181,"version":182,"summary_zh":183,"released_at":184},238640,"1.4.0","## 变更内容\n* 新增 `—md` 和 `—no-md` 选项，用于禁用或启用 Markdown 格式的输出。\n* 新增配置变量 `PRETTIFY_MARKDOWN`，用于默认禁用或启用 Markdown 输出。\n* 新增配置变量 `USE_LITELLM`，用于强制使用 LiteLLM 库。\n\n### OpenAI 与 LiteLLM\n由于 LiteLLM 支持向众多其他大模型后端发起请求，因此其导入开销较大，会增加 1–2 秒的运行时间。ShellGPT 默认使用 OpenAI 的库，这适用于大多数用户。您也可以通过运行 `pip install shell-gpt[litellm]` 来安装包含 LiteLLM 的 ShellGPT。若要强制使用 LiteLLM，请在配置文件 `~\u002F.config\u002Fshell_gpt\u002F.sgptrc` 中将 `USE_LITELLM` 设置为 `true`。","2024-02-22T02:56:09",{"id":186,"version":187,"summary_zh":188,"released_at":189},238641,"1.3.1","## 变更内容\n* 修复 #422：由 @jeanlucthumm 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F444 中实现的聊天历史 Markdown 格式化问题。\n* 新增配置变量 `API_BASE_URL` #473，并由 @TheR1D 在 https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fpull\u002F477 中修复了 `REQUEST_TIMEOUT` 配置项。\n* 进行了少量代码优化。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fcompare\u002F1.3.0...1.3.1","2024-02-17T02:06:46",{"id":191,"version":192,"summary_zh":193,"released_at":194},238642,"1.3.0","## 变更内容\n* Ollama 及其他 LLM 后端。\n* Markdown 格式化现取决于角色描述。\n* 代码重构与优化。\n\n### 多个 LLM 后端\nShellGPT 现在可以使用 [LiteLLM](https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm) 与多个后端协同工作。您可以使用本地部署的开源模型，这些模型是免费提供的。要使用本地模型，您需要运行自己的 LLM 后端服务器，例如 [Ollama](https:\u002F\u002Fgithub.com\u002Follama\u002Follama)。如需将 ShellGPT 与 Ollama 配合使用，请参阅这份详尽的 [指南](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FOllama)。支持的模型和提供商的完整列表请见 [这里](https:\u002F\u002Fdocs.litellm.ai\u002Fdocs\u002Fproviders)。**请注意，ShellGPT 并未针对本地模型进行优化，可能无法按预期工作❗️**\n\n### Markdown 格式化\nMarkdown 格式化现取决于角色描述。例如，如果角色描述中包含 `\"APPLY MARKDOWN\"`，则该角色的输出将以 Markdown 格式呈现。这一规则适用于默认角色和自定义角色。如果您希望禁用 Markdown 格式化，请编辑 `~\u002F.config\u002Fshell_gpt\u002Froles` 中的默认角色描述。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fcompare\u002F1.2.0...1.3.0","2024-02-09T22:48:41",{"id":196,"version":197,"summary_zh":198,"released_at":199},238643,"1.2.0","* 新增 `--interaction` 选项，可与 `--shell` 选项配合使用。例如，`sgpt --shell --no-interaction` 会将建议的命令输出到 **stdout**。这在需要将输出重定向到其他地方时非常有用。比如 `sgpt -s \"say hi\" | pbcopy`。\n* 修复了 `stdin` 和 `--shell` 选项无法切换到交互式输入模式的问题。\n* REPL 模式现在可以接受 `stdin` 或 `PROMPT` 参数，也可以同时接受两者。\n* 更新了 Shell 集成，改用新的 `--no-interaction` 选项来生成 Shell 命令。\n* 将 Shell 集成移至专用文件 **integration.py**。\n* 修改了 `--install-integration` 的逻辑，不再下载 shell 脚本。\n* 移除了对 `PROMPT` 参数的验证，现在默认值为空字符串。\n* 修复了在非交互式 Shell 环境（如 cron 任务）中调用 `sgpt` 时出现的问题。\n* 优化并修复了 **Dockerfile**。\n* 设置了 GitHub Codespaces。\n* 改进了测试用例。\n* 优化了 **README.md**。\n* 新增演示视频 🐴。\n\n❗️**Shell 集成**的逻辑已更新，因此它将不再兼容之前版本中位于 `~\u002F.bashrc` 或 `~\u002F.zshrc` 中的集成函数。请运行 `sgpt --install-integration` 以应用新更改，并移除您之前使用的旧集成函数。\n\nhttps:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fassets\u002F16740832\u002F9197283c-db6a-4b46-bfea-3eb776dd9093\n\n\n## REPL stdin\nREPL 模式现在可以接受 `stdin`、`PROMPT` 参数，甚至两者同时输入。这在为您的提示提供初始上下文时非常有用。\n```shell\nsgpt --repl temp \u003C my_app.py\n```\n```text\n进入 REPL 模式，按 Ctrl+C 退出。\n──────────────────────────────────── 输入 ────────────────────────────────────\nname = input(\"你的名字是什么？\")\nprint(f\"你好，{name}\")\n───────────────────────────────────────────────────────────────────────────────\n>>> 这段代码是关于什么的？\n你提供的代码片段是用 Python 编写的。它会提示用户...\n>>> 后续问题...\n```\n您也可以将 `PROMPT` 直接传递给 REPL 模式，例如 `sgpt --repl temp \"一些初始提示\"`，或者同时使用两者，如 `sgpt --repl temp \"初始参数提示\" \u003C text.txt`。\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fcompare\u002F1.1.0...1.2.0","2024-01-28T04:33:52",{"id":201,"version":202,"summary_zh":203,"released_at":204},238644,"1.1.0","https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fassets\u002F16740832\u002F721ddb19-97e7-428f-a0ee-107d027ddd59\n\n# OpenAI 库\nShellGPT 现已集成 OpenAI 的 Python 库来处理 API 请求。这一集成简化了 ShellGPT 代码库的开发与维护工作。此外，它还通过提供更友好的错误信息——包含描述和可能的解决方案——提升了用户体验。\n\n# 函数调用\n[函数调用](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Ffunction-calling)是 OpenAI 提供的一项强大功能。它允许大模型在您的系统中执行函数，从而完成各种任务。ShellGPT 提供了一种便捷的[定义函数](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt#function-calling)并使用它们的方式。要安装[默认函数](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Ftree\u002Fmain\u002Fsgpt\u002Fdefault_functions\u002F)，请运行：\n```shell\nsgpt --install-functions\n```\n这将为大模型添加一个用于执行 Shell 命令以及在 macOS 上执行 AppleScript 的函数。更多详情请参阅演示视频和 README.md 文件。\n\n# 选项\n* `—code` 的快捷选项 `-c`。\n* `--list-chats` 的快捷选项 `-lc`。\n* `--list-roles` 的快捷选项 `-lr`。\n* 新增 `—functions` 选项，用于启用或禁用函数调用。\n* 新增 `—install-functions` 选项，用于安装默认函数。\n\n# 配置\n* 新增配置变量 `OPENAI_FUNCTIONS_PATH`。\n* 新增配置变量 `OPENAI_USE_FUNCTIONS`。\n* 新增配置变量 `SHOW_FUNCTIONS_OUTPUT`。\n\n# 小幅改动\n* 代码优化。\n* 函数调用缓存优化。","2024-01-09T02:10:38",{"id":206,"version":207,"summary_zh":208,"released_at":209},238645,"1.0.1","* 修复了自上一版本以来在 REPL 模式中无法正常工作的 bug。\n* 对默认角色进行了小幅优化和错误修复。\n* 进行了少量代码优化。","2023-12-22T00:50:47",{"id":211,"version":212,"summary_zh":213,"released_at":214},238646,"1.0.0","ShellGPT `v1.0.0` release includes multiple significant changes:\r\n* Default model has been changed to `gpt-4-1106-preview` (a.k.a. GPT-4 Turbo).\r\n* ShellGPT roles (prompts) optimised for OpenAI GPT-4 models.\r\n* Using system roles when calling OpenAI API with [messages](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fapi-reference\u002Fchat\u002Fcreate#chat-create-messages).\r\n* Rendering markdown for default and describe shell command outputs.\r\n* New config variable `CODE_THEME` which sets theme for markdown (default is `dracula`).\r\n* Multiline input in REPL mode possible with `\"\"\"` triple quotes.\r\n* New `--version` options that prints installed ShellGPT version.\r\n* Fixed issue with home direcotry in Dockerfile which leading to container crash.\r\n* Code optimisations, minor bug fixes.\r\n\r\nhttps:\u002F\u002Fgithub-production-user-asset-6210df.s3.amazonaws.com\u002F16740832\u002F291779848-66392282-474e-4a84-8482-d20c53c8727d.mp4\r\n\r\nFor users which will be upgrading from previous versions it is recommended to change `DEFAULT_MODEL` to `gpt-4-1106-preview` in config file `~\u002F.config\u002Fshell_gpt\u002F.sgptrc` since older models might not perform well with system roles. Because of significant changes in roles, unfortunately previously created custom roles and chats will not work with ShellGPT v1.0.0 and you will need to re-create them using new version.\r\n\r\nShoutout to all contributors: @jaycenhorton @arafatsyed @th3happybit @Navidur1 @moritz-t-w @Ismail-Ben   ","2023-12-20T05:18:53",{"id":216,"version":217,"summary_zh":218,"released_at":219},238647,"0.9.4","By default, ShellGPT leverages OpenAI's large language models. However, this release provides the flexibility to use locally hosted models, which can be a cost-effective alternative. To use local models, you will need to run your own API server. You can accomplish this by using [LocalAI](https:\u002F\u002Fgithub.com\u002Fgo-skynet\u002FLocalAI), a self-hosted, OpenAI-compatible API. Setting up LocalAI allows you to run language models on your own hardware, potentially without the need for an internet connection, depending on your usage. To set up your LocalAI, please follow this comprehensive [guide](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FLocalAI). Remember that the performance of your local models may depend on the specifications of your hardware and the specific language model you choose to deploy.\r\n\r\n* `--model` parameter is now string (was enum before).\r\n* Added LocalAI information to README.md.\r\n* Created a [guide](https:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fwiki\u002FLocalAI) on wiki page.","2023-07-19T01:20:27",{"id":221,"version":222,"summary_zh":223,"released_at":224},238648,"0.9.3","This release incorporates support for the newly announced gpt-3.5-turbo-16k model which has same capabilities as the standard gpt-3.5-turbo model but with 4 times the context.\r\n```shell\r\nsgpt --model gpt-3.5-turbo-16k \"16k context prompt\"\r\n```","2023-06-14T15:08:47",{"id":226,"version":227,"summary_zh":228,"released_at":229},238649,"0.9.2","This release includes shell integrations for ZSH and Bash.\r\n* Added simple shell integration for ZSH.\r\n* Added simple shell integration for Bash.\r\n* New hidden option `--install-integration` which will update user shell profile.\r\n\r\n# Shell Integration\r\nShell integration allows you to use Shell-GPT in your terminal with hotkeys. It is currently available for Bash and ZSH. It will allow you to have `sgpt` completions in your shell history, and also edit suggested commands right away.\r\n\r\nhttps:\u002F\u002Fgithub.com\u002FTheR1D\u002Fshell_gpt\u002Fassets\u002F16740832\u002Fbead0dab-0dd9-436d-88b7-6abfb2c556c1\r\n\r\n# Installation\r\n```shell\r\npip install --upgrade shell-gpt\r\nsgpt --install-integration\r\n# Restart your terminal to apply changes.\r\n```\r\n\r\n# Usage\r\nIn your terminal enter natural language request, and press `Ctrl+l` to get shell command suggestion. It will replace your current input line (buffer) with the GPT suggested command.\r\n```text\r\nList all txt files in current folder (Ctrl+l)\r\n# -> ls *.txt\r\n```\r\nSpecial thanks to @chinarjoshi ","2023-06-04T23:49:09",{"id":231,"version":232,"summary_zh":233,"released_at":234},238650,"0.9.1","This release includes several new features, optimizations and bug fixes:\r\n* New input option to describe command when executing using `--shell`.\r\n* New CLI option `--describe-shell` or `-d` to generate explanation for commands.\r\n* Configuration parameter to execute shell commands by default.\r\n* Comment lines (a line starting with #) excluded when parsing `.sgptrc` file.\r\n* Max limit of `--temperature` was change to 2.\r\n* Hiding API key from tracebacks when `sgpt` crashes.\r\n* Fixing a bug when typing `exit()` in REPL mode.\r\n\r\n# Describe shell commands\r\nWhen executing a shell command suggestion using `--shell` the prompt has be changed. There are 3 new options:\r\n```shell\r\nsgpt -s \"show all txt files in current folder\"\r\n# -> ls *.txt\r\n# -> [E]xecute, [D]escribe, [A]bort: d\r\n# -> List all files with .txt extension in current directory\r\n# -> [E]xecute, [D]escribe, [A]bort: e\r\n...\r\n```\r\n\r\nSame logic works in `--repl` mode:\r\n```shell\r\nsgpt -s --repl temp\r\nEntering shell REPL mode, type [e] to execute commands or [d] to describe the commands, press Ctrl+C to exit.\r\n>>> install docker\r\nbrew install docker\r\n>>> d\r\nInstalls Docker using the Homebrew package manager.\r\n>>> e\r\n...\r\n```\r\n\r\nAdded new option `--describe-shell` or `-d`. It allows you to generate explanation for shell commands:\r\n```shell\r\nsgpt -d \"ls -la\"\r\n# -> List all files and directories, including hidden files, with permissions and ownership information.\r\n```\r\n\r\n# Execute commands by default\r\nNew configuration parameter `DEFAULT_EXECUTE_SHELL_CMD` (`false` by default), if `true` will executing commands when calling `sgpt --shell` if no input was passed (enter). So we don't have to type \"y\" or \"e\" to execute command.\r\n```shell\r\nsgpt -s \"say hi\"\r\n# -> echo hi\r\n# -> [E]xecute, [D]escribe, [A]bort: (enter)\r\nhi\r\n```\r\nShoutout to all contributors: @chinarjoshi, @konstantin-goldman, @Daeinar, @eitamal, @cosmojg. \r\n","2023-05-21T18:54:24",{"id":236,"version":237,"summary_zh":238,"released_at":239},238651,"0.9.0","* Custom user defined roles.\r\n* Option to change default roles like **shell**, **code** and **default**.\r\n* Option to force use [system role](https:\u002F\u002Fhelp.openai.com\u002Fen\u002Farticles\u002F7042661-chatgpt-api-transition-guide) messages (not recommended).\r\n* Improvements when passing stdin and prompt `echo hello | sgpt \"another hello\"`.\r\n* Fixed typo in `--list-chat` option renamed as `--list-chats`\r\n\r\n# Roles\r\nShellGPT allows you to create custom roles, which can be utilized to generate code, shell commands, or to fulfill your specific needs. To create a new role, use the `--create-role` option followed by the role name. You will be prompted to provide a description for the role, along with other details. This will create a JSON file in `~\u002F.config\u002Fshell_gpt\u002Froles` with the role name. Inside this directory, you can also edit default `sgpt` roles, such as **shell**, **code**, and **default**. Use the `--list-roles` option to list all available roles, and the `--show-role` option to display the details of a specific role. Here's an example of a custom role:\r\n```shell\r\nsgpt --create-role json\r\n# Enter role description: You are JSON generator, provide only valid json as response.\r\n# Enter expecting result, e.g. answer, code, shell command, etc.: json\r\nsgpt --role json \"random: user, password, email, address\"\r\n{\r\n  \"user\": \"JohnDoe\",\r\n  \"password\": \"p@ssw0rd\",\r\n  \"email\": \"johndoe@example.com\",\r\n  \"address\": {\r\n    \"street\": \"123 Main St\",\r\n    \"city\": \"Anytown\",\r\n    \"state\": \"CA\",\r\n    \"zip\": \"12345\"\r\n  }\r\n}\r\n```\r\nNote that all previous chats which were created in previous version of ShellGPT will not work with this new version.","2023-04-16T16:35:43",{"id":241,"version":242,"summary_zh":243,"released_at":244},238652,"0.8.9","This release includes several backend optimizations:\r\n* Migrating to TOML.\r\n* Mypy stricted types.\r\n* New code linting tools.\r\n* Dependencies optimization.\r\n* sdist and bdist package optimizations.","2023-04-14T23:31:23",{"id":246,"version":247,"summary_zh":248,"released_at":249},238653,"0.8.8","* Accept prompt from both stdin and command line argument.\r\n \r\nThis versatile feature is particularly useful when you need to pass file content or pipe output from other commands to the GPT models for summarization or analysis. For example, you can easily generate a git commit message based on a diff:\r\n```shell\r\ngit diff | sgpt \"Generate git commit message, for my changes\"\r\n# -> Commit message: Implement Model enum and get_edited_prompt()\r\n```\r\nThis powerful feature simplifies the process of managing and understanding data from different sources, making it easier for you to focus on what really matters: improving your projects and applications.","2023-04-10T15:20:19",{"id":251,"version":252,"summary_zh":253,"released_at":254},238654,"0.8.7","* Config option to change OpenAI completion color in terminal.\r\n* Minor config logic optimization.\r\n\r\nYou can change color of OpenAI completion by changing `DEFAULT_COLOR` in `~\u002F.config\u002Fshell_gpt\u002F.sgptrc` or `$DEFAULT_COLOR` env, possible options: black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white. \r\n```text\r\n...\r\nDEFAULT_COLOR=magenta\r\n```","2023-04-10T10:26:28",{"id":256,"version":257,"summary_zh":258,"released_at":259},238655,"0.8.6","* Model choice option to support GPT-4.\r\n* Added default model to config file.\r\n\r\nNote that GPT-4 currently in private beta, if you don't have access, you will get 404 error.","2023-04-09T17:20:11"]