Files changed (1) hide show
  1. app.py +21 -18
app.py CHANGED
@@ -117,7 +117,7 @@ if "conversational_chain" not in st.session_state:
117
  languages = [
118
  "English", "Hindi", "Bengali", "Telugu", "Marathi", "Tamil", "Urdu", "Gujarati", "Malayalam", "Kannada",
119
  "Punjabi", "Odia", "Maithili", "Sanskrit", "Santali", "Kashmiri", "Nepali", "Dogri", "Manipuri", "Bodo",
120
- "Sindhi", "Assamese", "Konkani", "Maithili", "Awadhi", "Rajasthani", "Haryanvi", "Bihari", "Chhattisgarhi", "Magahi"
121
  ]
122
 
123
  # Main interface
@@ -143,22 +143,6 @@ if "username" in st.session_state:
143
  with st.chat_message("assistant"):
144
  st.markdown(message["content"])
145
 
146
- # Keep the chat interface scrollable
147
- st.markdown(
148
- """
149
- <style>
150
- .streamlit-expanderHeader {
151
- display: none;
152
- }
153
- .chat-container {
154
- max-height: 400px;
155
- overflow-y: scroll;
156
- }
157
- </style>
158
- """,
159
- unsafe_allow_html=True
160
- )
161
-
162
  # User input section for typing
163
  user_query = None # Initialize user_query as None
164
 
@@ -187,6 +171,16 @@ if "username" in st.session_state:
187
  response = st.session_state.conversational_chain({"question": user_query})
188
  assistant_response = response["answer"]
189
 
 
 
 
 
 
 
 
 
 
 
190
  # Save assistant's response to chat history in memory
191
  st.session_state.chat_history.append({"role": "assistant", "content": assistant_response})
192
 
@@ -199,8 +193,17 @@ if "username" in st.session_state:
199
  translator = GoogleTranslator(source="en", target=selected_language.lower())
200
  translated_response = translator.translate(assistant_response)
201
 
 
 
 
 
 
 
 
 
 
202
  # Display translated response
203
  st.markdown(f"**Translated Answer ({selected_language}):** {translated_response}")
204
 
205
  # Clear the input field after the query is processed
206
- st.session_state.user_input = "" # Reset the input field for next use
 
117
  languages = [
118
  "English", "Hindi", "Bengali", "Telugu", "Marathi", "Tamil", "Urdu", "Gujarati", "Malayalam", "Kannada",
119
  "Punjabi", "Odia", "Maithili", "Sanskrit", "Santali", "Kashmiri", "Nepali", "Dogri", "Manipuri", "Bodo",
120
+ "Sindhi", "Assamese", "Konkani", "Awadhi", "Rajasthani", "Haryanvi", "Bihari", "Chhattisgarhi", "Magahi"
121
  ]
122
 
123
  # Main interface
 
143
  with st.chat_message("assistant"):
144
  st.markdown(message["content"])
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  # User input section for typing
147
  user_query = None # Initialize user_query as None
148
 
 
171
  response = st.session_state.conversational_chain({"question": user_query})
172
  assistant_response = response["answer"]
173
 
174
+ # Parse and format RAG pipeline output
175
+ detailed_response = response.get("detailed_answer", {})
176
+ book = detailed_response.get("book", "Unknown")
177
+ chapter = detailed_response.get("chapter_number", "N/A")
178
+ verse = detailed_response.get("verse_number", "N/A")
179
+ shloka = detailed_response.get("shloka", "Not available")
180
+ translation = detailed_response.get("translation", "Not available")
181
+ commentary = detailed_response.get("commentary", "Not available")
182
+ summary = detailed_response.get("summary", "Not available")
183
+
184
  # Save assistant's response to chat history in memory
185
  st.session_state.chat_history.append({"role": "assistant", "content": assistant_response})
186
 
 
193
  translator = GoogleTranslator(source="en", target=selected_language.lower())
194
  translated_response = translator.translate(assistant_response)
195
 
196
+ # Display detailed RAG response
197
+ st.markdown(f"**Book:** {book}")
198
+ st.markdown(f"**Chapter:** {chapter}")
199
+ st.markdown(f"**Verse:** {verse}")
200
+ st.markdown(f"**Shloka:** {shloka}")
201
+ st.markdown(f"**Translation:** {translation}")
202
+ st.markdown(f"**Commentary:** {commentary}")
203
+ st.markdown(f"**Summary:** {summary}")
204
+
205
  # Display translated response
206
  st.markdown(f"**Translated Answer ({selected_language}):** {translated_response}")
207
 
208
  # Clear the input field after the query is processed
209
+ st.session_state.user_input = ""