Implement Cosmic Cascade Response Mode without NASA API integration
Browse files- app.py +1 -28
- core/coordinator.py +1 -2
- core/personality.py +20 -32
app.py
CHANGED
|
@@ -14,7 +14,6 @@ from core.memory import check_redis_health
|
|
| 14 |
from core.coordinator import coordinator
|
| 15 |
from core.errors import translate_error
|
| 16 |
from core.personality import personality
|
| 17 |
-
from services.nasa_api import nasa_service
|
| 18 |
from services.hf_endpoint_monitor import hf_monitor
|
| 19 |
import logging
|
| 20 |
|
|
@@ -38,14 +37,6 @@ if "cosmic_mode" not in st.session_state:
|
|
| 38 |
if "show_welcome" not in st.session_state:
|
| 39 |
st.session_state.show_welcome = True
|
| 40 |
|
| 41 |
-
# Fetch NASA data once per session
|
| 42 |
-
if "nasa_data" not in st.session_state:
|
| 43 |
-
st.session_state.nasa_data = {
|
| 44 |
-
"apod": nasa_service.get_apod() if config.nasa_api_key else None,
|
| 45 |
-
"space_weather": nasa_service.get_space_weather_alerts() if config.nasa_api_key else None,
|
| 46 |
-
"mars_weather": nasa_service.get_mars_weather() if config.nasa_api_key else None
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
# Sidebar layout redesign
|
| 50 |
with st.sidebar:
|
| 51 |
st.title("π± CosmicCat AI Assistant")
|
|
@@ -142,17 +133,6 @@ with st.sidebar:
|
|
| 142 |
|
| 143 |
st.divider()
|
| 144 |
|
| 145 |
-
# NASA Context Display
|
| 146 |
-
if st.session_state.nasa_data.get("apod"):
|
| 147 |
-
apod = st.session_state.nasa_data["apod"]
|
| 148 |
-
st.subheader("π Cosmic Context")
|
| 149 |
-
if apod.get("media_type") == "image" and apod.get("url"):
|
| 150 |
-
st.image(apod["url"], caption=apod.get("title", "Astronomy Picture of the Day"), width=200)
|
| 151 |
-
st.markdown(f"{apod.get('title', 'Cosmic Phenomenon')}")
|
| 152 |
-
st.caption(apod.get("explanation", "")[:100] + "..." if len(apod.get("explanation", "")) > 100 else apod.get("explanation", ""))
|
| 153 |
-
|
| 154 |
-
st.divider()
|
| 155 |
-
|
| 156 |
st.subheader("π Debug Info")
|
| 157 |
# Show current configuration
|
| 158 |
st.markdown(f"Environment: {'HF Space' if config.is_hf_space else 'Local'}")
|
|
@@ -167,8 +147,6 @@ with st.sidebar:
|
|
| 167 |
features.append("Web Search")
|
| 168 |
if config.openweather_api_key:
|
| 169 |
features.append("Weather")
|
| 170 |
-
if config.nasa_api_key:
|
| 171 |
-
features.append("Space Data")
|
| 172 |
st.markdown(f"Active Features: {', '.join(features) if features else 'None'}")
|
| 173 |
|
| 174 |
# Main interface
|
|
@@ -178,10 +156,7 @@ st.markdown("Ask me anything about personal development, goal setting, or life a
|
|
| 178 |
# Show welcome message only once
|
| 179 |
if st.session_state.show_welcome:
|
| 180 |
with st.chat_message("assistant"):
|
| 181 |
-
greeting = personality.get_greeting()
|
| 182 |
-
nasa_context = personality.get_nasa_context(st.session_state.nasa_data)
|
| 183 |
-
if nasa_context:
|
| 184 |
-
greeting += f"\n\nπ {nasa_context}"
|
| 185 |
st.markdown(greeting)
|
| 186 |
st.session_state.show_welcome = False
|
| 187 |
|
|
@@ -574,8 +549,6 @@ with tab2:
|
|
| 574 |
features.append("Web Search")
|
| 575 |
if config.openweather_api_key:
|
| 576 |
features.append("Weather Data")
|
| 577 |
-
if config.nasa_api_key:
|
| 578 |
-
features.append("Space Data")
|
| 579 |
st.markdown(f"**Active Features:** {', '.join(features) if features else 'None'}")
|
| 580 |
|
| 581 |
# Conversation Analytics
|
|
|
|
| 14 |
from core.coordinator import coordinator
|
| 15 |
from core.errors import translate_error
|
| 16 |
from core.personality import personality
|
|
|
|
| 17 |
from services.hf_endpoint_monitor import hf_monitor
|
| 18 |
import logging
|
| 19 |
|
|
|
|
| 37 |
if "show_welcome" not in st.session_state:
|
| 38 |
st.session_state.show_welcome = True
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# Sidebar layout redesign
|
| 41 |
with st.sidebar:
|
| 42 |
st.title("π± CosmicCat AI Assistant")
|
|
|
|
| 133 |
|
| 134 |
st.divider()
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
st.subheader("π Debug Info")
|
| 137 |
# Show current configuration
|
| 138 |
st.markdown(f"Environment: {'HF Space' if config.is_hf_space else 'Local'}")
|
|
|
|
| 147 |
features.append("Web Search")
|
| 148 |
if config.openweather_api_key:
|
| 149 |
features.append("Weather")
|
|
|
|
|
|
|
| 150 |
st.markdown(f"Active Features: {', '.join(features) if features else 'None'}")
|
| 151 |
|
| 152 |
# Main interface
|
|
|
|
| 156 |
# Show welcome message only once
|
| 157 |
if st.session_state.show_welcome:
|
| 158 |
with st.chat_message("assistant"):
|
| 159 |
+
greeting = personality.get_greeting(cosmic_mode=st.session_state.cosmic_mode)
|
|
|
|
|
|
|
|
|
|
| 160 |
st.markdown(greeting)
|
| 161 |
st.session_state.show_welcome = False
|
| 162 |
|
|
|
|
| 549 |
features.append("Web Search")
|
| 550 |
if config.openweather_api_key:
|
| 551 |
features.append("Weather Data")
|
|
|
|
|
|
|
| 552 |
st.markdown(f"**Active Features:** {', '.join(features) if features else 'None'}")
|
| 553 |
|
| 554 |
# Conversation Analytics
|
core/coordinator.py
CHANGED
|
@@ -678,8 +678,7 @@ Stream your response for real-time delivery."""
|
|
| 678 |
'web_search_enabled': self.tavily_client is not None,
|
| 679 |
'external_apis_configured': any([
|
| 680 |
weather_service.api_key,
|
| 681 |
-
os.getenv("TAVILY_API_KEY")
|
| 682 |
-
os.getenv("NASA_API_KEY")
|
| 683 |
])
|
| 684 |
}
|
| 685 |
|
|
|
|
| 678 |
'web_search_enabled': self.tavily_client is not None,
|
| 679 |
'external_apis_configured': any([
|
| 680 |
weather_service.api_key,
|
| 681 |
+
os.getenv("TAVILY_API_KEY")
|
|
|
|
| 682 |
])
|
| 683 |
}
|
| 684 |
|
core/personality.py
CHANGED
|
@@ -14,6 +14,14 @@ class CosmicCatPersonality:
|
|
| 14 |
"Telepathic meow! I sense you're seeking cosmic guidance! π "
|
| 15 |
]
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
self.space_stories = [
|
| 18 |
"In the depths of Andromeda, a cybernetic cat discovered the secret of quantum purring, bending reality with each harmonic vibration.",
|
| 19 |
"A space-faring kitten once navigated through a black hole and emerged in a parallel dimension where all cats rule supreme.",
|
|
@@ -32,21 +40,25 @@ class CosmicCatPersonality:
|
|
| 32 |
"Powering up my neural net... π«"
|
| 33 |
]
|
| 34 |
|
| 35 |
-
def get_greeting(self) -> str:
|
| 36 |
-
"""Get a personalized
|
| 37 |
hour = datetime.now().hour
|
| 38 |
|
| 39 |
if 5 <= hour < 12:
|
| 40 |
-
time_greeting = "Good morning
|
| 41 |
elif 12 <= hour < 17:
|
| 42 |
-
time_greeting = "Good afternoon
|
| 43 |
elif 17 <= hour < 21:
|
| 44 |
-
time_greeting = "Good evening
|
| 45 |
else:
|
| 46 |
-
time_greeting = "
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
def get_space_story(self) -> str:
|
| 52 |
"""Get a random space cat story"""
|
|
@@ -55,30 +67,6 @@ class CosmicCatPersonality:
|
|
| 55 |
def get_initializing_message(self) -> str:
|
| 56 |
"""Get a random initialization message"""
|
| 57 |
return random.choice(self.initializing_messages)
|
| 58 |
-
|
| 59 |
-
def get_nasa_context(self, nasa_data: Optional[Dict]) -> str:
|
| 60 |
-
"""Create context based on NASA data"""
|
| 61 |
-
if not nasa_data:
|
| 62 |
-
return ""
|
| 63 |
-
|
| 64 |
-
context_parts = []
|
| 65 |
-
|
| 66 |
-
# Add APOD context
|
| 67 |
-
if 'apod' in nasa_data and nasa_data['apod']:
|
| 68 |
-
apod = nasa_data['apod']
|
| 69 |
-
context_parts.append(f"π Today's cosmic view: {apod.get('title', 'Unknown phenomenon')}")
|
| 70 |
-
|
| 71 |
-
# Add space weather context
|
| 72 |
-
if 'space_weather' in nasa_data and nasa_data['space_weather']:
|
| 73 |
-
weather = nasa_data['space_weather']
|
| 74 |
-
context_parts.append("π°οΈ Space weather is stable for cosmic communications")
|
| 75 |
-
|
| 76 |
-
# Add Mars weather if available
|
| 77 |
-
if 'mars_weather' in nasa_data and nasa_data['mars_weather']:
|
| 78 |
-
mars = nasa_data['mars_weather']
|
| 79 |
-
context_parts.append("πͺ Martian conditions are optimal for interplanetary contemplation")
|
| 80 |
-
|
| 81 |
-
return " | ".join(context_parts) if context_parts else ""
|
| 82 |
|
| 83 |
# Global instance
|
| 84 |
personality = CosmicCatPersonality()
|
|
|
|
| 14 |
"Telepathic meow! I sense you're seeking cosmic guidance! π "
|
| 15 |
]
|
| 16 |
|
| 17 |
+
self.standard_greetings = [
|
| 18 |
+
"Hello! I'm your AI Life Coach. How can I assist you today?",
|
| 19 |
+
"Welcome! I'm here to help with your personal development journey.",
|
| 20 |
+
"Hi there! What would you like to focus on today?",
|
| 21 |
+
"Greetings! Let's work together to achieve your goals.",
|
| 22 |
+
"Good to see you! How can I support your growth today?"
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
self.space_stories = [
|
| 26 |
"In the depths of Andromeda, a cybernetic cat discovered the secret of quantum purring, bending reality with each harmonic vibration.",
|
| 27 |
"A space-faring kitten once navigated through a black hole and emerged in a parallel dimension where all cats rule supreme.",
|
|
|
|
| 40 |
"Powering up my neural net... π«"
|
| 41 |
]
|
| 42 |
|
| 43 |
+
def get_greeting(self, cosmic_mode: bool = True) -> str:
|
| 44 |
+
"""Get a personalized greeting based on mode"""
|
| 45 |
hour = datetime.now().hour
|
| 46 |
|
| 47 |
if 5 <= hour < 12:
|
| 48 |
+
time_greeting = "Good morning"
|
| 49 |
elif 12 <= hour < 17:
|
| 50 |
+
time_greeting = "Good afternoon"
|
| 51 |
elif 17 <= hour < 21:
|
| 52 |
+
time_greeting = "Good evening"
|
| 53 |
else:
|
| 54 |
+
time_greeting = "Hello"
|
| 55 |
|
| 56 |
+
if cosmic_mode:
|
| 57 |
+
space_greeting = random.choice(self.space_greetings)
|
| 58 |
+
return f"{time_greeting}, space traveler! π±β¨\n\n{space_greeting}"
|
| 59 |
+
else:
|
| 60 |
+
standard_greeting = random.choice(self.standard_greetings)
|
| 61 |
+
return f"{time_greeting}! π\n\n{standard_greeting}"
|
| 62 |
|
| 63 |
def get_space_story(self) -> str:
|
| 64 |
"""Get a random space cat story"""
|
|
|
|
| 67 |
def get_initializing_message(self) -> str:
|
| 68 |
"""Get a random initialization message"""
|
| 69 |
return random.choice(self.initializing_messages)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
# Global instance
|
| 72 |
personality = CosmicCatPersonality()
|