cb1716pics commited on
Commit
1a1332a
·
verified ·
1 Parent(s): ca5aacd

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -4,6 +4,7 @@ from retrieval import retrieve_documents_hybrid,find_query_dataset
4
  from evaluation import calculate_metrics
5
  from data_processing import load_recent_questions, save_recent_question
6
  import time
 
7
 
8
  # Page Title
9
  st.title("RAG7 - Real World RAG System")
@@ -63,13 +64,11 @@ if "time_taken_for_response" not in st.session_state:
63
  st.session_state.time_taken_for_response = "N/A"
64
  if "metrics" not in st.session_state:
65
  st.session_state.metrics = {}
66
- if "metrics" not in st.session_state:
67
- st.session_state.metrics = {}
68
 
69
  recent_questions = load_recent_questions()
70
 
71
- import matplotlib.pyplot as plt
72
-
73
  # for visualization
74
 
75
 
@@ -81,25 +80,31 @@ import matplotlib.pyplot as plt
81
  # ax.set_ylabel("Time Taken for Response")
82
  # ax.legend()
83
  # st.sidebar.pyplot(fig)
84
- if recent_questions:
85
  st.sidebar.title("Analytics")
 
 
86
  response_time = [q["response_time"] for q in recent_questions["questions"]]
87
- labels = [f"Q{i+1}" for i in range(len(response_time))] # Labels for X-axis
88
 
 
89
  fig, ax = plt.subplots()
90
- ax.plot(labels, response_time, color="skyblue")
91
  ax.set_xlabel("Recent Questions")
92
  ax.set_ylabel("Time Taken for Response (seconds)")
93
  ax.set_title("Response Time Analysis")
94
 
95
- st.sidebar.markdown("---")
 
96
 
 
 
 
97
  st.sidebar.title("Recent Questions")
98
  for q in reversed(recent_questions["questions"]): # Show latest first
99
  st.sidebar.write(f"🔹 {q['question']}")
100
  else:
101
- st.sidebar.write(f"No Recent questions")
102
-
103
  # Separator
104
 
105
  # Streamlit Sidebar for Recent Questions
 
4
  from evaluation import calculate_metrics
5
  from data_processing import load_recent_questions, save_recent_question
6
  import time
7
+ import matplotlib.pyplot as plt
8
 
9
  # Page Title
10
  st.title("RAG7 - Real World RAG System")
 
64
  st.session_state.time_taken_for_response = "N/A"
65
  if "metrics" not in st.session_state:
66
  st.session_state.metrics = {}
67
+ if "query_dataset" not in st.session_state:
68
+ st.session_state.query_dataset = ''
69
 
70
  recent_questions = load_recent_questions()
71
 
 
 
72
  # for visualization
73
 
74
 
 
80
  # ax.set_ylabel("Time Taken for Response")
81
  # ax.legend()
82
  # st.sidebar.pyplot(fig)
83
+ if recent_questions and "questions" in recent_questions and recent_questions["questions"]:
84
  st.sidebar.title("Analytics")
85
+
86
+ # Extract response times and labels
87
  response_time = [q["response_time"] for q in recent_questions["questions"]]
88
+ labels = [f"Q{i+1}" for i in range(len(response_time))]
89
 
90
+ # Plot graph
91
  fig, ax = plt.subplots()
92
+ ax.plot(labels, response_time, marker="o", linestyle="-", color="skyblue")
93
  ax.set_xlabel("Recent Questions")
94
  ax.set_ylabel("Time Taken for Response (seconds)")
95
  ax.set_title("Response Time Analysis")
96
 
97
+ # Display the plot in the sidebar
98
+ st.sidebar.pyplot(fig)
99
 
100
+ st.sidebar.markdown("---")
101
+
102
+ # Display Recent Questions
103
  st.sidebar.title("Recent Questions")
104
  for q in reversed(recent_questions["questions"]): # Show latest first
105
  st.sidebar.write(f"🔹 {q['question']}")
106
  else:
107
+ st.sidebar.write("No recent questions")
 
108
  # Separator
109
 
110
  # Streamlit Sidebar for Recent Questions