CoolFace
Apppublic

SohamLone77/Disaster_Resource_connector

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
App README

Disaster Resource Connector ๐Ÿ†˜

An AI-powered agent that helps people find essential resources during disaster situations, including shelter, food, medical aid, and government assistance.

Features

  • โ€”Multi-Agent Architecture: Planner, Worker, and Evaluator agents work together to process requests
  • โ€”Resource Discovery: Find shelters, food distribution points, medical stations, and government aid
  • โ€”Context Understanding: Analyzes urgency and disaster type from user input
  • โ€”Session Memory: Maintains conversation history and caches resource data
  • โ€”Real-time Observability: Tracks agent activities and performance metrics

Architecture

app.py (Gradio Interface)
  โ†“
main_agent.py (Orchestrator)
  โ”œโ”€โ”€ agents/
  โ”‚   โ”œโ”€โ”€ planner.py (Creates execution plans)
  โ”‚   โ”œโ”€โ”€ worker.py (Executes resource discovery)
  โ”‚   โ””โ”€โ”€ evaluator.py (Validates and ranks results)
  โ”œโ”€โ”€ core/
  โ”‚   โ”œโ”€โ”€ context_engineering.py (Analyzes user context)
  โ”‚   โ”œโ”€โ”€ observability.py (Logging and metrics)
  โ”‚   โ””โ”€โ”€ a2a_protocol.py (Agent-to-agent messaging)
  โ”œโ”€โ”€ memory/
  โ”‚   โ””โ”€โ”€ session_memory.py (Session and cache management)
  โ””โ”€โ”€ tools/
      โ””โ”€โ”€ tools.py (Resource data)

Deployment on Hugging Face Spaces

Option 1: Direct Deployment

  1. 1.Fork this repository to your GitHub account
  2. 2.Go to Hugging Face Spaces
  3. 3.Click "Create new Space"
  4. 4.Select:
  5. 5.Owner: Your Hugging Face username
  6. 6.Space name: disaster-resource-connector
  7. 7.License: OpenRAIL (or your choice)
  8. 8.Space SDK: Docker
  9. 9.Connect your GitHub repository
  10. 10.Click "Create Space"

The app will automatically deploy using the Dockerfile.

Option 2: Manual Setup

  1. 1.Create a new Space on Hugging Face with Gradio SDK
  2. 2.Clone this repository
  3. 3.Push the code to the Space repository
  4. 4.The app will auto-deploy

Local Development

Prerequisites

  • โ€”Python 3.8+
  • โ€”pip or conda

Installation

bash
# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Running Locally

bash
python app.py

The application will launch at http://localhost:7860

Usage

  1. 1.Open the Gradio interface
  2. 2.Enter your situation in the text box (e.g., "I need shelter after the hurricane")
  3. 3.Click "Find Resources" or press Enter
  4. 4.View the recommended resources with locations and descriptions

Example Queries

  • โ€”"I need shelter after the hurricane"
  • โ€”"Where can I find food and water?"
  • โ€”"Medical assistance needed urgently"
  • โ€”"How do I apply for FEMA aid?"

Configuration for Hugging Face

The code automatically adapts to Hugging Face environment:

  • โ€”Port: Uses port 7860 (Hugging Face default)
  • โ€”Logging: Only writes to console (file logging disabled on Spaces)
  • โ€”Server: Binds to 0.0.0.0 (accessible from web)

Project Structure

project/
โ”œโ”€โ”€ app.py                 # Gradio interface (main entry point)
โ”œโ”€โ”€ main_agent.py          # Agent orchestrator
โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”œโ”€โ”€ README.md             # This file
โ”œโ”€โ”€ agents/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ planner.py        # Request planning
โ”‚   โ”œโ”€โ”€ worker.py         # Resource discovery
โ”‚   โ””โ”€โ”€ evaluator.py      # Result evaluation
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ context_engineering.py  # User context analysis
โ”‚   โ”œโ”€โ”€ observability.py         # Logging and metrics
โ”‚   โ””โ”€โ”€ a2a_protocol.py          # Agent communication
โ”œโ”€โ”€ memory/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ session_memory.py   # Session and cache management
โ””โ”€โ”€ tools/
    โ”œโ”€โ”€ __init__.py
    โ””โ”€โ”€ tools.py           # Resource data and tools

Dependencies

  • โ€”gradio: Web UI framework
  • โ€”transformers: NLP models (for future enhancements)
  • โ€”torch: Deep learning framework
  • โ€”numpy/pandas: Data processing
  • โ€”requests: HTTP requests

Environment Variables

Currently, the application works without environment variables. All configuration is hardcoded for demo purposes. To extend with real APIs:

  1. 1.Add .env file with API keys
  2. 2.Update tools/tools.py to fetch from real APIs
  3. 3.Update requirements.txt with API client libraries

Testing

Run test cases:

bash
python run_demo.py

This will test the agent with sample queries and display results.

Troubleshooting

Import Errors

  • โ€”Ensure you're in the project root directory
  • โ€”Check that all relative imports are used (no project. prefix)
  • โ€”Verify Python path: echo $PYTHONPATH

Port Issues

  • โ€”Hugging Face Spaces automatically handles port mapping
  • โ€”Locally, the app uses port 7860

Dependencies

  • โ€”Update all packages: pip install --upgrade -r requirements.txt
  • โ€”Check Python version: python --version (should be 3.8+)

Future Enhancements

  • โ€”[ ] Integration with real disaster resource APIs
  • โ€”[ ] Real-time location-based filtering
  • โ€”[ ] Multi-language support
  • โ€”[ ] User authentication and preferences
  • โ€”[ ] SMS integration for emergency alerts
  • โ€”[ ] Offline support

License

This project is provided as-is for educational and humanitarian purposes.

Support

For issues or questions:

  1. 1.Check the Hugging Face Spaces documentation
  2. 2.Review logs in the Hugging Face Space interface
  3. 3.Test locally before deploying

Built with โค๏ธ for disaster relief assistance ======= --- title: Disaster Resource Connector emoji: ๐ŸŒ– colorFrom: gray colorTo: pink sdk: gradio sdkversion: 6.0.2 appfile: app.py pinned: false ---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

>>>>>> 6ec802608ae2cdb53393a9643eaeebb2b59f6a7a