@ -43,21 +43,22 @@ Download it from [GitHub Releases](https://github.com/sigoden/aichat/releases),
## Features
- Support most of the LLM platforms
- OpenAI (paid, vision)
- OpenAI: GPT3.5/GPT4 (paid, vision)
- Gemini (free, vision)
- Claude (paid)
- Claude: Claude2/Claude3 (paid)
- Mistral (paid)
- LocalAI (free, local, vision)
- Ollama (free, local)
- Azure-OpenAI (paid)
- VertexAI (paid, vision)
- VertexAI: Gemini (paid, vision)
- Ernie (paid)
- Qianwen (paid, vision)
- Support [REPL Mode](#chat-repl) and [Command Mode](#command)
- Support [Roles](#roles)
- Support context-aware conversation (session)
- Support [Command Mode](#command) and [Chat-REPL Mode](#chat-repl)
- Support [roles](#roles)
- Support sessions (context-aware conversation)
- Support multimodal models (vision)
- Execute commands using natural language
- Shell integration
- Syntax highlighting for markdown and 200+ languages in code blocks
- Save messages/sessions
- Stream/Non-stream output
@ -104,52 +105,139 @@ Take a look at the [config.example.yaml](config.example.yaml) for the complete c
There are some configurations that can be set through environment variables. For more information, please refer to the [Environment Variables](https://github.com/sigoden/aichat/wiki/Environment-Variables) page.
### Roles
## Command
We can define a batch of roles in `roles.yaml`.
```
Usage: aichat [OPTIONS] [TEXT]...
> We can get the location of `roles.yaml` through the repl's `.info` command or cli's `--info` option.
Arguments:
[TEXT]... Input text
For example, we can define a role:
Options:
-m, --model <MODEL> Choose a LLM model
-r, --role <ROLE> Choose a role
-s, --session [<SESSION>] Create or reuse a session
-e, --execute Execute commands using natural language
-c, --code Generate only code
-f, --file <FILE>... Attach files to the message to be sent
-H, --no-highlight Disable syntax highlighting
-S, --no-stream No stream output
-w, --wrap <WRAP> Specify the text-wrapping mode (no, auto, <max-width>)
Let ChatGPT answer questions in the role of a Linux shell expert.
### Execute commands using natural language
Simply input what you want to do in natural language, and aichat will prompt and run the command that achieves your intent.
```
> .role shell
aichat -s <text>...
```
shell> extract encrypted zipfile app.zip to /tmp/app
mkdir /tmp/app
unzip -P PASSWORD app.zip -d /tmp/app
Aichat is aware of OS and `$SHELL` you are using, it will provide shell command for specific system you have. For instance, if you ask `aichat` to update your system, it will return a command based on your OS. Here's an example using macOS:
```sh
aichat -e update my system
# sudo softwareupdate -i -a
# ? [e]xecute, [d]escribe, [a]bort: (e)
```
AIChat with roles will be a universal tool.
The same prompt, when used on Ubuntu, will generate a different suggestion:
```sh
aichat -e update my system
# sudo apt update && sudo apt upgrade -y
# ? [e]xecute, [d]escribe, [a]bort: (e)
```
We can still use pipes to pass input to aichat and generate shell commands:
We can also pipe the output of aichat which will disable interactive mode.
```sh
aichat -e find all json files in current folder | pbcopy
```
$ aichat --role shell extract encrypted zipfile app.zip to /tmp/app
unzip -P password app.zip -d /tmp/app
$ cat README.md | aichat --role spellcheck
### Shell integration
This is a **very handy feature**, which allows you to use `aichat` shell completions directly in your terminal, without the need to type `aichat` with prompt and arguments. This feature puts `aichat` completions directly into terminal buffer (input line), allowing for immediate editing of suggested commands.
To install shell integration, go to [./scripts/shell-integration](https://github.com/sigoden/aichat/tree/main/scripts/shell-integration) to download the script and source the script in rc file. After that restart your shell. You can invoke the completion with `alt+e` hotkey.
## Generate Code
By using the `--code` or `-c` parameter, you can specifically request pure code output, for instance:
```
aichat --code a echo server in node.js
```
For more details about roles, please visit [Role Guide](https://github.com/sigoden/aichat/wiki/Role-Guide).
```js
const net = require('net');
const server = net.createServer(socket => {
socket.on('data', data => {
socket.write(data);
});
socket.on('end', () => {
console.log('Client disconnected');
});
});
server.listen(3000, () => {
console.log('Server running on port 3000');
});
```
Since it is valid js code, we can redirect the output to a file:
```
aichat --code a echo server in node.js > echo-server.js
Aichat is aware of OS and `$SHELL` you are using, it will provide shell command for specific system you have. For instance, if you ask `aichat` to update your system, it will return a command based on your OS. Here's an example using macOS:
Let ChatGPT answer questions in the role of a Linux shell expert.
```sh
aichat -e update my system
# sudo softwareupdate -i -a
# ? [e]xecute, [d]escribe, [a]bort: (e)
```
> .role shell
The same prompt, when used on Ubuntu, will generate a different suggestion:
```sh
aichat -e update my system
# sudo apt update && sudo apt upgrade -y
# ? [e]xecute, [d]escribe, [a]bort: (e)
shell> extract encrypted zipfile app.zip to /tmp/app
mkdir /tmp/app
unzip -P PASSWORD app.zip -d /tmp/app
```
We can still use pipes to pass input to aichat and generate shell commands:
$ aichat --role shell extract encrypted zipfile app.zip to /tmp/app
unzip -P password app.zip -d /tmp/app
We can also pipe the output of aichat which will disable interactive mode.
```sh
aichat -e find all json files in current folder | pbcopy
$ cat README.md | aichat --role spellcheck
```
### Shell integration
This is a **very handy feature**, which allows you to use `aichat` shell completions directly in your terminal, without the need to type `aichat` with prompt and arguments. This feature puts `aichat` completions directly into terminal buffer (input line), allowing for immediate editing of suggested commands.
To install shell integration, go to [./scripts/shell-integration](https://github.com/sigoden/aichat/tree/main/scripts/shell-integration) to download the script and source the script in rc file. After that restart your shell. You can invoke the completion with `alt+e` hotkey.
For more details about roles, please visit [Role Guide](https://github.com/sigoden/aichat/wiki/Role-Guide).