A Streamlit-based chat interface that uses Google's Gemini API to create an interactive AI chatbot experience.
- 🚀 Modern, clean interface built with Streamlit
- 🔒 Secure API key management
- 💬 Interactive chat interface
- 🔄 Persistent chat history within sessions
- ⚡ Real-time responses from Gemini API
- 🛡️ Error handling and rate limiting protection
- Python 3.6 or higher
- A Gemini API key (Get it from Google AI Studio)
- Clone this repository:
git clone https://github.com/tufail26/myAI_Chatbot.git
cd myAI_Chatbot- Install the required dependencies:
pip install -r requirements.txtThere are two ways to configure your Gemini API key:
-
Recommended: Using Streamlit Secrets
- Create a
.streamlit/secrets.tomlfile - Add your API key:
GEMINI_API_KEY = "your-api-key-here"
- Create a
-
Alternative: Input at Runtime
- Enter your API key directly in the web interface when prompted
- Start the application:
streamlit run app.py-
Open your web browser and navigate to the URL shown in the terminal (typically
http://localhost:8501) -
If you haven't configured the API key in secrets, enter it when prompted
-
Start chatting with the AI!
app.py- Main Streamlit application interfacechatbot_backend.py- Backend class for Gemini API integrationrequirements.txt- Project dependencies.streamlit/secrets.toml- (Optional) Configuration file for API key
The chatbot uses:
- Gemini API version: 2.5-flash-preview-09-2025
- Temperature: 0.9
- Max Output Tokens: 2048
- Built-in retry mechanism with exponential backoff for rate limiting
- Never commit your API key to version control
- Prefer using Streamlit secrets over runtime input for API key management
- The application includes basic error handling and input validation
Feel free to open issues or submit pull requests for improvements!