-
Notifications
You must be signed in to change notification settings - Fork 4k
[fix] Conditionally expose files/audio attributes in ChatInputValue based on accept parameters #13079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] Conditionally expose files/audio attributes in ChatInputValue based on accept parameters #13079
Conversation
✅ 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. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
9f2d1e8 to
a191b55
Compare
2565b0b to
7299b3e
Compare
7299b3e to
752f938
Compare
a191b55 to
f87f492
Compare
f87f492 to
85c1006
Compare
752f938 to
4dbf253
Compare
Merge activity
|
4dbf253 to
9b9bfc4
Compare

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.