{"id":31476754,"url":"https://github.com/parthapray/air_pollution_llm_advisor","last_synced_at":"2026-05-18T03:10:41.670Z","repository":{"id":300984267,"uuid":"1007800456","full_name":"ParthaPRay/Air_Pollution_LLM_Advisor","owner":"ParthaPRay","description":"This repo shows the coding of air pollution LLM advisor chatbot for localized LLM using Ollama","archived":false,"fork":false,"pushed_at":"2025-06-30T15:45:55.000Z","size":1246,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-02T01:43:13.389Z","etag":null,"topics":["airpollution","chatbot","edge","india","iot","large-language-models","localized","ollama","open-meteo-api","privacy","raspberrypi4","restapi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ParthaPRay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-24T14:47:30.000Z","updated_at":"2025-06-30T15:45:58.000Z","dependencies_parsed_at":"2025-06-24T15:46:18.757Z","dependency_job_id":"a766e376-1391-4bb2-86ed-016a8ee01ba6","html_url":"https://github.com/ParthaPRay/Air_Pollution_LLM_Advisor","commit_stats":null,"previous_names":["parthapray/air_pollution_llm_advisor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ParthaPRay/Air_Pollution_LLM_Advisor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FAir_Pollution_LLM_Advisor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FAir_Pollution_LLM_Advisor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FAir_Pollution_LLM_Advisor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FAir_Pollution_LLM_Advisor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ParthaPRay","download_url":"https://codeload.github.com/ParthaPRay/Air_Pollution_LLM_Advisor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FAir_Pollution_LLM_Advisor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33163437,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["airpollution","chatbot","edge","india","iot","large-language-models","localized","ollama","open-meteo-api","privacy","raspberrypi4","restapi"],"created_at":"2025-10-02T01:42:24.320Z","updated_at":"2026-05-18T03:10:41.646Z","avatar_url":"https://github.com/ParthaPRay.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Air Pollution LLM Advisor\n\n**Author**: Partha Pratim Ray  \n**Date**: 24 June 2025  \n**Email**: parthapratimray1986@gmail.com\n\n---\n\n## 📖 Project Overview\n\nThis project integrates:\n\n- **Live air quality data** from the Open-Meteo API\n- **Large Language Model (LLM)** reasoning using a locally hosted Ollama server\n- **Interactive map** with Folium visualization\n- **Conversational interface** using Gradio chatbot\n- **Persistent CSV logging** of all data, including model metrics\n\nThe system provides both real-time pollution data and expert-like environmental health advice using a locally running LLM model. It allows users to:\n\n- Search for any Indian city location\n- Get air quality data visualized and summarized\n- Query an LLM for health impact advice on the air quality\n- Log all interactions (first LLM advice only) into a CSV file for research and future analysis\n\n---\n\n## ⚙ Deployment Scenario: Raspberry Pi + Local Network Ollama\n\nThis system is specifically designed to run on **resource-constrained edge devices like Raspberry Pi 4B**, while leveraging the power of **localized private LLM inference** hosted on a separate GPU-enabled machine on the same local network.\n\nThe Raspberry Pi 4B acts as:\n\n* The **interactive user interface server** using Gradio (lightweight, fully browser-based UI)\n* The **data fetcher** from Open-Meteo public API for live air pollution data\n* The **controller** that sends structured prompts to the LLM server over the local network\n\nMeanwhile, the Large Language Model (LLM) itself runs independently on a **local GPU-powered laptop or workstation** using **Ollama**, an open-source privacy-preserving LLM deployment platform.\n\nThis architecture offers:\n\n* ✅ **Privacy-aware design** — no external cloud dependencies\n* ✅ **Free of cost** — Ollama and all models run fully offline after setup\n* ✅ **High availability** — even works entirely offline after initial setup\n* ✅ **Separation of concerns** — lightweight front-end on Raspberry Pi, heavy model inference on GPU server\n* ✅ **Interactive real-time dialogue** — Gradio handles persistent chat sessions, the LLM responds to queries, and the user can freely continue conversations after receiving advice\n\nIn this hybrid edge-GPU deployment, all sensitive data remains entirely within the user's private infrastructure, making it highly suitable for research, academic demonstrations, or privacy-critical deployments.\n\n\n---\n\n## 🌐 Features\n\n- Live AQI data retrieval from Open-Meteo\n- PM2.5, PM10, CO, NO2, SO2, O3, AOD, Dust, UV Index, Methane readings\n- Folium-based India map with markers\n- Gradio UI with full interactive chat\n- Uses **Ollama LLM** (local deployment) to answer health queries\n- First LLM interaction logged into `llm_aqi_log.csv` with full model metrics:\n    - `total_duration`, `load_duration`, `prompt_eval_count`, `prompt_eval_duration`, `eval_count`, `eval_duration`, `tokens_per_second`\n- After initial LLM analysis, user can continue chatting but no further logs are generated (only first LLM call is logged)\n- Fully edge-deployable with Raspberry Pi or local laptop server running Ollama\n\n---\n\n## 🔧 Requirements\n\n- Python 3.10 or newer\n- Ollama server installed and running locally (https://ollama.com/)\n- Models loaded inside Ollama (e.g., `granite3.1-moe`, `deepseek-r1`, `qwen3`, etc.)\n\n---\n\n## 🔑 Installation\n\nClone this repository:\n\n```bash\ngit clone https://github.com/yourusername/air-pollution-llm-advisor.git\ncd air-pollution-llm-advisor\n````\n\nCreate virtual environment (recommended):\n\n```bash\npython3 -m venv venv\nsource venv/bin/activate\n```\n\nInstall Python dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n---\n\n## 🔑 Running Ollama Server\n\nInstall Ollama on your host machine:\n\n```bash\nhttps://ollama.com/download\n```\n\nLoad your desired model(s) into Ollama:\n\n```bash\nollama run granite3.1-moe\n# or \nollama run deepseek-r1\n```\n\nEnsure Ollama API is available at:\n\n```\nhttp://localhost:11434/\n```\n\nIf you're using a remote Ollama server, edit this line in the code:\n\n```python\nOLLAMA_IP = \"192.168.x.x\"  # your Ollama host IP\nOLLAMA_PORT = \"11434\"\n```\n\n---\n\n## 🚀 Launching the Application\n\nStart your Gradio UI by running:\n\n```bash\npython app.py\n```\n\nBy default, it launches at:\n\n```\nhttp://0.0.0.0:7860\n```\n\n---\n\nThe Ollama activivity can be seen by following command on laptop acting as cloud in real-time on a terminal:\n\n```bash\njournalctl -u ollama -f\n```\n\n---\n\n## 📝 Output File\n\nThe application creates a log file `llm_aqi_log.csv` containing:\n\n* Timestamp\n* Location \u0026 Coordinates\n* All pollutant values (cleaned: no units)\n* Chosen LLM model\n* LLM generated response\n* Ollama model metrics\n\nExample:\n\n| timestamp | location | lat | lon | PM2.5 | PM10 | ... | llm\\_response | total\\_duration | load\\_duration | ... |\n| --------- | -------- | --- | --- | ----- | ---- | --- | ------------- | --------------- | -------------- | --- |\n\n---\n\n## 📦 requirements.txt\n\n```text\ngradio\nfolium\nrequests\n```\n\n---\n\n## ⚠️ Notes\n\n* The first click on \"**Ask LLM for Pollution Analysis**\" triggers CSV logging.\n* After that, multiple chats can continue but only the first advice gets logged.\n* Units (μg/m³, ppm, mg/m³) are automatically stripped before logging.\n* Compatible with any Ollama model that supports `/api/generate` or `/api/chat` endpoints.\n* Thinking mode is disabled in Ollama calls (`\"think\": false`) for faster responses.\n\n---\n\n## 📄 Citation\n\nIf you use this work, please cite:\n\n```bibtex\n@misc{ray2025airpollution,\n  author = {Partha Pratim Ray},\n  title = {Air Pollution LLM Advisor},\n  year = {2025},\n  month = {June},\n  url = {https://github.com/yourusername/air-pollution-llm-advisor},\n  note = {Version 1.0},\n  howpublished = {GitHub repository},\n}\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparthapray%2Fair_pollution_llm_advisor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparthapray%2Fair_pollution_llm_advisor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparthapray%2Fair_pollution_llm_advisor/lists"}