yash108coolboy commited on
Commit
e37b04e
·
verified ·
1 Parent(s): 4690b3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -25
app.py CHANGED
@@ -1,25 +1,25 @@
1
- import streamlit as st
2
-
3
- # Set the title of the web app
4
- st.title("Text and Token Input App")
5
-
6
- # Input for the user's prompt
7
- prompt = st.text_area("Enter a prompt above 15 words:")
8
-
9
- # Input for the number of tokens to be generated
10
- num_tokens = st.number_input("Enter the number of tokens to be generated:", min_value=1, step=1)
11
-
12
- # Function to calculate the length of the string and the sum of the length and number of tokens
13
- def calculate_length_and_sum(prompt, num_tokens):
14
- prompt_length = len(prompt.split())
15
- total_sum = prompt_length + num_tokens
16
- return prompt_length, total_sum
17
-
18
- # Button to perform the calculation
19
- if st.button("Calculate"):
20
- if len(prompt.split()) < 15:
21
- st.warning("Please enter a prompt with more than 15 words.")
22
- else:
23
- prompt_length, total_sum = calculate_length_and_sum(prompt, num_tokens)
24
- st.write(f"Length of the prompt: {prompt_length}")
25
- st.write(f"Sum of the length of the prompt and the number of tokens: {total_sum}")
 
1
+ import streamlit as st
2
+
3
+ # Set the title of the web app
4
+ st.title("Text and Token Input App")
5
+
6
+ # Input for the user's prompt
7
+ prompt = st.text_area("Enter a prompt above 15 words:")
8
+
9
+ # Input for the number of tokens to be generated
10
+ num_tokens = st.number_input("Enter the number of tokens to be generated:", min_value=1, step=1)
11
+
12
+ # Function to calculate the length of the string and the sum of the length and number of tokens
13
+ def calculate_length_and_sum(prompt, num_tokens):
14
+ prompt_length = len(prompt.split())
15
+ total_sum = prompt_length + num_tokens
16
+ return prompt_length, total_sum
17
+
18
+ # Button to perform the calculation
19
+ if st.button("Calculate"):
20
+ if len(prompt.split()) < 15:
21
+ st.warning("Please enter a prompt with more than 15 words.")
22
+ else:
23
+ prompt_length, total_sum = calculate_length_and_sum(prompt, num_tokens)
24
+ st.write(f"Length of the prompt: {prompt_length}")
25
+ st.write(f"Sum of the length of the prompt and the number of tokens: {total_sum}")