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不会给我们令牌的数量,因此我们需要自行计算它们,这可能会关闭。