加入新的 Discord 伺服器並開始為該專案做出貢獻!
一個簡單、輕量級的 shell 腳本,可從終端使用 OpenAI 的 chatGPT 和 DALL-E,無需安裝 python 或 node.js。腳本使用官方 ChatGPT 模型gpt-3.5-turbo
和 OpenAI API 端點/chat/completions
。如果您有存取權限,也可以使用新的gpt-4
模型。
此腳本支援使用所有其他 OpenAI 模型以及completions
端點和images/generations
端點來產生圖像。
聊天模式:
$ chatgpt
Welcome to chatgpt. You can quit with ' exit ' .
Enter a prompt:
帶有初始提示的聊天模式:
$ chatgpt -i " You are Rick, from Rick and Morty. Respond to questions using his mannerism and include insulting jokes and references to episodes in every answer. "
Welcome to chatgpt. You can quit with ' exit ' .
Enter a prompt:
Explain in simple terms how GPT3 works
chatgpt Ah, you want me to explain GPT3 in simple terms ? Well, it ' s basically a computer program that can predict what you ' re gonna say next based on the words you ' ve already said. Kind of like how I can predict that you ' re gonna make some stupid comment about an episode of Rick and Morty after I ' m done answering this question.
Enter a prompt:
使用管道:
echo " How to view running processes on Ubuntu? " | chatgpt
使用腳本參數:
chatgpt -p " What is the regex to match an email address? "
該腳本依賴curl來發送對api的請求,並依賴jq來解析json回應。
捲曲
brew install curl
傑克
brew install jq
OpenAI API 金鑰。在 OpenAI 建立帳戶並取得免費的 API 金鑰
或者,您可以安裝glow來在markdown渲染回應
要安裝,請在終端機中運行此程序,並在詢問時提供您的 OpenAI API 金鑰。
curl -sS https://raw.githubusercontent.com/0xacx/chatGPT-shell-cli/main/install.sh | sudo -E bash
如果您使用 ArchLinux,您可以使用以下命令安裝 AUR 軟體包:
paru -S chatgpt-shell-cli
如果你想手動安裝它,你所要做的就是:
chatgpt.sh
檔案下載到您想要的目錄中chatgpt.sh
的路徑加入$PATH
。您可以將此行新增至 shell 設定檔中來完成此操作: export PATH=$PATH:/path/to/chatgpt.sh
export OPENAI_KEY=your_key_here
chatgpt
指令運行腳本。預設情況下,腳本使用gpt-3.5-turbo
模型。 echo "What is the command to get all pdf files created yesterday?" | chatgpt
chatgpt -p "What is the regex to match an email address?"
image:
要產生影像,請啟動提示image:
如果您使用的是 iTerm,則可以直接在終端機中查看影像。否則,腳本將要求在瀏覽器中開啟圖像。history
要查看您的聊天記錄,請輸入history
models
輸入models
model:
要查看特定模型的所有信息,請使用model:
和模型列表中顯示的模型id
啟動提示。例如: model:text-babbage:001
將為您提供text-babbage:001
模型的所有字段command:
要取得具有指定功能的命令並執行它,只需鍵入command:
並解釋您想要實現的目標。該腳本將始終詢問您是否要執行該命令。 ie command: show me all files in this directory that have more than 150 lines of code
如果命令修改檔案系統或下載外部文件,則腳本將在執行前顯示警告。gpt-3.5-turbo
和gpt-4
以外的模型,其中 OpenAI api 不支援聊天上下文,您可以使用此腳本中的聊天上下文來建立。您可以為模型啟用聊天上下文模式,以記住您先前的聊天問題和答案。這樣您就可以提出後續問題。在聊天上下文-c
,模型會收到充當 ChatGPT 的提示,並了解今天的日期, --chat-context
使用截至 2021 年的資料進行訓練。 。即chatgpt --chat-context
並開始聊天。 -i
或--init-prompt
然後使用您的初始提示,即chatgpt -i "You are Rick from Rick and Morty, reply with references to episodes."
--init-prompt-from-file
從檔案設定初始聊天提示,即chatgpt --init-prompt-from-file myprompt.txt
*當您設定初始提示時,您不需要啟用聊天上下文。
gpt-3.5-turbo
。gpt-4
來使用它,即chatgpt --model gpt-4
若要設定請求參數,您可以像這樣啟動腳本: chatgpt --temperature 0.9 --model text-babbage:001 --max-tokens 100 --size 1024x1024
可用參數有:
-t
或--temperature
-m
或--model
--max-tokens
-s
或--size
(OpenAI API 接受的大小為 256x256、512x512、1024x1024)-p
或--prompt
--prompt-from-file
要了解有關這些參數的更多信息,您可以查看 API 文檔
感謝所有使用、測試、提交問題、PR 和提議更改的人:
pfr-dev, jordantrizz, se7en-x230, mountaineerbr, oligeo, biiaocy, dmd, goosegit11, dilatedpupils, direster, rxaviers, Zeioth, edshamis, nre-ablecoton, TobiasLaving, rxaviers, Zeioth, edshamis, nre-ableAtal, TobiasLaving, rxaviers, Zeioth, edshamis, nre-ableAtal, TobiasLaving, Hub RexAcker, Hub RexA, sadm, sad,23, Keyvings, Hub RexA.
非常歡迎您的貢獻!
如果您有想法或需要幫助才能開始,請加入 Discord 伺服器