Anne31415 commited on
Commit
5a28160
·
1 Parent(s): f6c931e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
  import streamlit_analytics
3
  from dotenv import load_dotenv
4
  import pickle
@@ -137,6 +138,10 @@ def main():
137
 
138
  loading_message = st.empty()
139
  loading_message.text('Bot is thinking...')
 
 
 
 
140
 
141
  # Use the VectorStore loaded at the start from the session state
142
  chain = load_chatbot()
@@ -144,6 +149,15 @@ def main():
144
  with get_openai_callback() as cb:
145
  response = chain.run(input_documents=docs, question=query)
146
 
 
 
 
 
 
 
 
 
 
147
  st.session_state['chat_history'].append(("Bot", response, "new"))
148
 
149
  # Display new messages at the bottom
 
1
  import streamlit as st
2
+ import time
3
  import streamlit_analytics
4
  from dotenv import load_dotenv
5
  import pickle
 
138
 
139
  loading_message = st.empty()
140
  loading_message.text('Bot is thinking...')
141
+
142
+
143
+ # Start timing
144
+ start_time = time.time()
145
 
146
  # Use the VectorStore loaded at the start from the session state
147
  chain = load_chatbot()
 
149
  with get_openai_callback() as cb:
150
  response = chain.run(input_documents=docs, question=query)
151
 
152
+ # Stop timing
153
+ end_time = time.time()
154
+
155
+ # Calculate duration
156
+ duration = end_time - start_time
157
+
158
+ # You can use Streamlit's text function to display the timing
159
+ st.text(f"Response time: {duration:.2f} seconds")
160
+
161
  st.session_state['chat_history'].append(("Bot", response, "new"))
162
 
163
  # Display new messages at the bottom