eaglelandsonce
commited on
Commit
•
1c97873
1
Parent(s):
2a7bc10
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,37 @@
|
|
|
|
1 |
import requests
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
import requests
|
3 |
|
4 |
+
# Streamlit interface setup
|
5 |
+
st.title('Video Summary Interface')
|
6 |
+
|
7 |
+
# Input for modifying the prompt
|
8 |
+
prompt = st.text_input("Enter your prompt:",
|
9 |
+
"list the top 4 job interview mistakes and how to improve")
|
10 |
+
|
11 |
+
# Slider to adjust the number in the prompt
|
12 |
+
number = st.slider("Select the number of top mistakes:", min_value=1, max_value=10, value=4)
|
13 |
+
|
14 |
+
# Update the prompt with the chosen number
|
15 |
+
updated_prompt = prompt.replace("4", str(number))
|
16 |
+
|
17 |
+
# Button to send the request
|
18 |
+
if st.button("Summarize Video"):
|
19 |
+
BASE_URL = "https://api.twelvelabs.io/v1.2"
|
20 |
+
api_key = "tlk_3CPMVGM0ZPTKNT2TKQ3Y62TA7ZY9"
|
21 |
+
data = {
|
22 |
+
"video_id": "6636cf7fd1cd5a287c957cf5",
|
23 |
+
"type": "summary",
|
24 |
+
"prompt": updated_prompt
|
25 |
+
}
|
26 |
+
|
27 |
+
# Send the request
|
28 |
+
response = requests.post(f"{BASE_URL}/summarize", json=data, headers={"x-api-key": api_key})
|
29 |
+
|
30 |
+
# Check if the response is successful
|
31 |
+
if response.status_code == 200:
|
32 |
+
st.text_area("Summary:", response.json()['summary'], height=300)
|
33 |
+
else:
|
34 |
+
st.error("Failed to fetch summary: " + response.text)
|
35 |
+
|
36 |
+
# Run this script using the following command:
|
37 |
+
# streamlit run your_script_name.py
|