100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.
changes
Madhu396d95ad8b21
diff --git a/ai_agent_tutorials/ai_aqi_analysis_agent/ai_aqi_analysis_agent.py b/ai_agent_tutorials/ai_aqi_analysis_agent/ai_aqi_analysis_agent.pyindex 80f539cc..d96d5cd4 100644--- a/ai_agent_tutorials/ai_aqi_analysis_agent/ai_aqi_analysis_agent.py+++ b/ai_agent_tutorials/ai_aqi_analysis_agent/ai_aqi_analysis_agent.py@@ -37,15 +37,12 @@ class AQIAnalyzer:def _format_url(self, country: str, state: str, city: str) -> str:"""Format URL based on location, handling cases with and without state"""- # Clean and format the componentscountry_clean = country.lower().replace(' ', '-')city_clean = city.lower().replace(' ', '-')- # If state is None or empty, use direct city URLif not state or state.lower() == 'none':return f"https://www.aqi.in/dashboard/{country_clean}/{city_clean}"- # Regular case with state includedstate_clean = state.lower().replace(' ', '-')return f"https://www.aqi.in/dashboard/{country_clean}/{state_clean}/{city_clean}"@@ -63,20 +60,17 @@ class AQIAnalyzer:})- # Parse Firecrawl responseaqi_response = AQIResponse(**response)if not aqi_response.success:raise ValueError(f"Failed to fetch AQI data: {aqi_response.status}")- # Display raw data in expander with timestamp- with st.expander("π Raw AQI Data", expanded=True):+ with st.expander("π¦ Raw AQI Data", expanded=True):st.json({"url_accessed": url,"timestamp": aqi_response.expiresAt,"data": aqi_response.data})- # Add warning if data seems stale or inconsistentst.warning("""β οΈ Note: The data shown may not match real-time values on the website.This could be due to:@@ -137,12 +131,11 @@ class HealthRecommendationAgent:User's Context:- Medical Conditions: {user_input.medical_conditions or 'None'}- Planned Activity: {user_input.planned_activity}-- Provide detailed health recommendations considering:- 1. Current air quality impacts on health- 2. Safety precautions needed for the planned activity of User based on the air quality conditions- 3. Whether the planned activity is advisable or not, if its not advisable then provide alternative activity suggestions- 4. Best time to conduct the activity if applicable+ **Comprehensive Health Recommendations:**+ 1. **Impact of Current Air Quality on Health:**+ 2. **Necessary Safety Precautions for Planned Activity:**+ 3. **Advisability of Planned Activity:**+ 4. **Best Time to Conduct the Activity:**"""def analyze_conditions(@@ -169,12 +162,12 @@ def initialize_session_state():def setup_page():st.set_page_config(- page_title="AQI Analysis Assistant",+ page_title="AQI Analysis Agent",page_icon="π",layout="wide")- st.title("π AQI Analysis Assistant")+ st.title("π AQI Analysis Agent")st.info("Get personalized health recommendations based on air quality conditions.")def render_sidebar():@@ -195,7 +188,6 @@ def render_sidebar():help="Enter your OpenAI API key")- # Update session state only if both keys are providedif (new_firecrawl_key and new_openai_key and(new_firecrawl_key != st.session_state.api_keys['firecrawl'] ornew_openai_key != st.session_state.api_keys['openai'])):@@ -259,10 +251,9 @@ def main():except Exception as e:st.error(f"β Error: {str(e)}")- # Display recommendations if availableif result:- st.markdown("### π Recommendations")- st.info(result)+ st.markdown("### π¦ Recommendations")+ st.markdown(result)st.download_button("πΎ Download Recommendations",