SohamLone77/Disaster_Resource_connector
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
- Fork this repository to your GitHub account
- Go to Hugging Face Spaces
- Click "Create new Space"
- Select:
- Owner: Your Hugging Face username
- Space name:
disaster-resource-connector - License: OpenRAIL (or your choice)
- Space SDK: Docker
- Connect your GitHub repository
- Click "Create Space"
The app will automatically deploy using the Dockerfile.
Option 2: Manual Setup
- Create a new Space on Hugging Face with Gradio SDK
- Clone this repository
- Push the code to the Space repository
- The app will auto-deploy
Local Development
Prerequisites
- Python 3.8+
- pip or conda
Installation
# 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.txtRunning Locally
python app.pyThe application will launch at http://localhost:7860
Usage
- Open the Gradio interface
- Enter your situation in the text box (e.g., "I need shelter after the hurricane")
- Click "Find Resources" or press Enter
- 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 toolsDependencies
- 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:
- Add
.envfile with API keys - Update
tools/tools.pyto fetch from real APIs - Update requirements.txt with API client libraries
Testing
Run test cases:
python run_demo.pyThis 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:
- Check the Hugging Face Spaces documentation
- Review logs in the Hugging Face Space interface
- 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
