Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
return
|
|
|
|
| 17 |
|
| 18 |
# Button to perform the calculation
|
| 19 |
-
if st.button("
|
| 20 |
-
if len(prompt.split()) <
|
| 21 |
st.warning("Please enter a prompt with more than 15 words.")
|
| 22 |
else:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|