Video Demo: https://youtu.be/96rdAvVNIuY
This project is a Command-Line Interface (CLI) AI Chatbot implemented in C++. It integrates the Gemini API for natural language generation and supports user authentication with registration and login features. Each user's chat history is stored and retrieved during subsequent logins, providing a personalized experience.
- User Authentication:
- Register with a unique username and password (passwords are hashed using SHA256 for security).
- Log in with your credentials to access your chat history.
- Chat History:
- User-specific chat histories are stored in text files (e.g.,
history_<username>.txt
) and persist across sessions. - View previous conversations upon login.
- User-specific chat histories are stored in text files (e.g.,
- AI-Powered Conversations:
- Uses the Gemini API to generate intelligent and context-aware responses.
- Robust Error Handling:
- Handles invalid inputs, API errors, and empty requests gracefully.
- C++ Compiler with support for C++11 or later
- OpenSSL Library (for password hashing)
libcurl
Library (for HTTP requests)nlohmann/json
Library (for JSON processing)- Gemini API Key
git clone https://github.com/HtetAungKhant23/AIChatBot.git
cd AIChatBot
Make sure the following libraries are installed on your system:
- OpenSSL
libcurl
nlohmann/json
For Debian-based systems:
sudo apt-get install libssl-dev libcurl4-openssl-dev nlohmann-json3-dev
Replace the placeholder API key in the code with your actual Gemini API key:
string apiKey = "YOUR_API_KEY_HERE";
Use g++ to compile the source code:
g++ aichatbot.cpp -o chatbot -lcurl -std=c++17 -lssl -lcrypto -I/usr/include/openssl
Execute the program:
./chatbot
- Start the program and choose the Register option.
- Enter a unique username and password.
- Your credentials will be securely stored.
- Choose the Login option and enter your username and password.
- View your previous chat history (if any).
- Enter your messages, and the chatbot will respond using the Gemini API.
- Type
exit
to end the session.
- Invalid Credentials: Displays a message for incorrect username or password.
- API Errors: Prints detailed error messages if the API fails to respond.