A simple, safe AI-powered search engine prototype designed for children aged 6-10.
This project provides a web interface where children can ask questions. The backend, built with Python and Flask, takes the query, performs basic safety checks, and then uses the OpenRouter API (specifically configured for google/gemini-pro-2.5 in this implementation) with carefully crafted prompts to generate simple, safe, and age-appropriate answers.
The focus is on:
- Safety: Basic input/output filtering and strict AI prompting to avoid inappropriate content.
- Simplicity: Generating answers using vocabulary and sentence structures suitable for early elementary readers.
- Backend: Python 3.11+, Flask
- AI Interaction: OpenRouter API (
google/gemini-pro-2.5model) viarequestslibrary - Frontend: HTML, CSS, JavaScript
- Environment: Python Virtual Environment (
venv)
-
Clone the repository (if you haven't already):
git clone git@github.com:yusufmalikul/kidsearch.git cd kidsearch -
Create a Python virtual environment:
python3.11 -m venv .venv
-
Activate the virtual environment:
- Linux/macOS:
source .venv/bin/activate - Windows (Git Bash/WSL):
source .venv/Scripts/activate - Windows (CMD):
.venv\Scripts\activate.bat - Windows (PowerShell):
.venv\Scripts\Activate.ps1
- Linux/macOS:
-
Install dependencies:
pip install -r requirements.txt
-
Set the OpenRouter API Key: You need an API key from OpenRouter. Set it as an environment variable named
OPENROUTER_API_KEY.- Option A (Environment Variable):
(You'll need to do this every time you open a new terminal session unless you add it to your shell profile)
# Linux/macOS export OPENROUTER_API_KEY='your_openrouter_api_key_here' # Windows CMD set OPENROUTER_API_KEY=your_openrouter_api_key_here # Windows PowerShell $env:OPENROUTER_API_KEY='your_openrouter_api_key_here'
- Option B (.env file):
Create a file named
.envin the project root directory (kid-search/) with the following content:Then, installOPENROUTER_API_KEY=your_openrouter_api_key_herepython-dotenv:And uncomment/add the following lines near the top ofpip install python-dotenv
app.py:(Thefrom dotenv import load_dotenv load_dotenv()
.envfile is already included in.gitignore)
- Option A (Environment Variable):
- Make sure your virtual environment is activated and the
OPENROUTER_API_KEYis set (either as an environment variable or via.env). - Run the Flask development server:
python app.py # Or directly using the venv python if not activated: # .venv/bin/python app.py
- Open your web browser and navigate to
http://127.0.0.1:5000(or the address shown in the terminal).
Enter a query in the input box and press Enter to get a response.