Skip to content

lewas-lab/chatbot-frontend

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LEWAS AI Chatbot Frontend - Interactive Environmental Data Assistant

Learning Enhanced Watershed Assessment System (LEWAS) Lab
Virginia Tech - Conversational Interface for Environmental Research

πŸ› οΈ Technologies Used

Streamlit Python

🌐 Live Demo

πŸ”— Access the Chatbot: https://lewaschatbot.streamlit.app/

πŸ€– Overview

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.

✨ Key Features

🧠 Intelligent Conversation Interface

  • 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

πŸ“š Three-Way Knowledge Access

  1. πŸ“– Research Knowledge (RAG): Access LEWAS Lab's research papers and documentation
  2. πŸ“Š Live Environmental Data: Get current sensor readings and recent trends
  3. πŸ“ˆ Data Visualizations: Generate charts and graphs on demand

🎯 Smart Query Understanding

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

🌊 Comprehensive Environmental Coverage

  • 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

πŸš€ Quick Start

Live Demo

🌐 Access the Chatbot: https://lewaschatbot.streamlit.app/

Local Development

  1. Clone the repository
git clone https://github.com/lewas-lab/chatbot-frontend
cd chatbot-frontend
  1. Install dependencies
pip install -r requirements.txt
  1. 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
  1. Create a Virtual Environment for Python, using the requirements.txt file

  2. Run the application

streamlit run src/main.py
  1. Access the interface Open your browser to http://localhost:8501

πŸŽ›οΈ User Interface

Main Chat Interface

  • 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

Sidebar Features

  • About LEWAS Lab: Information about the research facility
  • Example Questions: Sample queries to get started
  • Contact Information: Support and development contacts

Response Types

  • 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

πŸ“Š Environmental Parameters

πŸ§ͺ Water Quality Parameters

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?"

🌊 Water Flow Parameters

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?"

🌀️ Weather Parameters

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?"

πŸ’¬ Example Conversations

Getting Research Information

You: "What research does LEWAS Lab conduct?"

πŸ€– Chatbot:

Alt text

Getting Live Data

You: "What's the current water temperature?"

πŸ€– Chatbot:

Alt text

Getting Visualizations

You: "Show me a graph of pH trends"

πŸ€– Chatbot:

Alt text

🎯 Query Types and Examples

πŸ“š Research Knowledge Queries

  • "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?"

πŸ“Š Live Data Queries

Latest Readings (Single Values)

  • "What is the current air temperature?"
  • "Latest humidity reading?"
  • "How much dissolved oxygen right now?"
  • "Current water level?"

Recent Trends (Multiple Values)

  • "Show me recent temperature readings"
  • "pH measurements from today"
  • "Last few hours of pressure data"
  • "Recent flow rate changes"

πŸ“ˆ Visualization Queries

  • "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"

πŸ” Technical Queries

  • "How does the monitoring system work?"
  • "What's the sampling frequency of sensors?"
  • "Explain the data processing pipeline"
  • "What quality control measures are used?"

🎨 Interface Customization

Streamlit Configuration

# .streamlit/config.toml

πŸ“± Responsive Design

Mobile Optimization

  • 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

Accessibility Features

  • Keyboard Navigation: Full keyboard support
  • High Contrast: Accessible color combinations
  • Clear Typography: Readable fonts and sizing

πŸ”„ Deployment

Streamlit Cloud (Recommended)

  1. Connect GitHub Repository

    • Link your GitHub account to Streamlit Cloud
    • Select the repository containing your app
  2. Configure Deployment

    # .streamlit/config.toml
     [server]
     enableCORS = false
     enableXsrfProtection = false
    
     [theme]
     base="dark"
  3. 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
  4. Deploy Application

    • Automatic deployment on git push
    • Real-time logs and monitoring

πŸ§ͺ Development

Project Structure

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

Adding New Features

  1. 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"])
  1. User Authentication (Optional)

The implementation is already implemented, just uncomment the code. Enable Cognito on AWS, and add the credentials to the project

πŸ”’ Security and Privacy

Data Protection

  • 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

πŸŽ“ Educational Use

Classroom Integration

  • 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

Research Support

  • 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

🀝 Contributing

User Feedback

  • In-App Feedback: Use thumbs up/down buttons
  • Feature Requests: Submit GitHub issues
  • Bug Reports: Contact development team
  • Educational Use Cases: Share classroom applications

Development Contributions

  1. Fork the repository
  2. Create feature branch
  3. Implement improvements
  4. Test thoroughly
  5. Submit pull request

πŸ“ž Support

Getting Help

Common Issues

  • 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

πŸ“ˆ Future Enhancements

Planned Features

  • 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.

About

Streamlit based frontend for the LEWAS Lab chatbot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 92.8%
  • CSS 7.2%