[fix] Conditionally expose files/audio attributes in ChatInputValue based on accept parameters#13079
Merged
sfc-gh-nbellante merged 2 commits intodevelopfrom Nov 24, 2025
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
✅ PR preview is ready!
|
Contributor
Author
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the st.chat_input widget's return value to conditionally include files and audio keys based on the accept_file and accept_audio parameters. The goal is to make the API more intuitive by only exposing keys when the corresponding feature is enabled.
Key Changes:
- Modified
ChatInputValuedataclass to add_include_filesand_include_audioprivate fields that control which keys are exposed through the dict-like interface - Updated MutableMapping implementations (
__len__,__iter__,__contains__,__getitem__,__setitem__,__delitem__,to_dict()) to respect these flags - Added
__getattr__to raiseAttributeErrorwhen accessing excluded attributes - Updated existing tests to include the new parameters and added comprehensive parametrized tests for conditional key behavior
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
lib/streamlit/elements/widgets/chat.py |
Implements conditional key exposure in ChatInputValue by adding inclusion flags and updating MutableMapping interface methods and documentation |
lib/tests/streamlit/elements/chat_test.py |
Updates existing tests with new parameters and adds comprehensive parametrized tests to verify conditional key behavior |
7d6e8be to
7f04a08
Compare
08e084b to
2ef7be8
Compare
2ef7be8 to
3b51b15
Compare
3b51b15 to
9f2d1e8
Compare
5bbe981 to
2565b0b
Compare
sfc-gh-bnisco
approved these changes
Nov 21, 2025
9f2d1e8 to
a191b55
Compare
2565b0b to
7299b3e
Compare
7299b3e to
752f938
Compare
a191b55 to
f87f492
Compare
f87f492 to
85c1006
Compare
752f938 to
4dbf253
Compare
Contributor
Merge activity
|
4dbf253 to
9b9bfc4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Describe your changes
Improved the
ChatInputValueclass to conditionally exposefilesandaudioattributes based on theaccept_fileandaccept_audioparameters. This change ensures that:filesattribute is only accessible whenaccept_file=Trueaudioattribute is only accessible whenaccept_audio=Trueto_dict()method and dictionary-like access only include the enabled attributesTesting Plan
ChatInputValueattributes based on different combinations ofaccept_fileandaccept_audioparametersChatInputValueobjects with the new required parametersContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.