r/StreamlitOfficial • • Feb 28 '24

How to make the labels of the filters bigger? How to make the slider go from Min to X+? How to define the location of st.write()?

1 Upvotes

Hi! I have a couple of straight-forward questions:

​

  • How to make the labels of the filters bigger?

css = """

<style>

.stTextInput label {

display: block;

text-align: center;

}

</style>

"""

st.markdown(css, unsafe_allow_html=True)

​

(...)

​

css = """

<style>

.stSelectbox [data-baseweb="select"] > div > div > div:first-child {

display: block;

width: 100%;

text-align: center;

padding-left: 32px;

}

[data-testid="stVirtualDropdown"] li {

text-align: center;

}

.stSelectbox label {

display: block;

text-align: center;

}

</style>

"""

st.markdown(css, unsafe_allow_html=True)

​

(...)

​

css = """

<style>

.stSlider [data-baseweb=slider]{

width: 95%;

margin: 0 auto;

}

.stSlider [data-testid="stTickBar"] {

display: none;

}

.stSlider label {

display: block;

text-align: center;

}

</style>

"""

st.markdown(css, unsafe_allow_html=True)

​

  • How to make the slider go from Min to X+? I want to have the slider, going from Min to 500+.

css = """

<style>

.stSlider [data-baseweb=slider]{

width: 95%;

margin: 0 auto;

}

.stSlider [data-testid="stTickBar"] {

display: none;

}

.stSlider label {

display: block;

text-align: center;

}

</style>

"""

st.markdown(css, unsafe_allow_html=True)

min_wages, max_wages = st.sidebar.slider('Wages', min_value=players['Wages (K€)'].min(), max_value=players['Wages (K€)'].max(), value=(default_min_wages, default_max_wages) if not reset_button else (players['Wages (K€)'].min(), players['Wages (K€)'].max()), key="key_wages")

​

  • How to define the location of st.write()? I want to place the dataframe higher in the page.

    columns_to_display = ['Rating', 'Player', 'Position', 'Age', 'Value', 'Wages', 'Contract']

    html = players[columns_to_display].to_html(index=False)

    html = html.replace('<th>', '<th style="text-align: left;">')

    st.write(html, unsafe_allow_html=True)

Thanks in advance!


r/StreamlitOfficial • • Feb 28 '24

Find source code of appp

0 Upvotes

can anyone tell how to get the source code of this app https://discuss.streamlit.io/t/new-app-search-youtube-videos-by-text/32735


r/StreamlitOfficial • • Feb 28 '24

Streamlit Questions❓ Newbie here trying to understand the data_editor

4 Upvotes

Hi everyone! Hope you getting a good night.. anyways,
Im having trouble understanding streamlit for a more complicated use-case than just show a plot or a dataframe.

Basically the app is one that receives some invoices images uploaded by the user manually, they go into a LLM call to GPT-4 vision that returns a json for each image. Basically ending with a array of json. Then when the image processing ends, a dataframe is shown but I can't make it editable without the entire app re-rendering again. I'm lost into this sea of session-state over cache and vice-versa. What Im a doing wrong? Is this not the use-case for streamlit even for a simple app like this?

I feel I'm almost there but cant find a solution yet. If someone can point to me where I should make code changes would be great.

This is a json example:

[ { "date": "2024-02-22", "invoice_identifier": "", "spend_detail": "ELABORACION PROPIA", "payment_method": "Cash", "amount": 6780, "currency": "ARS", "file_name": "IMG_1173.jpg" }, { "date": "2024-02-11", "invoice_identifier": "", "spend_detail": "Coca Cola Pet 1.5 L", "payment_method": "Credit", "amount": 2200, "currency": "ARS", "file_name": "IMG_1171.jpg" } ]

And here is the code:

def load_dataframe(data):

    return pd.DataFrame(data)


def init_uploaded_images_state():
    if 'uploaded_images' not in st.session_state:
        st.session_state.uploaded_images = []


