Spaces:
Sleeping
Sleeping
| import os | |
| import streamlit as st | |
| import pandas as pd | |
| import faiss | |
| import numpy as np | |
| from groq import Groq | |
| from data_fetcher import fetch_nrel_data | |
| # Fetch data from NREL API | |
| data = get_hydrogen_data() | |
| if data is None: | |
| print("⚠️ Using backup dataset...") | |
| data = [ | |
| {"station": "Example Station 1", "location": "California", "status": "Open"}, | |
| {"station": "Example Station 2", "location": "Texas", "status": "Planned"} | |
| ] | |
| # Print the first station as a check | |
| print("🚀 Hydrogen Station Data Sample:", data[0] if data else "No data available.") | |
| # Import custom modules | |
| from data_fetcher import get_hydrogen_data | |
| from visuals import plot_hydrogen_capacity | |
| # ✅ Load environment variables (API Keys) | |
| NREL_API_KEY = os.getenv("NREL_API_KEY") | |
| GROQ_API_KEY = os.getenv("GROQ_API_KEY") | |
| # ✅ Ensure API keys are set | |
| if not NREL_API_KEY: | |
| st.error("❌ ERROR: NREL API Key is missing! Please set it in environment variables.") | |
| st.stop() | |
| if not GROQ_API_KEY: | |
| st.error("❌ ERROR: Groq API Key is missing! Please set it in environment variables.") | |
| st.stop() | |
| # ✅ Fetch real-time hydrogen data | |
| hydrogen_data = get_hydrogen_data() | |
| # ✅ Display UI | |
| st.set_page_config(page_title="HydroGen-AI", layout="wide") | |
| st.title("🔬 HydroGen-AI: Green Hydrogen Techno-Economic Analyzer") | |
| if hydrogen_data is not None: | |
| st.sidebar.subheader("📡 Real-time Hydrogen Data (NREL API)") | |
| st.sidebar.write(hydrogen_data.head(5)) | |
| else: | |
| st.sidebar.warning("⚠️ No hydrogen data available from NREL API.") | |