Commit ·
b325ed3
1
Parent(s): 3605144
fixed streamlit components
Browse files9 unmodified lines101112131415161712 unmodified lines3031323334353637383940414243444546479 unmodified lines#load_dotenv()#HF_TOKEN = os.environ.get("HF_API_TOKEN")HF_TOKEN = st.secrets["HF_API_TOKEN"]login(token=HF_TOKEN)# Setup logginglogging.basicConfig(stream=sys.stdout, level=logging.INFO)12 unmodified lines# Create text generation pipelinepipe = pipeline("text-generation", model=model, tokenizer=tokenizer)# Continuously prompt the user for questionswhile True:# User input and chat interactionprompt = st.text_input("Please ask your question here (or type 'exit' to quit):")if prompt.lower() == 'exit':break# Display user message in chat message containerst.markdown("<b style='color:Red;'>User:</b> {}".format(prompt), unsafe_allow_html=True)# Generate responseresult = pipe(prompt, max_length=50, truncation=True)# Display bot response in chat message containerst.markdown("<b style='color:Green;'>Bot:</b> {}".format(result[0]['generated_text']), unsafe_allow_html=True)9 unmodified lines101112131415161712 unmodified lines3031323334353637383940414243444546479 unmodified lines#load_dotenv()#HF_TOKEN = os.environ.get("HF_API_TOKEN")#HF_TOKEN = st.secrets["HF_API_TOKEN"]#login(token=HF_TOKEN)# Setup logginglogging.basicConfig(stream=sys.stdout, level=logging.INFO)12 unmodified lines# Create text generation pipelinepipe = pipeline("text-generation", model=model, tokenizer=tokenizer)prompt = st.text_input("Please ask your question here:")# Button to submit questionif st.button("Submit"):if prompt.strip():# Display user message in chat message containerst.markdown("<b style='color:Red;'>User:</b> {}".format(prompt), unsafe_allow_html=True)# Generate responseresult = pipe(prompt)#, max_length=100, num_return_sequences=1)# Display bot response in chat message containerst.markdown("<b style='color:Green;'>Bot:</b> {}".format(result[0]['generated_text']), unsafe_allow_html=True)
app.py+17-17