aihelp
所属分类:GPT/ChatGPT
开发工具:Shell
文件大小:0KB
下载次数:0
上传日期:2023-03-06 19:33:56
上 传 者:
sh-1993
说明: 围绕curl的CLI包装器,用于向OpenAI API发出请求。
(CLI wrapper around curl for making requests to OpenAI API.)
文件列表:
aihelp.sh (1000, 2023-03-06)
assets/ (0, 2023-03-06)
assets/demo.gif (18611500, 2023-03-06)
distribution/ (0, 2023-03-06)
distribution/install.sh (590, 2023-03-06)
# `aihelp`
A convenience tool for getting help from AI on the command line.
It uses the [OpenAI API](https://platform.openai.com/docs/api-reference/making-requests) to get suggestions for the last command you ran.
### Installation
##### Automatic (Ubuntu, Debian only)
*Note that this is deemed unsafe. Don't do this if you don't trust the author.*
```bash
wget -O - https://raw.githubusercontent.com/v-spassky/aihelp/main/distribution/install.sh \
| bash /dev/stdin folder-to-save-script-to shell-conf-file command-name
```
- `folder-to-save-script-to` - the script will be downloaded to this path. Make sure it is in your `$PATH`;
- `shell-conf-file` - the script will add an alias to this file;
- `command-name` - the name of the command that will be used to run the script.
Example:
```bash
wget -O - https://raw.githubusercontent.com/v-spassky/aihelp/main/distribution/install.sh \
| bash /dev/stdin ~/.local/bin/ ~/.zshrc aihelp
```
Afterwards, rerun your shell configuration file (e.g. `source ~/.zshrc`).
##### Manual
- Download the script to a folder that is in your `$PATH` (i.e. at `~/.local/bin`);
- Make it executable;
- Add an alias to your `~/.bashrc`, `~/.zshrc` or whatever:
`alias aihelp="aihelp.sh \"\$(history | cut -c 8- | tail -n 1)\""`
- Make sure you have `jq` installed.
### Configuring
Open the script with a text editor of your choice and set the `OPENAI_API_TOKEN` variable:
`nano ~/.local/bin/aihelp.sh`
```bash
...
OPENAI_MODEL="gpt-3.5-turbo"
OPENAI_API_TOKEN="sk-zWHHjthO...LudGVG"
PROMPT_PREFIX="What is wrong with this command: "
PROMPT_POSTFIX=" ? I ran it in Linux terminal and it gave me an error. \
Please give a concise answer (ideally, 3-4 sentences)."
...
```
You might as well change all the other settings to your liking.
Also, you can change the alias to something else if you wish:
`alias whatever="aihelp.sh \"\$(history | cut -c 8- | tail -n 1)\""`
### Usage
Print `aihelp` to get a suggestion on the last command you ran.
近期下载者:
相关文件:
收藏者: