Welcome! Please login or sign up to begin your spiritual journey.
912 |1076 | Ask questions about life, dharma, and spirituality to receive guidance from the timeless wisdom of the Bhagavad Gita. Personalize your experience using the options above. 1077 |
1078 | """, unsafe_allow_html=True) 1079 | 1080 | left_empty_for_center, main_chat_col, sidebar_col = st.columns([1, 3, 1]) 1081 | 1082 | with main_chat_col: 1083 | if "submission_in_progress" not in st.session_state: 1084 | st.session_state.submission_in_progress = False 1085 | 1086 | if not st.session_state.submission_in_progress: 1087 | question = st.chat_input("Ask your question here...") 1088 | if question: 1089 | st.session_state.messages.append({"role": "user", "content": question}) 1090 | st.session_state.submission_in_progress = True 1091 | st.experimental_rerun() 1092 | else: 1093 | with st.spinner("🧘 Contemplating your question..."): 1094 | last_user_msg = st.session_state.messages[-1]["content"] 1095 | response = asyncio.run(st.session_state.bot.get_response( 1096 | last_user_msg, 1097 | st.session_state.selected_theme, 1098 | st.session_state.current_mood, 1099 | dominant_emotion() 1100 | )) 1101 | st.session_state.messages.append({ 1102 | "role": "assistant", 1103 | **response 1104 | }) 1105 | st.session_state.submission_in_progress = False 1106 | st.experimental_rerun() 1107 | 1108 | # Enhanced message display (now below the input) 1109 | for i, message in enumerate(st.session_state.messages): 1110 | 1111 | with st.chat_message(message["role"]): 1112 | if message["role"] == "user": 1113 | st.markdown(message["content"]) 1114 | else: 1115 | if message.get("verse_reference"): 1116 | st.markdown(f"**📖 {message['verse_reference']}**") 1117 | if message.get('sanskrit'): 1118 | st.markdown(f"*Sanskrit:* {message['sanskrit']}") 1119 | if message.get('translation'): 1120 | st.markdown(f"**Translation:** {message['translation']}") 1121 | if message.get('explanation'): 1122 | st.markdown("### 🧠 Understanding") 1123 | st.markdown(message["explanation"]) 1124 | if message.get('application'): 1125 | st.markdown("### 🌟 Modern Application") 1126 | st.markdown(message["application"]) 1127 | if message.get('keywords'): 1128 | st.markdown("**Key Concepts:** " + " • ".join([f"`{kw}`" for kw in message['keywords']])) 1129 | 1130 | if question := st.chat_input("Ask your question here..."): 1131 | st.session_state.messages.append({"role": "user", "content": question}) 1132 | show_preloader() 1133 | response = asyncio.run(st.session_state.bot.get_response( 1134 | question, 1135 | st.session_state.selected_theme, 1136 | st.session_state.current_mood 1137 | )) 1138 | st.session_state.messages.append({ 1139 | "role": "assistant", 1140 | **response 1141 | }) 1142 | st.rerun() 1143 | with col2: 1144 | render_enhanced_sidebar() 1145 | 1146 | 1147 | # Show context values that were passed to LLM 1148 | context_parts = [] 1149 | if message.get('theme'): 1150 | context_parts.append(f"🎯 {message['theme']}") 1151 | if message.get('mood'): 1152 | context_parts.append(f"🎭 {message['mood']}") 1153 | if message.get('emotional_state'): 1154 | context_parts.append(f"💭 {message['emotional_state']}") 1155 | 1156 | if context_parts: 1157 | st.markdown("**Response Context:** " + " • ".join(context_parts)) 1158 | 1159 | # Display confidence score for AI responses 1160 | if message.get('confidence_score') is not None: 1161 | confidence_score = message['confidence_score'] 1162 | 1163 | # Create confidence indicator 1164 | col1, col2, col3 = st.columns([1, 3, 1]) 1165 | with col2: 1166 | st.markdown("**🤖 AI Response Confidence:**") 1167 | 1168 | # Confidence bar 1169 | confidence_color = "green" if confidence_score >= 80 else "orange" if confidence_score >= 60 else "red" 1170 | st.progress(confidence_score / 100, text=f"{confidence_score:.1f}%") 1171 | 1172 | # Confidence level indicator 1173 | if confidence_score >= 80: 1174 | st.success(f"✅ High Confidence ({confidence_score:.1f}%)") 1175 | elif confidence_score >= 60: 1176 | st.warning(f"⚠️ Medium Confidence ({confidence_score:.1f}%)") 1177 | else: 1178 | st.error(f"❌ Low Confidence ({confidence_score:.1f}%)") 1179 | 1180 | # Confidence explanation tooltip 1181 | with st.expander("ℹ️ What does this confidence score mean?"): 1182 | st.markdown(f""" 1183 | **Response Quality Assessment:** 1184 | 1185 | This confidence score ({confidence_score:.1f}%) indicates how well the AI was able to: 1186 | - **Provide complete information** (verse reference, translation, explanation, application) 1187 | - **Match your context** (theme: {message.get('theme', 'N/A')}, mood: {message.get('mood', 'N/A')}) 1188 | - **Address your emotional state** ({message.get('emotional_state', 'N/A')}) 1189 | - **Offer detailed and relevant guidance** 1190 | 1191 | **Confidence Levels:** 1192 | - **80-100%**: Excellent response quality with comprehensive guidance 1193 | - **60-79%**: Good response with room for improvement 1194 | - **Below 60%**: Basic response, consider rephrasing your question 1195 | """) 1196 | 1197 | # NEW: Add Favorite button for assistant responses 1198 | unique_key = f"favorite_btn_{i}_{message.get('verse_reference', '').replace(' ', '_')}" 1199 | if st.button("⭐ Add to Favorites", key=unique_key): 1200 | verse_info = "" 1201 | if message.get("verse_reference"): 1202 | verse_info += message["verse_reference"] 1203 | if message.get("translation"): 1204 | if verse_info: 1205 | verse_info += " - " 1206 | verse_info += message["translation"] 1207 | 1208 | if verse_info and verse_info not in st.session_state.favorite_verses: 1209 | st.session_state.favorite_verses.append(verse_info) 1210 | st.success("Verse added to favorites!") 1211 | elif verse_info: 1212 | st.warning("This verse is already in your favorites!") 1213 | 1214 | # Add the download button after the chat messages 1215 | if st.session_state.messages: 1216 | chat_content = create_downloadable_content(st.session_state.messages) 1217 | st.download_button( 1218 | label="📥 Download Chat History", 1219 | data=chat_content, 1220 | file_name=f"WisdomWeaver_Chat_History_{datetime.now().strftime('%Y-%m-%d')}.txt", 1221 | mime="text/plain", 1222 | help="Download your entire chat conversation as a text file" 1223 | ) 1224 | 1225 | with sidebar_col: 1226 | render_enhanced_sidebar() 1227 | 1228 | 1229 | st.markdown("---") 1230 | with st.expander("💫 About Wisdom Weaver", expanded=True): 1231 | st.markdown(""" 1232 |1235 | “Let the light of ancient wisdom guide your modern journey.” 1236 |
1237 |
1262 | “You are not alone on this journey. May the wisdom of the Gita illuminate your path.”
1263 | 🙏
1264 |