yash108coolboy commited on
Commit
c680a41
·
verified ·
1 Parent(s): 06dea14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
 
3
  # Set the title of the web app
4
  st.title("Text and Token Input App")
@@ -9,17 +10,26 @@ prompt = st.text_area("Enter a prompt above 15 words:")
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
+ from main import *
3
 
4
  # Set the title of the web app
5
  st.title("Text and Token Input App")
 
10
  # Input for the number of tokens to be generated
11
  num_tokens = st.number_input("Enter the number of tokens to be generated:", min_value=1, step=1)
12
 
13
+
14
+ # Function to generate output based on the prompt and number of tokens
15
+ def generate(prompt, num_tokens):
16
+ output = gen(prompt, num_tokens)
17
+ return output
18
+
19
 
20
  # Button to perform the calculation
21
+ if st.button("Generate Output"):
22
+ if len(prompt.split()) < 9:
23
  st.warning("Please enter a prompt with more than 15 words.")
24
  else:
25
+ output = generate(prompt, num_tokens)
26
+
27
+ # Display prompt length and sum of prompt length and number of tokens
28
+ prompt_length = len(prompt.split())
29
+ total_sum = prompt_length + num_tokens
30
+
31
+ # Display output in a box below or next to the input prompts
32
+
33
+
34
+ st.subheader("Generated Output")
35
+ st.write(output)