Learning Enhanced Watershed Assessment System (LEWAS) Lab
Virginia Tech - Conversational Interface for Environmental Research
π Access the Chatbot: https://lewaschatbot.streamlit.app/
The LEWAS AI Chatbot Frontend is an intuitive Streamlit web application that provides a conversational interface to access LEWAS Lab's research knowledge and real-time environmental data. This interactive assistant serves as the user-facing component of our AI-powered system, enabling researchers, students, and the public to explore a decade of watershed research and current sensor data through natural language queries.
π Related Projects: This frontend connects to the LEWAS Chatbot Backend for AI processing and accesses live data from the LEWAS Backend. Users can also explore data visually using the LEWAS Frontend Dashboard.
- Natural Language Processing: Ask questions in plain English
- Context-Aware Responses: Maintains conversation context
- Multi-Modal Responses: Text, data tables, and visualizations
- Real-Time Interaction: Instant responses from backend AI
- π Research Knowledge (RAG): Access LEWAS Lab's research papers and documentation
- π Live Environmental Data: Get current sensor readings and recent trends
- π Data Visualizations: Generate charts and graphs on demand
The chatbot automatically determines what you're asking for:
- "What's the current water temperature?" β Live sensor data
- "Show me pH trends" β Data visualization
- "Tell me about LEWAS research" β Knowledge base search
- "How does stormwater affect measurements?" β Research documentation
- 16 Environmental Parameters across water quality, flow, and weather
- Real-Time Sensor Readings from Webb Branch watershed
- Historical Data Access for trend analysis
- Research-Grade Processing with same algorithms used in publications
π Access the Chatbot: https://lewaschatbot.streamlit.app/
- Clone the repository
git clone https://github.com/lewas-lab/chatbot-frontend
cd chatbot-frontend
- Install dependencies
pip install -r requirements.txt
- Configure environment
# Copy ./streamlit/secrets_example.toml
# Rename it to secrets.toml
cp ./.streamlit/secrets_example.toml ./.streamlit/secrets.toml
# Fill in all the values
-
Create a Virtual Environment for Python, using the requirements.txt file
-
Run the application
streamlit run src/main.py
- Access the interface Open your browser to http://localhost:8501
- Message Input: Type your questions in the chat box
- Send Button: Submit queries with Enter or click
- Response Display: Formatted responses with sources
- View Details: Expandable sections for technical details
- Feedback System: Thumbs up/down for response quality
- About LEWAS Lab: Information about the research facility
- Example Questions: Sample queries to get started
- Contact Information: Support and development contacts
- Text Answers: Comprehensive explanations and information
- Live Data: Current sensor readings with timestamps
- Visualizations: Embedded charts and graphs
- Source Citations: Links to original research documents
Ask about any of these water quality measurements:
Parameter | Description | Example Query |
---|---|---|
ph |
Water acidity/alkalinity | "What's the current pH?" |
dissolved_oxygen |
Oxygen content in water | "How much oxygen is in the water?" |
water_temperature |
Water thermal conditions | "What's the water temperature?" |
turbidity |
Water clarity measurement | "How cloudy is the water?" |
specific_conductance |
Electrical conductivity | "What's the conductivity reading?" |
salinity |
Salt content measurement | "How salty is the water?" |
orp |
Oxidation reduction potential | "What's the ORP level?" |
Explore water movement and dynamics:
Parameter | Description | Example Query |
---|---|---|
stage |
Water level/height | "How high is the water?" |
flow_rate |
Volumetric flow estimation | "What's the flow rate?" |
smoothed_velocity |
Processed water speed | "What's the water velocity?" |
downstream_velocity |
Raw velocity measurement | "Current water speed?" |
Check atmospheric conditions:
Parameter | Description | Example Query |
---|---|---|
air_temperature |
Atmospheric temperature | "How hot is it outside?" |
humidity |
Relative humidity | "What's the humidity level?" |
air_pressure |
Barometric pressure | "What's the air pressure?" |
rain_intensity |
Current precipitation rate | "Is it raining hard?" |
rain_accumulation |
Total rainfall amount | "How much rain has fallen?" |
rain_duration |
Precipitation event length | "How long has it been raining?" |
You: "What research does LEWAS Lab conduct?"
π€ Chatbot:
You: "What's the current water temperature?"
π€ Chatbot:
You: "Show me a graph of pH trends"
π€ Chatbot:
- "Describe the acute chloride toxicity event at LEWAS"
- "How does stormwater affect LEWAS measurements?"
- "What sensors are deployed at the monitoring site?"
- "Explain the data flow between LEWAS components"
- "What publications has LEWAS Lab produced?"
- "What is the current air temperature?"
- "Latest humidity reading?"
- "How much dissolved oxygen right now?"
- "Current water level?"
- "Show me recent temperature readings"
- "pH measurements from today"
- "Last few hours of pressure data"
- "Recent flow rate changes"
- "Create a graph of temperature trends"
- "Show me humidity data visualization"
- "Generate a plot of air pressure over time"
- "Chart the dissolved oxygen levels"
- "Visualize rainfall patterns"
- "How does the monitoring system work?"
- "What's the sampling frequency of sensors?"
- "Explain the data processing pipeline"
- "What quality control measures are used?"
# .streamlit/config.toml
- Touch-Friendly: Large buttons and input areas
- Responsive Layout: Adapts to different screen sizes
- Optimized Images: Compressed visualizations for faster loading
- Simplified Navigation: Streamlined mobile interface
- Keyboard Navigation: Full keyboard support
- High Contrast: Accessible color combinations
- Clear Typography: Readable fonts and sizing
-
Connect GitHub Repository
- Link your GitHub account to Streamlit Cloud
- Select the repository containing your app
-
Configure Deployment
# .streamlit/config.toml [server] enableCORS = false enableXsrfProtection = false [theme] base="dark"
-
Set Secrets
# Copy ./streamlit/secrets_example.toml # Rename it to secrets.toml cp ./.streamlit/secrets_example.toml ./.streamlit/secrets.toml # Fill in all the values
-
Deploy Application
- Automatic deployment on git push
- Real-time logs and monitoring
rag-chatbot-frontend/
βββ src/
β βββ Home.py # Main application entry
β βββ main.py # Core chatbot logic
β βββ chatbot.css # Custom styling
β βββ images/ # Static assets
βββ lewas_logo.png
β βββ pages/ # Additional pages
β βββ chat.py # Chat interface
βββ .streamlit/
β βββ config.toml # Streamlit configuration
β βββ secrets.toml # API keys and secrets
βββ requirements.txt # Python dependencies
βββ README.md # This file
- New Response Types
def handle_new_response_type(response_data):
"""Handle custom response formats"""
if response_data.get("type") == "custom":
# Custom display logic
st.custom_component(response_data["content"])
- User Authentication (Optional)
The implementation is already implemented, just uncomment the code. Enable Cognito on AWS, and add the credentials to the project
- No Personal Data Storage: Only query history for improvement
- Secure API Communication: HTTPS encryption
- Key Management: Secure storage of API credentials
- Privacy Compliance: Research data usage only
- Interactive Demonstrations: Live data for class discussions
- Student Research: Independent exploration of environmental data
- Assignment Support: Access to research materials and current data
- Cross-Disciplinary Learning: Supports multiple engineering and science courses
- Literature Review: Quick access to relevant LEWAS papers
- Data Validation: Compare current readings with historical patterns
- Hypothesis Generation: Explore environmental relationships
- Methodology Reference: Find established research procedures
- In-App Feedback: Use thumbs up/down buttons
- Feature Requests: Submit GitHub issues
- Bug Reports: Contact development team
- Educational Use Cases: Share classroom applications
- Fork the repository
- Create feature branch
- Implement improvements
- Test thoroughly
- Submit pull request
- Technical Issues: [email protected]
- LinkedIn: linkedin.com/in/dhruvvarshneyvk
- Educational Use: Contact Dr. Vinod Lohani ([email protected])
- User Guide: Available in sidebar of application. Available here as well: View here
- Slow Responses: Check internet connection and backend status
- No Data Available: Some parameters may have temporary outages
- Visualization Errors: Refresh page and try again
- Connection Errors: Verify backend API is accessible
- Multi-Language Support: Spanish and other languages for broader access
- Voice Interface: Speech-to-text for hands-free interaction
- Advanced Analytics: Correlation analysis and trend prediction
- Custom Dashboards: User-created monitoring displays
- Collaborative Features: Share queries and results with others
Dhruv Varshney | LEWAS Chatbot | Virginia Tech | Making Environmental Data Accessible Through Conversation
Ask anything about LEWAS research, get live environmental data, and explore watershed science through natural language interaction.