Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import io, os
|
3 |
import subprocess
|
4 |
import pdfplumber
|
@@ -19,8 +20,8 @@ import google.generativeai as genai
|
|
19 |
from typing import List
|
20 |
from langchain_core.language_models import BaseLanguageModel
|
21 |
from langchain_core.runnables import Runnable
|
22 |
-
|
23 |
import google.generativeai as genai
|
|
|
24 |
|
25 |
|
26 |
class GeminiLLM(Runnable):
|
@@ -259,17 +260,42 @@ def main():
|
|
259 |
st.session_state.chat_ready = True
|
260 |
st.success("MODTRAN User Manual loaded successfully!")
|
261 |
|
262 |
-
user_question = st.text_input("Ask your question:")
|
263 |
|
264 |
-
if st.
|
265 |
set_global_vectorstore(st.session_state.vectorstore)
|
266 |
response = handle_user_query(user_question)
|
267 |
st.session_state.chat_history.append({"user": user_question, "bot": response})
|
|
|
|
|
|
|
|
|
268 |
|
269 |
-
for chat in st.session_state.chat_history:
|
270 |
st.write(f"**You:** {chat['user']}")
|
271 |
st.write(f"**Bot:** {chat['bot']}")
|
272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
if __name__ == "__main__":
|
274 |
load_environment()
|
275 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
import io, os
|
4 |
import subprocess
|
5 |
import pdfplumber
|
|
|
20 |
from typing import List
|
21 |
from langchain_core.language_models import BaseLanguageModel
|
22 |
from langchain_core.runnables import Runnable
|
|
|
23 |
import google.generativeai as genai
|
24 |
+
from datetime import datetime
|
25 |
|
26 |
|
27 |
class GeminiLLM(Runnable):
|
|
|
260 |
st.session_state.chat_ready = True
|
261 |
st.success("MODTRAN User Manual loaded successfully!")
|
262 |
|
263 |
+
user_question = st.text_input("Ask your question:", key="user_input")
|
264 |
|
265 |
+
if st.button("Submit") and user_question:
|
266 |
set_global_vectorstore(st.session_state.vectorstore)
|
267 |
response = handle_user_query(user_question)
|
268 |
st.session_state.chat_history.append({"user": user_question, "bot": response})
|
269 |
+
|
270 |
+
|
271 |
+
if "feedback_log" not in st.session_state:
|
272 |
+
st.session_state.feedback_log = []
|
273 |
|
274 |
+
for i, chat in enumerate(st.session_state.chat_history):
|
275 |
st.write(f"**You:** {chat['user']}")
|
276 |
st.write(f"**Bot:** {chat['bot']}")
|
277 |
|
278 |
+
rating = st.radio(
|
279 |
+
"How would you rate this response?",
|
280 |
+
options=["1", "2", "3", "4", "5"],
|
281 |
+
key=f"rating_{i}",
|
282 |
+
horizontal=True
|
283 |
+
)
|
284 |
+
|
285 |
+
|
286 |
+
st.session_state.feedback_log.append({
|
287 |
+
"question": chat["user"],
|
288 |
+
"answer": chat["bot"],
|
289 |
+
"rating": rating
|
290 |
+
})
|
291 |
+
|
292 |
+
|
293 |
+
|
294 |
+
if st.session_state.feedback_log:
|
295 |
+
feedback_df = pd.DataFrame(st.session_state.feedback_log)
|
296 |
+
current_date = datetime.now().strftime("%Y%m%d_%H%M%S")
|
297 |
+
feedback_df.to_csv(f"feedback_{current_date}.csv", index=False)
|
298 |
+
|
299 |
if __name__ == "__main__":
|
300 |
load_environment()
|
301 |
main()
|