Richat is a command-line ChatGPT tool implemented in Ruby that supports highly customizable configuration. It can save chat contents, performs fuzzy searches on historical inputs, allows for prompt switching at any time and can even run Linux commands.
2023-03-30.16.58.51.mov
- Save chat contents in markdown files
- Switch and set prompt easily
- Auto complete, traverse and search input history
- Can even be used as a real Linux terminal
- Fully configurable
gem install richat
There are two ways to configure OpenAI API key
- set
OPENAI_API_KEY
env variable - edit
~/.richat/config.json
file and set API key, for example
{
"chatgpt": {
"api_key": "YOUR OPENAI API KEY"
}
}
Then run richat
command to talk with ChatGPT.
Use /config
command to show current configuration.
>> /config
Configuration file path is /Users/fzdp/.richat/config.json
{
"chatgpt": {
"api_key": "YOUR_OPENAI_API_KEY",
"model": "gpt-3.5-turbo",
"temperature": 0.7
},
"log": {
"enable": true,
"log_dir": "~/.richat/logs",
"log_file": null,
"user_role": "USR",
"ai_role": "GPT",
"system_role": "SYS"
},
"shell": {
"save_shell_history": true,
"enable_chat_context": true,
"show_welcome_info": true,
"shell_history_file": "~/.richat/history.txt",
"exit_keywords": [
"/exit",
"q",
"quit",
"exit"
],
"chat_context_indicator": "💡"
},
"sys_cmd": {
"activate_keywords": [
">",
"!"
],
"deactivate_keywords": [
"q",
"quit",
"exit"
]
},
"prompt": {
"prompt_dir": "~/.richat/prompts",
"default": ""
}
}
Edit ~/.richat/config.json
if you need customize configuration.
By default, Richat will log your chat history and log names are in date format.
Set log.enable
to false if you don't need log feature.
Default logs directory is ~/.richat/logs
, you can set another directory if needed.
If you need save chat logs in a single file, for example in ~/chatgpt_logs.md
, there are two ways to do this:
- edit
~/.richat/config.json
{
"log": {
"log_file": "~/chatgpt_logs.md"
}
- through command line
richat --logfile ~/chatgpt_logs.md
If log file is not an absolute path then its parent directory is log_dir
.
You can place prompt files in ~/.richat/prompts
or other directory defined in configure file.
For example, if you place emoji
, linux
, wikipedia
in the directory, then in Richat shell /prompt
command will show these prompt files.
You can use /prompt
command to switch prompt, the argument is prompt file name or prompt file index.
For example if you want to use linux as default prompt, just edit config file
{
"prompt": {
"default": "linux"
}
}
Then Richat shell will use linux prompt when it's run
By default your input history will be saved in ~/.richat/shell_history_file
.
In Richat shell mode, there are three ways to enhance chat experience.
- press TAB to auto complete input
- press Arrow keys to traverse history
- press
Control + R
to fuzzy search input
ChatGPT stream mode is auto enabled in Richat shell mode
2023-03-30.16.04.38.mov
You can run richat
with additional chat content directly
~ richat hello world
Hello! How can I assist you today?
Chat context is enabled by default, because ChatGPT have no memory of past requests, all relevant information must be supplied via the conversation.
You can toggle chat context mode using /context
command.
Press >
or any other keys defined in config file, then you will enter linux shell mode where you can run any commands.
press q
or other keys you defined to exit linux shell mode.
Bug reports and pull requests are welcome on GitHub at https://github.com/fzdp/richat.
The gem is available as open source under the terms of the MIT License.