Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
import pickle
|
| 4 |
from huggingface_hub import Repository
|
|
@@ -135,12 +136,25 @@ def main():
|
|
| 135 |
loading_message = st.empty()
|
| 136 |
loading_message.text('Bot is thinking...')
|
| 137 |
|
|
|
|
|
|
|
|
|
|
| 138 |
VectorStore = load_pdf(pdf_path)
|
| 139 |
chain = load_chatbot()
|
| 140 |
docs = VectorStore.similarity_search(query=query, k=3)
|
| 141 |
with get_openai_callback() as cb:
|
| 142 |
response = chain.run(input_documents=docs, question=query)
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
st.session_state['chat_history'].append(("Bot", response, "new"))
|
| 145 |
|
| 146 |
# Display new messages at the bottom
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import time
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import pickle
|
| 5 |
from huggingface_hub import Repository
|
|
|
|
| 136 |
loading_message = st.empty()
|
| 137 |
loading_message.text('Bot is thinking...')
|
| 138 |
|
| 139 |
+
# Start timing
|
| 140 |
+
start_time = time.time()
|
| 141 |
+
|
| 142 |
VectorStore = load_pdf(pdf_path)
|
| 143 |
chain = load_chatbot()
|
| 144 |
docs = VectorStore.similarity_search(query=query, k=3)
|
| 145 |
with get_openai_callback() as cb:
|
| 146 |
response = chain.run(input_documents=docs, question=query)
|
| 147 |
|
| 148 |
+
# Stop timing
|
| 149 |
+
end_time = time.time()
|
| 150 |
+
|
| 151 |
+
# Calculate duration
|
| 152 |
+
duration = end_time - start_time
|
| 153 |
+
|
| 154 |
+
# You can use Streamlit's text function to display the timing
|
| 155 |
+
st.text(f"Response time: {duration:.2f} seconds")
|
| 156 |
+
|
| 157 |
+
|
| 158 |
st.session_state['chat_history'].append(("Bot", response, "new"))
|
| 159 |
|
| 160 |
# Display new messages at the bottom
|