File size: 1,402 Bytes
826e275 7a75a15 826e275 7a75a15 7b34e37 826e275 e0bb50d 826e275 b598d9f 826e275 7a75a15 826e275 b1dd47e 826e275 b1dd47e 826e275 b1dd47e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
"""
The Streamlit app for the project demo.
In the demo, the user can write a prompt
and the model will generate a response using the grouped sampling algorithm.
"""
import streamlit as st
from hanlde_form_submit import on_form_submit
from on_server_start import main as on_server_start_main
on_server_start_main()
st.title("Grouped Sampling Demo")
with st.form("request_form"):
selected_model_name: str = st.text_input(
label="Model name",
value="gpt2",
help=f"The name of the model to use."
)
output_length: int = st.number_input(
label="Output Length in tokens",
min_value=1,
max_value=4096,
value=100,
help="The length of the output text in tokens (word pieces)."
)
submitted_prompt: str = st.text_area(
label="Input for the model, It is highly recommended to write an English prompt.",
help="Enter the prompt for the model. The model will generate a response based on this prompt.",
max_chars=16384,
)
submitted: bool = st.form_submit_button(
label="Generate",
help="Generate the output text.",
disabled=False,
)
if submitted:
try:
output = on_form_submit(selected_model_name, output_length, submitted_prompt)
st.write(f"Generated text: {output}")
except ValueError as e:
st.error(e)
|