startrz commited on
Commit
05a998f
·
verified ·
1 Parent(s): 019a702

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -2,6 +2,7 @@ import requests
2
  import tiktoken
3
  import streamlit as st
4
  import json
 
5
 
6
  # Define the API URL
7
  API_URL = "https://startrz-proagents.hf.space/api/v1/prediction/9ad2e52d-052f-44e5-b3a0-7fd432d86506"
@@ -29,9 +30,15 @@ if st.button("Submit"):
29
  # Payload for the API
30
  payload = {"question": question}
31
 
 
 
 
32
  # Query the API
33
  response_data = query(payload)
34
 
 
 
 
35
  # Calculate input tokens
36
  input_tokens = calculate_tokens(str(payload))
37
 
@@ -47,7 +54,8 @@ if st.button("Submit"):
47
  "respond": response_data,
48
  "input_tokens": len(input_tokens),
49
  "output_tokens": len(output_tokens),
50
- "total_tokens": total_tokens
 
51
  }
52
 
53
  # Display the data
 
2
  import tiktoken
3
  import streamlit as st
4
  import json
5
+ import time
6
 
7
  # Define the API URL
8
  API_URL = "https://startrz-proagents.hf.space/api/v1/prediction/9ad2e52d-052f-44e5-b3a0-7fd432d86506"
 
30
  # Payload for the API
31
  payload = {"question": question}
32
 
33
+ # Measure the response time
34
+ start_time = time.time() # Start the timer
35
+
36
  # Query the API
37
  response_data = query(payload)
38
 
39
+ # End the timer and calculate response time
40
+ response_time = time.time() - start_time
41
+
42
  # Calculate input tokens
43
  input_tokens = calculate_tokens(str(payload))
44
 
 
54
  "respond": response_data,
55
  "input_tokens": len(input_tokens),
56
  "output_tokens": len(output_tokens),
57
+ "total_tokens": total_tokens,
58
+ "response_time": response_time
59
  }
60
 
61
  # Display the data