import streamlit as st from generator import generate_response_from_document from retrieval import retrieve_documents from evaluation import calculate_metrics #from data_processing import load_data_from_faiss import time # Page Title st.title("RAG7 - Real World RAG System") # @st.cache_data # def load_data(): # load_data_from_faiss() # data_status = load_data() time_taken_for_response = 'N/A' # Question Section st.subheader("Hi, What do you want to know today?") question = st.text_area("Enter your question:", placeholder="Type your question here...", height=100) # Submit Button if st.button("Submit"): start_time = time.time() retrieved_documents = retrieve_documents(question, 5) response = generate_response_from_document(question, retrieved_documents) end_time = time.time() time_taken_for_response = end_time-start_time else: response = "" # Response Section st.subheader("Response") st.text_area("Generated Response:", value=response, height=150, disabled=True) # Metrics Section st.subheader("Metrics") col1, col2 = st.columns([1, 3]) # Creating two columns for button and metrics display with col1: if st.button("Calculate Metrics"): metrics = calculate_metrics(question, response, retrieved_documents, time_taken_for_response) else: metrics = "" with col2: st.text_area("Metrics:", value=metrics, height=100, disabled=True)