DEV Community

Avanish
Avanish

Posted on

TrailMind: An Offline Open-Source AI Companion for the Trail 🌲

Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass Submission 🌿

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass

What I Built

For the Hacktoberfest "Touch Grass" Challenge, I built TrailMind, a lightweight Python-based offline assistant designed to help hikers, nature enthusiasts, and explorers get out into nature without being tethered to cell towers or cloud-dependent APIs. Whether you're deep in a forest or exploring local green spaces with spotty signal, TrailMind provides immediate guidance on trail safety, plant characteristics, and wildlife etiquette.

Demo

You can run the script instantly on any local machine or portable device to test out trail queries offline before heading out.

Code


python
import sys

TRAIL_DATABASE = {
    "plant": "If you spot broad, alternating leaves with jagged edges on this trail, it's likely a native local shrub. Avoid touching unfamiliar berries!",
    "wildlife": "If you encounter local wildlife, remain calm, make yourself look large, and back away slowly without running.",
    "weather": "Mountain and trail weather can shift rapidly. Always keep a lightweight windbreaker and emergency poncho handy.",
    "hydration": "Drink water regularly in small sips rather than waiting until you feel thirsty on the trail."
}

def local_trail_assistant(query):
    query = query.lower()
    print("\n[TrailMind Local Engine]: Processing query offline...")
    for keyword, advice in TRAIL_DATABASE.items():
        if keyword in query:
            return advice
    return "General Trail Tip: Stay on marked paths, respect local flora and fauna, and leave no trace!"

if __name__ == "__main__":
    print("=== TrailMind: Your Offline Outdoor Companion ===")
    user_query = "What should I do if I see a plant with jagged edges?"
    if len(sys.argv) > 1:
        user_query = " ".join(sys.argv[1:])
    print(f"Hiker Query: {user_query}")
    print(f"Advice: {local_trail_assistant(user_query)}\n")
Enter fullscreen mode Exit fullscreen mode

Top comments (0)