This is a Python application that utilizes Google Gemini AI's capabilities to provide an interactive chatbot experience. The app has a graphical user interface (GUI) built with Tkinter, and it uses Google Gemini models to generate responses based on user input.
- Chat Interface: A simple and user-friendly chat interface that allows users to interact with the chatbot.
- Model Selection: Users can select between two models provided by Google Gemini AI:
gemini-2.0-flash(free, fast) andgemini-2.5-pro(latest, most capable). - End Scroll Button: A "Go to End" button allows the user to quickly scroll to the latest messages in the chat.
- API Key Management: Securely manage Google Gemini AI API keys using local encryption.
- Supports Code Formatting: The chatbot supports rendering responses with syntax-highlighted code blocks.
To run the chatbot, you'll need:
- Python 3.8 or newer installed on your system.
- Google Gemini AI API Key. Make sure you have a valid API key to use with the application.
If you do not have Python installed, you can download and install the latest version of Python 3 from Python.org. Make sure to add Python to your system PATH during the installation.
Create a directory for your project and create a Python file, for example, chatbot.py. You can use the code from the provided script to set up the chatbot.
Create a virtual environment to keep the dependencies organized:
python -m venv venvActivate the virtual environment:
venv\Scripts\activateOn macOS/Linux:
source venv/bin/activateCreate a requirements.txt file with the following content:
tkinterweb
cryptography
markdown
google-generativeai
pygmentsInstall the dependencies by running:
pip install -r requirements.txtThe application requires a master key for encryption purposes, which is set through an environment variable. Set this variable by running the following command:
export MASTER_KEY=<YOUR-SECRET-KEYS>or on Windows
set MASTER_KEY=<YOUR-SECRET-KEYS>After setting up the environment, run the chatbot using the following command:
python chatbot.py
or
python3 chatbot.pyTo package the Python application into an executable file (.exe), you can use PyInstaller. Follow these steps:
Install PyInstaller:
pip install pyinstallerCreate the Executable: Run the following command to create an executable version of your script:
pyinstaller --onefile chatbot.py-
The --onefile option ensures that all dependencies are packed into a single .exe file.
-
After running this command, a dist directory will be created containing the chatbot.exe file.
Running the Executable: Navigate to the dist directory and run the generated chatbot.exe file Note: On the first run, some antivirus software may flag the executable. You may need to mark it as safe.