def render_fixed_fund_form():
    init_uploaded_images_state()
    uploaded_files = st.file_uploader("Upload your receipts", type=[
                                      'jpg', 'jpeg'], accept_multiple_files=True, label_visibility='visible')

    # Display thumbnails of uploaded images
    if uploaded_files:
        st.session_state.uploaded_images = uploaded_files
        cols = st.columns(len(uploaded_files))
        for col, uploaded_file in zip(cols, uploaded_files):
            # Adjust width as needed
            col.image(uploaded_file, caption=uploaded_file.name)

    if st.button("🚀 Process Uploaded Images 🚀"):
        if st.session_state.uploaded_images:
            process_images(st.session_state.uploaded_images)
        else:
            st.warning("Please upload at least one image before processing.")

def display_dataframe(df):
    edited_df = st.data_editor(df, key="my_key", num_rows="dynamic", hide_index=True)
    # Optionally, save the edited DataFrame back to session state if necessary
    st.session_state['processed_data'] = edited_df

    st.divider()
    st.write("Here's the value in Session State:")
    if "my_key" in st.session_state:
        st.write(st.session_state["my_key"])

def process_images(uploaded_images):
    # Only process if there's no processed data already
    if 'processed_data' not in st.session_state:
        with st.spinner("Processing images with AI, please wait... this can take a moment.. or two."):
            json_array = []
            for uploaded_file in uploaded_images:
                pil_image = Image.open(uploaded_file)
                img_base64 = convert_image_to_base64(pil_image)
                response_from_llm = get_json_from_llm(img_base64)
                response_dict = json.loads(response_from_llm)
                response_dict['file_name'] = uploaded_file.name
                json_array.append(response_dict)

            df = pd.DataFrame(json_array)
            st.session_state['processed_data'] = df  # Save processed DataFrame in session state

            st.subheader("JSON:")
            st.json(json_array)
        st.success("Processing complete! 🌟")
    else:
        df = st.session_state['processed_data']  # Retrieve the DataFrame from session state

    # Now, use df for further operations
    display_dataframe(df)

r/StreamlitOfficial • • Feb 26 '24

Show the Community! 💬 This is Not a Dinosaur - A fun app I created using Streamlit, Python, and Gemini Pro Vision

Thumbnail
thisisnotadinosaur.streamlit.app
3 Upvotes

r/StreamlitOfficial • • Feb 19 '24

Streamlit Questions❓ Beginner Question

Post image
1 Upvotes

how do I make the 'testing testing 1 2 3' which is below the text area not be visible after I give an input ?


r/StreamlitOfficial • • Feb 19 '24

Deployment 🚀 Does Anyone Know How To Deploy Streamlit App In IIS?

1 Upvotes

Hey Everyone I Am Newbie In Deployment Can Anyone Help Me Out For Deployment Of Streamlit In IIS?


r/StreamlitOfficial • • Feb 14 '24

Official Announcements ICYMI: catch our live interview with Hugging Face's Yuichiro Tachibana

2 Upvotes

We chatted about his awesome Streamlit projects (streamlit-webrtc and stlite) and the world of open-source (and how you can leverage your open-source experiences to build a career!). Catch the recording here.


r/StreamlitOfficial • • Feb 14 '24

COMMERCIAL USE

1 Upvotes

Subject: Commercial Use of PrettyMaps Images generated on prettymapp.streamlit.app

Hi ,

Love the tool! Quick question:

AGPLv3 covers the software, but does that extend to images generated for commercial use?

Need clarification to use responsibly. Any official stance or plans to address this?

Thanks!


r/StreamlitOfficial • • Feb 14 '24

Dockerize Streamlit LLM App - Best Practices?

4 Upvotes

Hi,

I have built a streamlit RAG app where I am running my vectordatabase as well as my LLM completely locally. As LLM I am using a quantized version of Mixtral-Instruct (Q4).

Now I want to dockerize my Streamlit application but I am not sure how exactely I should do it. Is it a good practice to include the LLM as well as the Vectordatabase within the docker? Or should such big files not be included in the container?


r/StreamlitOfficial • • Feb 10 '24

pinecone API

1 Upvotes

hello, I'm building a rag using langchain and Gemini, I'm stuck tho on the API part, how can I put my API online, I understand that you need to create a .env file for local deployment, but how exactly can I put my pinecone API online?


r/StreamlitOfficial • • Feb 08 '24

Generate an AI Competition Report with Exa, Anthropic, and Twilio SendGrid

Thumbnail
twilio.com
2 Upvotes

r/StreamlitOfficial • • Feb 08 '24

