import requests import streamlit as st from utils_display import HEADER, SIDE_BAR_TEXT, write_incremental, i_am_feeling_lucky st.markdown(HEADER, unsafe_allow_html=True) st.markdown("![Alt Text](https://s3.amazonaws.com/moonup/production/uploads/1659200417899-62441d1d9fdefb55a0b7d12c.png)") st.sidebar.image( "https://assets.website-files.com/6139f3cdcbbff3a68486761d/613cd8997b270da063e230c5_Tekengebied%201-p-2000.png", use_column_width=True ) st.sidebar.markdown( SIDE_BAR_TEXT ) MAX_LEN = 100 max_length = st.sidebar.slider("Maximum generation length", 1, MAX_LEN, 20) # TODO: use the correct URL once it is ready # url = ( # f"https://hf.space/embed/bigscience/distributed-bloom-api/+/api/predict/" # ) url = ( f"https://hf.space/embed/ybelkada/bloom-1b3-gen/+/api/predict/" ) text_input = st.text_area(' Write your prompt below 🔎', height=50) col1, col2, col3 = st.columns(3) with col1: button_pushed = st.button("Let's generate!") with col2: lucky_button = st.button("I am feeling lucky") with col3: method_button = st.button("How does the method work?") text_placeholder = st.empty() if lucky_button: text_input = i_am_feeling_lucky() button_pushed = True if button_pushed: if text_input != '': r = requests.post( url=url, json={"data": [text_input, max_length, 0.6, True, 5, 42]} ) generated_text = r.json()["data"][0] write_incremental(text_input + generated_text, text_placeholder) else: write_incremental("Write some text above and try again :-)", text_placeholder)