Gish是一個命令行界面(CLI),在Unix約定後與OpenAI GPT進行交互,並通過標誌提供豐富的功能。重要的是要注意,需要使用Gish的付費OpenAI帳戶和API密鑰。
Gish提供以下功能:
#import
語句將文件集成到提示中#diff
語句或-d
標誌的原始文件分散生成的文件 npx gish-gpt
或者
npm install gish-gpt
node_modules/.bin/gish
替代性,用NPM Dev替換步驟3,以更改代碼
dist/index.js
dist/index.js
鏈接。或者,創建一個別名。 # gish tell me a joke
Why was the math book sad? Because it had too many problems.
# gish "What is the population of the city of London?".
The population of the City of London is approximately9 million, as of 2021.
如果沒有引號,殼將在第二個請求中解釋問號並引起錯誤。
管道輸入:
#echo "What is the population of the city of London?" | gish
The estimated population of the city of London is around 9 million people.
# gish.
> tell me a joke
Why did the tomato turn red? Because it saw the salad dressing!
這類似於在命令行中鍵入“ Python”或“ Node”。
gist < foo
Foo的內容在哪裡
tell me a joke
gish --help
顯示所有不同的選項gish tell me a joke
只會發送請求gish "what is the population of San Francisco?".
您需要報價以避免外殼錯誤。gish -e
將您放入編輯器中,並在完成後發送內容。流產,要么不創建文件,要么將其清空gish -e foo.txt
執行相同的操作,但在現有文件上運行。gish -h [num]
向您展示了歷史記錄。 NUM是可選的,默認為20。gish -i foo
發送foo的內容。等效於cat foo | gish
。gish -m gpt-4
指定模型gish -p foo
在聊天中使用FOO作為提示。其他標誌或參數用於傳遞實際請求,但這是背景。請參閱https://platform.openai.com/docs/guides/chat。 Gish將此提示設置為聊天中的第一個提示,即“系統”的角色。gish -s foo.ts
將輸出保存到foo.ts。生成代碼時,用戶需要使用生成適當輸出的提示。請參閱提示/編碼。gish -d foo.ts
與此文件相差。需要-s。gish -c [num]
激活聊天模式並指的是num請求,默認為上一個。有關更多詳細信息,請參見聊天部分。gish -g
生成多個文件以創建一個完整的應用程序。有關更多詳細信息,請參見生成部分。gish -x
額外的論點將傳遞給GPT。示例:-x'“溫度” = 0.5:“ max_tokens” = 500'。 如您的外殼-H或 - 歷史所示,顯示了您的請求的歷史記錄。可選的數字參數指定元素的數量。默認值為20。
聊天模式提供了與https://platform.openai.com/chat相似的體驗,您可以在其中參考以前的請求。
# gish what is the capital of japan
The capital of Japan is Tokyo.
# gish -c population
The estimated population of Tokyo, Japan as of2021 is approximately 13.9 million people.
使用歷史記錄功能,您可以在歷史記錄中查看請求的位置,並將其傳遞到-c參數中。
# gish tell me a joke
Why did the tomato turn red ? Because it saw the salad dressing !
# gish tell me a one line story
She found love in the most unexpected place.
# gish -h 2
892: tell me a joke
893: tell me a one line story
# gish -c 892 another
Why did the bicycle fall over ? Because it was two-tired !
有關可以使用的鞭毛列表,請參見[CHAT API文檔](https://platform.openai.com/docs/api-reference/chat)。此功能適用於高級用戶,但是如果通過不支持的標誌,API通常會出錯。
警告您通過的字符串需要有效的JSON。具體確保在“:”的兩面都將任何字符串包裹在雙引號中。這是JSON,而不是JavaScript!例子:
# gish -x '"temperature":0.5,"max_tokens":5' tell me a joke
Why did the tomato turn
使其在5個令牌後切碎響應。
chat
和輸入聊天模式的請求。類型出口以離開聊天模式。 使用可選數字鍵入歷史記錄以查看歷史記錄。默認值為20。
聊天模式提供了與https://platform.openai.com/chat相似的體驗,您可以在其中參考以前的請求。
> 10 miles to km
16.0934 km.
> chat how about 40
40 miles is equal to64.3736 kilometers.
Chat > how about 50
50 miles is equal to80.4672 kilometers.
Chat > exit
> how about 30
30 is a positive integer that comes after29 and before 31.
chat 876 another
使用輸入文件中的#import
語句包括您希望Chatgpt做出反應的提示或註釋/文本。例子
#import ~/work/gish/tasks/coding.txt
The above program prints hello world. Change it to print goodbye world.
#import hello.ts
這是tasks/coding.txt
的內容:
I want you to act as a coding collaborator. I will ask you software questions and you will answer with code.
Your response for this request needs to be code and nothing else.
Only provide comments if they provide important extra information and they should be brief and to the point. The contents should be in the code as comments at the top of the file.
---
這是使用Gish進行編碼時的典型工作流程:
當您希望GPT對文件進行更改,然後將其分開時,請使用#diff
選項:
#import ~/work/gish/tasks/coding.txt
In the following file, document the code better
#diff settings.ts
此過程類似於#import
,但也讓應用程序知道用戶正在修改文件。生成代碼後,在settings.ts
中定義的diff命令。TS將在原始文件和生成的文件上啟動。為了進行複雜的變化,副駕駛可能會更好。
使用適當的提示,例如[Web Application](Tasks/webapp.txt),建議您獲得LLM,GPT-4為此,但請嘗試並查看對您有用的方法。簡單地創建輸入文件
#import tasks/webapp.txt
Generate Conway's game of life.
Include on the page, the instructions on how to play the game.
然後運行
gish -m gpt-4 -g life -i /input
導致“生活”目錄中的生活遊戲。
警告
請注意,使用這種方法易於使用許多令牌,特別是使用GPT-4,因此成本可以加起來。
有關使用Gish的方法,請參見[示例](示例)DIR:
這是一個Shell腳本示例,該示例使用Gish生成Git Commit消息,並將用戶放入編輯器中,並使用消息進行了預言:
#! /bin/bash
out= " The following is the output of git diff "
out+= ` git diff $* `
out+= " ----------------------------- "
out+= " The following is the output of git status "
out+= ` git status --untracked-files=no $* `
out+= " ----------------------------- "
out+= " based on the above provide a commit message "
git commit -e -m " ` echo $out | gish --no-stats ` " $*
日誌文件,〜/.gish/history.json作為與chatgpt對話的日誌。由於它是標准文件,因此您可以使用編輯器或Pager來查看與Chatgpt互動的歷史記錄,其中包括:
與諸如CAT和Echo之類的Linux命令類似,以下是Gish如何優先考慮參數和標誌:
默認情況下,Gish向您顯示您的請求的統計信息:
gish tell me a joke --no-stream
Why don't scientists trust atoms?
Because they make up everything.
Tokens: 26 Cost: $0.00005 Elapsed: 1.198 Seconds
成本基於以下假設:您使用的是GPT3.5,每1000個令牌$ 0.02。 *在依靠數字之前仔細檢查數字。當使用流時,API不會給我們令牌的數量,因此我們需要自行計算它們,這可能會關閉。