Git source: https://github.com/bhaswarasiwi/work-helper-ai.git

Prerequisites 📋

Before you begin, ensure you have the following installed on your system:

  1. Python 3.8+: You can download it from python.org.
  2. Git: Download and install Git from git-scm.com.
  3. Google Gemini API Key:

Installation Steps 🚀

Follow these steps to get the application running:

  1. 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.

  2. Create a Virtual Environment It's highly recommended to use a virtual environment to manage project dependencies.Bash

    python -m venv venv

  3. Activate the Virtual Environment

    You should see (venv) in your terminal prompt, indicating the virtual environment is active.

  4. 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).

  5. 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')

    ... other model configurations ...

    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 = []`

  6. 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/.


Access the Application 🌐

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!