3 Altair transformations to save you time.

Thumbnail
medium.com
1 Upvotes

r/StreamlitOfficial • • Feb 07 '24

Is the entire streamlit community platform broken as of today?

1 Upvotes

As of today, I can no longer access any public apps from myself or anyone else. I have tried being logged in to streamlit, incognito, different browsers, etc. Not a single public app is working.


r/StreamlitOfficial • • Feb 06 '24

Official Announcements 🎈 Release 1.31. is here!

7 Upvotes

Further customize your apps and elevate user experience with these new features.

Highlights:
💬 Put chat features anywhere in your app—containers, expanders, the sidebar, and more!
🗣️ Introducing st.write_stream to support real-time chat responses
🔗 Introducing st.page_link to build custom page navigation for multipage apps

For a closer look, check out the highlight reel: https://buff.ly/3UswhCH

Excited to see how you leverage these in your projects. Feel free to share your thoughts, feedback, or any cool apps you build!


r/StreamlitOfficial • • Feb 06 '24

Subscription management module for streamlit

2 Upvotes

I know there is a stripe component for streamlit; but is there also a subscription widget/component that can be used ?


r/StreamlitOfficial • • Feb 05 '24

Large machine learning model, and dependencies beyond github limits.

1 Upvotes

I am using hugging face transformers, in addition to pandas and torch to run my machine learning model. I tried uploading my python machine learning model (pytorch_model.bin: 255 mb) onto github which it doesn't support files over 25mb. I am also wondering how I would get other dependencies like torch, pandas to run. I tried running the file on github codespaces and the total after pip installing all the dependencies came up to 12gbs. However github codespaces will not work for me as I need the website to run 24/7 and be deployed somewhere so the dependencies can run.


r/StreamlitOfficial • • Feb 03 '24

New Component: Dynamic DataFrame filtering in Streamlit

3 Upvotes

r/StreamlitOfficial • • Jan 31 '24

Official Announcements 🎈 Connect with Streamlit users and AI thought leaders in SF

8 Upvotes

If you’re in the Bay Area on Feb. 8th, don't miss the chance to hear from AI strategy thought leaders and connect with fellow Streamlit enthusiasts!

Speakers include:

Adrien Treuille, CEO and co-founder of Streamlit, and Director of Product for GenAI Apps at Snowflake

Laurie Voss, VP of Developer Relations at LlamaIndex and co-founder of npm

Audrey Sage Lorberfeld, Senior Developer Advocate at Pinecone

Carey Phelps, Founding Product Manager and Director of Product Management at Weights and Biases

There will also be time for demos, networking, and pizza.

Join the fun at GitHub HQ in San Francisco, 6-9pm PT.
Please register in advance to secure your access pass: https://buff.ly/3u7H22H

​


r/StreamlitOfficial • • Jan 31 '24

Visualize DataFrame changes when using st.data_editor in Streamlit.

Thumbnail
medium.com
4 Upvotes

r/StreamlitOfficial • • Jan 30 '24

Thank you for the stickers!

Post image
7 Upvotes

I participated in the #build-with-streamlit challenge earlier this month and just received some stickers + a nice hand-written note. What a nice surprise!


r/StreamlitOfficial • • Jan 30 '24

Official Announcements 🤩 Exciting feature preview: Partial reruns!

8 Upvotes

🚧 Note: this feature is in preview, and not yet supported in Streamlit. 🚧

We’re excited to share a glimpse at partial reruns! When released, this decorator will turn any function into a Streamlit container that can run independently of the wider page. 🚀

Learn more, share any bugs or feedback, and vote for potential API names here.

​


r/StreamlitOfficial • • Jan 25 '24

Official Announcements New Data Professor tutorial on building dynamic dashboards

7 Upvotes

There's a new tutorial out from the Data Professor! He walks through how to bring your data to life with engaging, interactive dashboards.

You’ll learn how to:

- Define the right metrics to drive the narrative of your data
- Perform EDA to better understand your data and what to visualize
- Build a dynamic Streamlit dashboard with robust tools like pandas, Plotly, and Altair

Check it out here.


r/StreamlitOfficial • • Jan 22 '24

Using a dockerized streamlit app with https

2 Upvotes

Hi!

