-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the nodeBOT wiki!
This program is a chatbot application written in JavaScript. It uses the Google Generative AI module to generate responses to user input. The chatbot is capable of having a conversation with the user, and it stores the conversation history for future reference.
-
Environment Variables: The program uses the dotenv module to load environment variables from a .env file. This is where the API key for the Google Generative AI module is stored.
-
Google Generative AI: The Google Generative AI module is used to generate responses to user input. The program creates an instance of GoogleGenerativeAI with the API key.
-
Readline Interface: The readline module is used to create an interface for input and output in the console.
-
Conversation History: The program stores the conversation history in an array. Each conversation consists of a question from the user and an answer from the chatbot.
-
Menu Options: The program provides a menu with several options, including reading the README.md file, displaying information about the author, chatting with the bot, displaying prior conversations, and exiting the program.
-
Error Handling: The program includes error handling for invalid user input and issues with reading the README.md file.
-
Graceful Shutdown: The program listens for a command event (Ctrl+C) and shuts down gracefully when this event is detected.
This program is a great example of a simple but effective chatbot application using Google's Generative AI. It demonstrates good practices in terms of security (with the use of environment variables), user interaction (with the readline interface and menu options), and error handling.
-
Prerequisites: Ensure you have Node.js installed on your machine. You will also need an API key from Google Generative AI.
-
Installation: Clone the repository to your local machine and run
npm install
to install all necessary dependencies. -
Setup: Create a
.env
file in the root directory and add your Google Generative AI API key asAPI_KEY
. -
Running the Program: Use the command
node chatbot.js
to start the program.
To interact with the chatbot, follow the prompts in the console. You can ask the bot questions, view prior conversations, read the README.md file, view information about the author, or exit the program.
Contributions are welcome! Please fork this repository and open a pull request to add enhancements, fix bugs, or make other improvements.
This project is licensed under the MIT License.