NerdChat CLI is a command-line chat tool for interacting with AI chat providers like DeepSeek and OpenAI. This script supports dynamic provider selection, model fetching, and chat conversation history management—all in a colorful and easy-to-use interface.
- Provider Support: Choose between DeepSeek and OpenAI.
- Dynamic API Key Handling: Enter your API keys only if needed.
- Model Selection: Fetch and select models dynamically from OpenAI or predefined DeepSeek models.
- Conversation History: Saves your chat history to a local JSON file for reference.
- Colorful Output: Differentiate between user, assistant, and system messages with colors.
- Bash: Version 4.0 or higher.
- Utilities:
- jq (for JSON processing)
- curl (for making API requests)
-
Clone the repository:
git clone https://github.com/lrrrrrrrr/cli-ai-chat.git cd cli-ai-chat -
Ensure the script has execution permissions:
chmod +x chat.sh
-
Install dependencies if not already installed:
-
For Ubuntu/Debian:
sudo apt update sudo apt install -y jq curl
-
For macOS (using Homebrew):
brew install jq curl
-
-
Run the script:
./chat.sh
-
Provider Selection: On startup, choose your AI provider:
DeepSeekorOpenAI.
-
API Key Setup: If an API key is missing, the script prompts you to enter it.
-
Model Selection: For OpenAI, dynamically fetch and select models. For DeepSeek, predefined models are available.
-
Chat: Type messages to interact with the assistant. Use the following commands:
/openai: Switch to OpenAI./deepseek: Switch to DeepSeek./models: Re-select the model./quit: Exit the script.
-
Conversation History: Chat history is automatically saved in
chat_history.json.
$ ./chat.sh
=== NerdChat CLI (Provider: OPENAI, Model: gpt-3.5-turbo). Warning: For nerds only! ===
USER: Hi there!
ASSISTANT: Hello! How can I help you today?
(Type your message, or use commands: /openai, /deepseek, /models, /quit)
Message> What's the weather today?
ASSISTANT: I can't fetch the weather, but I can tell you how to retrieve it using an API!- Disable Colors: Set the color variables in the script to empty strings (
"") for plain text output. - Use a Specific Provider by Default: Modify the script to set
providerinitially (e.g.,provider="openai").
Contributions are welcome! Feel free to submit a pull request or open an issue to discuss features or improvements.
This project is licensed under the MIT License.