How to take multiline rich-text input from user

I am using the following code for taking user input , but the output is not rendering.
code inside if condition is not working. if i place the txt area outside if, it works.
Any help would be appreciated

option = st.sidebar.selectbox("Select option",  ("Text Summarisation", "Web Scrapping", "Video Summarisation"))

def get_option(option):

if option == "Text Summarisation":

    sentence = st.text_area('Enter your text here...')

    if sentence:

        summarization = pipeline("summarization")

        summary_text = summarization(sentence)[0]['summary_text']

        st.write(summary_text)

Hi @Shambhavi4, welcome to the Streamlit community!! :clap: :partying_face:

Could you clarify what exactly within which of the if blocks isn’t working? I’m unable to reproduce the error on my end. Your code seems to work as expected:

import streamlit as st
from transformers import pipeline

def get_option(option):
    if option == "Text Summarisation":
        sentence = st.text_area('Enter your text here...')
        if sentence:
            summarization = pipeline("summarization")
            summary_text = summarization(sentence)[0]['summary_text']
            st.write(summary_text)

option = st.sidebar.selectbox("Select option",  ("Text Summarisation", "Web Scrapping", "Video Summarisation"))

get_option(option)

Output:

multiline-rich-text

Best, :balloon:
Snehan

Thanks @snehankekre
The code is not producing the output at my end. It displays nothing.

Thanks for your response. The code worked. I found the error. I want not calling the fnction correctly

1 Like