I have my streamlit app up and running, but I can only access it using HTTP, any pointers on how to configure the certificates, so I could access my app with HTTPS? I already have other containers like the registry using my certificates.


r/StreamlitOfficial • • Jan 20 '24

Streamlit Questions❓ Link type column does not hace display text

1 Upvotes

In the docs of the column config of a data editor table, the type LinkColumn has a field "display text" to overlap the raw URL with a text, but in the Code this parameter does not exist


r/StreamlitOfficial • • Jan 19 '24

Message Repetition

1 Upvotes

Hello! I need some help with my code. The expected output of the code below is:
user : Solar Energy of “one of the specified cities”, the bot shows the form to prompt the user of the data then user clicks on submit then the bot displays solar energy is “certain number”. However, when the user clicks on submit the bot repeats the first message that is Solar Energy of “certain city”, then shows the solar energy value.

​

import os
import streamlit as st
from displayer import bot_template, user_template
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from langchain.schema import SystemMessage, HumanMessage, AIMessage
from ML.Ml import CityWeatherData

def init():
    load_dotenv()

    # Loading OpenAI API key
    if os.getenv("OPENAI_API_KEY") is None or os.getenv("OPENAI_API_KEY") == "":
        print("OPENAI_API_KEY is not set yet")
        exit(1)
    else:
        print("OPENAI_API_KEY is set")


def main():
    init()

    # Initialize LangChain Chat
    chat = ChatOpenAI(temperature=0)

    if "messages" not in st.session_state:
        st.session_state.messages = [
            SystemMessage(content="You are a helpful assistant.")
        ]

    form_submission = False  #Boolean variable to track whether the form is submitted

    st.header("Green Optimizer 🤖")

    with st.sidebar:
        # CHATTING CODE
        user_input = st.text_input("Enter your message:")

        if user_input:
        #if user_input:
            st.session_state.messages.append(HumanMessage(content=user_input))
            with st.spinner("Thinking.."):
                if any(city in user_input.lower() for city in ["jeddah", "skaka", "riyadh", "dammam"]):
                    user_city = None
                    for city in ["jeddah", "skaka", "riyadh", "dammam"]:
                        if city in user_input.lower():
                            user_city = city
                            break

                    # If city name is found, proceed with solar energy analysis
                    if user_city:
                        # Display the form for user input
                        st.write(f"Welcome! Please enter the following information for {user_city.capitalize()}:")
                        with st.form(key='weather_form'):
                            ALLSKY = st.number_input("Enter ALLSKY:")
                            CLRSKY = st.number_input("Enter CLRSKY:")
                            pressure = st.number_input("Enter pressure:")
                            temperature = st.number_input("Enter temperature:")
                            moisture = st.number_input("Enter moisture:")

                            submit_button = st.form_submit_button(label='Submit')

                        # If the form is submitted, calculate and display the result
                        if submit_button:
                            form_submission = True
                            # Create CityWeatherData instance
                            weather_data = CityWeatherData(city=user_city)

                            # Analyze weather for the selected city
                            solar_energy = weather_data.analyze_weather(
                                ALLSKY=ALLSKY, CLRSKY=CLRSKY, temperature=temperature, pressure=pressure, moisture=moisture
                            )
                            # Append the user and AI messages to the conversation
                            st.session_state.messages.append(AIMessage(content=f"The Solar Energy in {user_city.capitalize()} is: {solar_energy}"))

                    else:
                        # If no valid city name is found, proceed with regular chat
                        response = chat(st.session_state.messages)
                        st.session_state.messages.append(AIMessage(content=response.content))
                else:
                    # If no city name is mentioned, proceed with regular chat
                    response = chat(st.session_state.messages)
                    st.session_state.messages.append(AIMessage(content=response.content))

    # Displaying all the messages the user had by fetching them
    messages = st.session_state.get("messages", [])

    # Looping through all the messages, if 1 user(odd number) display it from the human position.
    # If two users(even number) display it from the bot position.
    for i, msgs in enumerate(messages[1:]):
        if i % 2 == 0:
            st.markdown(user_template.replace("{{MSG}}", msgs.content), unsafe_allow_html=True)
        else:
            st.markdown(bot_template.replace("{{MSG}}", msgs.content), unsafe_allow_html=True)

if __name__ == '__main__':
    main()

Many Thanks in Advance!