This repository contains a Streamlit application for interacting with the Google Gemini-Pro AI model. The chatbot uses Streamlit's user-friendly interface to facilitate conversational AI interactions.
This repository is about building a chatbot using Google's Gemini-Pro with streamlit.
- Streamlit-based Chat Interface: A simple, clean interface for interacting with the chatbot.
- Google Gemini-Pro Integration: Utilizes the Gemini-Pro generative AI model for advanced conversational capabilities.
- Customizable Themes: Includes a custom dark theme with white background for better readability.
- Session Persistence: Maintains chat history within the session.
- Python 3.9 or above
streamlit
python-dotenv
google-generativeai
-
Clone the repository:
git clone <repository_url> cd <repository_name>
-
Create a virtual environment and activate it:
python -m venv env source env/bin/activate # On Windows, use `env\\Scripts\\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Create a
.env
file in the root directory. - Add your Google API key:
GOOGLE_API_KEY=your_google_api_key
- Create a
-
Run the Streamlit application:
streamlit run app.py
-
Open the application:
- The application will open in your default web browser, or you can access it at
http://localhost:8501
.
- The application will open in your default web browser, or you can access it at
-
Interact with the chatbot:
- Type your query in the input field labeled "Ask Gemini-Pro..." and view the responses from Gemini-Pro AI.
app.py
: Main Streamlit application file..env
: Environment variables file (not included; you need to create this).requirements.txt
: Python dependencies for the project.
The custom theme uses CSS injected via Streamlit's st.markdown
to provide a white background and dark text for better readability. You can modify the theme by editing the CSS block in the app.py
file:
st.markdown(
"""
<style>
body {
background-color: white;
color: #333333;
}
.st-bq {
background-color: #f5f5f5 !important;
color: #333333 !important;
}
</style>
""",
unsafe_allow_html=True
)
The Google Gemini-Pro AI model is configured using the google-generativeai
library. Ensure that you have a valid API key and that it is stored in the .env
file as GOOGLE_API_KEY
.
Contributions are welcome! Feel free to submit a pull request or open an issue to discuss changes or new features.
- Streamlit for the interactive UI framework.
- Google Generative AI for the Gemini-Pro model.
- Dotenv for managing environment variables.