Adding in streamlit chat_input the possibility to add an image

Unfortunately, st.chat_input accepts text and the only way to get images into the app is via the st.file_uploader. After an image file has been uploaded, you can process it into a format that the OpenAI API can process namely into a NumPy array.

Here’s a code snippet from @Adrien_Treuille_Snow from this post.

import streamlit as st
import numpy as np
from PIL import Image

img_file_buffer = st.file_uploader('Upload a PNG image', type='png')
if img_file_buffer is not None:
    image = Image.open(img_file_buffer)
    img_array = np.array(image)

Hope this helps!