Chat_Input doesnt accept attach_file parameter?

I tried using the attach_file parameter for the chat_input in the latest version of Streamlit but it doesn’t work?

Traceback (most recent call last):
  File "/Users/aravind.vijayaraghav/Documents/Data_AI_ML/Complex_AI.py", line 255, in <module>
    prompt = st.chat_input("Type your question here...",accept_file=True, file_type=["csv"])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 408, in wrapped_func
    result = non_optional_func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ChatMixin.chat_input() got an unexpected keyword argument 'accept_file'
streamlit --version
Streamlit, version 1.43.0

I have the latest streamlit version as well. So I’m not sure what the problem is

Can you double check within your app that it’s running on the same version as in your terminal?

  1. From your running app, in the upper right hand corner, click the three dots.
  2. Select About.
  3. Check the Streamlit version reported the.

I can see in your error message that you have the correct parameter, accept_file. So I just want to confirm if there is a mixup between multiple Python environments.

Oh you were right even though I reinstalled it its still in 1.41 version but I was able to resolve that. Do you know how to get the output to just have the text and the file (if attached):

Right now it looks like this, when I type a simple Hi in the chatbot. Could you also help with how I have to use files attached within my prompts:

ChatInputValue(text=‘Hi’, files=)

I can provide my current code if it helps:

prompt = st.chat_input("Type your question here...",accept_file=True, file_type=["csv","jpg","jpeg","png"])

st.session_state.messages.append({"role": "user", "content": prompt})
        with st.chat_message("user"):
            st.markdown(f'<div class="user-message">{prompt.text}+{prompt["files"][0]}</div>', unsafe_allow_html=True)

response_prompt = {
                "role": "user",
                "content": (
                    f"This is the session's conversation history so far: {st.session_state.messages}\n\n"
                    f"User's current question: {prompt}\n\n"
                 )
}

with st.chat_message("assistant"):
            stream = client.chat.completions.create(
                model=st.session_state["openai_model"],
                messages=[system_message, response_prompt],
                stream=True,
                temperature=0.7,
            )
            response = st.write_stream(stream)
            st.session_state.messages.append({"role": "assistant", "content": response})

The chat output is a dict-like object when you have the file uploader enabled. So you need to work from the text and files attributes of the return value.

import streamlit as st

prompt = st.chat_input(
    "Say something and/or attach an image",
    accept_file=True,
    file_type=["jpg", "jpeg", "png"],
)
if prompt and prompt.text:
    st.markdown(prompt.text)
if prompt and prompt["files"]:
    st.image(prompt["files"][0])