Good morning!
I was thinking to add the possibility to upload an image in chat_input, as OpenAI released the gpt-4-turbo including vision.
That could be great that chat_input could handle text and image inputs.
Thanks!
Good morning!
I was thinking to add the possibility to upload an image in chat_input, as OpenAI released the gpt-4-turbo including vision.
That could be great that chat_input could handle text and image inputs.
Thanks!
Hi @Adlef
Images could be uploaded via st.file_uploader
(st.file_uploader - Streamlit Docs)
That’s correct, but I was thinking to combine both together, as done by ChatGPT. A drag and drop into the chat_input, instead of combining the prompt written in chat_input and an upload of file. Besides, when sending a prompt via chat, I suppose automatically file_uploader is not cleaned right? It must be handled by code. Or?
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!
Thanks for your answer! I will play with that
I also came across this issue. I think having a component that can send attachments, especially with the vision AIGC models becoming more common, is very important.
I’m working on a custom component with the help of Copilot. It’s now already working but with some caveats. It’s open-sourced here and wish people who have more experience can help improve it! GitHub - AI-Colleagues/st-components
Update: I’ve just committed some big improvements. It’s practically usable now. No significant issues, and not very ugly IMO. Here is a video for it. Feel free to submit a PR if you have ideas to improve it further!
This is really nice. I think something like this should be added to the standard streamlit chat functionality
Amazing work!
Feel free to also upvote this feature request on GitHub: `st.chat_input`: Support for image and file input · Issue #7409 · streamlit/streamlit · GitHub
We started prototyping this feature recently. Don’t have a clear release date yet but we’re on it!
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.