Git source: https://github.com/bhaswarasiwi/work-helper-ai.git
Before you begin, ensure you have the following installed on your system:
GOOGLE_API_KEY
.
set GOOGLE_API_KEY=YOUR_API_KEY_HERE
export GOOGLE_API_KEY=YOUR_API_KEY_HERE
YOUR_API_KEY_HERE
with your actual key).Follow these steps to get the application running:
Clone the Repository (if applicable) If your project is hosted on GitHub, clone it to your local machine:Bash
git clone <https://github.com/bhaswarasiwi/work-helper-ai.git> cd your-repo-name # Navigate into your project directory
(Replace your-username/your-repo-name.git
with your actual GitHub repository URL).
If you've just been working on the files locally, navigate directly to your project directory.
Create a Virtual Environment It's highly recommended to use a virtual environment to manage project dependencies.Bash
python -m venv venv
Activate the Virtual Environment
**Windows:**Bash
.\\venv\\Scripts\\activate
**macOS/Linux:**Bash
source venv/bin/activate
You should see (venv)
in your terminal prompt, indicating the virtual environment is active.
Install Dependencies
Install all required Python packages using pip
and the requirements.txt
file:Bash
pip install -r requirements.txt
If you haven't created requirements.txt
yet, you can do so by running pip freeze > requirements.txt
(while your venv is active) and then install from it. If you don't have a requirements.txt
, you'll need to manually install Flask, google-generativeai, markdown-it-py, and DOMPurify (for frontend).
Configure Your API Key in config.py
(Verify)
Ensure your config.py
file properly uses your GOOGLE_API_KEY
environment variable. It should look something like this:Python
`# config.py import os import google.generativeai as genai
GEMINI_API_KEY = os.getenv('GOOGLE_API_KEY')
GEMINI_MODEL_NAME = "gemini-pro" GEMINI_GENERATION_CONFIG = { "temperature": 0.7, "top_p": 1, "top_k": 1, "max_output_tokens": 2048, }
ENABLE_SAFETY_SETTINGS = True if ENABLE_SAFETY_SETTINGS: GEMINI_SAFETY_SETTINGS = [ {"category": genai.types.HarmCategory.HARM_CATEGORY_HARASSMENT, "threshold": genai.types.HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE}, {"category": genai.types.HarmCategory.HARM_CATEGORY_HATE_SPEECH, "threshold": genai.types.HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE}, {"category": genai.types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, "threshold": genai.types.HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE}, {"category": genai.types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, "threshold": genai.types.HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE}, ] else: GEMINI_SAFETY_SETTINGS = []`
Run the Flask Application From your project's root directory (with the virtual environment active), run the Flask application:Bash
python app.py
You should see output indicating that the Flask development server is running, usually on http://127.0.0.1:5000/
.
Open your web browser and navigate to the address provided by Flask, typically:
http://127.0.0.1:5000/
You should now see your Gemini AI Chat application ready for use!