Skip to content

decagondev/Chatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chatter

A command-line interface application for interacting with OpenAI's GPT models using the DecaChat wrapper.

Features

  • 🖥️ Interactive command-line interface
  • 💬 Real-time chat with AI assistant
  • 📜 Conversation history viewing
  • 🔄 Conversation reset capability
  • ⚙️ Configurable AI parameters
  • 🔐 Secure environment variable configuration

Prerequisites

  • Node.js (v14 or higher)
  • npm (Node Package Manager)

Installation

  1. Clone the repository:
git clone <repository-url>
cd decachat-cli
  1. Install dependencies:
npm install
  1. 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

Usage

  1. Start the application:
node app.js
  1. Available commands:
  • Type your message and press Enter to chat with the assistant
  • !clear - Reset the conversation
  • !history - View conversation history
  • quit - Exit the application

Configuration

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)

Example Session

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

Error Handling

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.

Development

The application is built using:

  • deca-chat: Wrapper for OpenAI's API
  • dotenv: Environment variable management
  • readline: 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.');

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see the LICENSE file for details.

About

A simple cli chat bot using DecaChat

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published