A command-line interface application for interacting with OpenAI's GPT models using the DecaChat wrapper.
- 🖥️ Interactive command-line interface
- 💬 Real-time chat with AI assistant
- 📜 Conversation history viewing
- 🔄 Conversation reset capability
- ⚙️ Configurable AI parameters
- 🔐 Secure environment variable configuration
- Node.js (v14 or higher)
- npm (Node Package Manager)
- Clone the repository:
git clone <repository-url>
cd decachat-cli
- Install dependencies:
npm install
- Create a
.env
file in the project root with your configuration:
API_KEY=your-openai-api-key
BASE_URL=https://api.openai.com/v1
CHAT_MODEL=gpt-4o-mini
- Start the application:
node app.js
- Available commands:
- Type your message and press Enter to chat with the assistant
!clear
- Reset the conversation!history
- View conversation historyquit
- Exit the application
The application can be configured using the following environment variables:
Variable | Description | Default Value |
---|---|---|
API_KEY | Your OpenAI API key | Required |
BASE_URL | API endpoint URL | https://api.openai.com/v1 |
CHAT_MODEL | GPT model to use | gpt-4o-mini |
Additional configuration in the code:
maxTokens
: 150 (maximum response length)temperature
: 0.7 (response creativity level)
DecaChat Test Application
------------------------
Type your messages and press Enter. Type "quit" to exit.
Special commands:
!clear - Clear conversation history
!history - Show conversation history
------------------------
You: Hello, who are you?
Assistant is typing...
Assistant: I'm an AI assistant programmed to provide concise and helpful responses.
You: !history
Conversation History:
[system]: You are a helpful assistant who provides concise responses.
[user]: Hello, who are you?
[assistant]: I'm an AI assistant programmed to provide concise and helpful responses.
You: !clear
Conversation cleared.
You: quit
The application includes robust error handling for:
- API connection issues
- Invalid responses
- Token limit exceeded
- Network errors
Errors are logged to the console with descriptive messages.
The application is built using:
deca-chat
: Wrapper for OpenAI's APIdotenv
: Environment variable managementreadline
: Command-line interface handling
To modify the system message or other parameters, edit the values in the main function:
chat.setSystemMessage('You are a helpful assistant who provides concise responses.');
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see the LICENSE file for details.