Skip to content

Conversation

@sfc-gh-nbellante
Copy link
Contributor

@sfc-gh-nbellante sfc-gh-nbellante commented Nov 20, 2025

Describe your changes

Improved the ChatInputValue class to conditionally expose files and audio attributes based on the accept_file and accept_audio parameters. This change ensures that:

  • The files attribute is only accessible when accept_file=True
  • The audio attribute is only accessible when accept_audio=True
  • Attempting to access these attributes when not enabled raises appropriate errors
  • The to_dict() method and dictionary-like access only include the enabled attributes
  • Updated docstrings to clarify this conditional behavior

Testing Plan

  • Unit Tests: Added comprehensive tests to verify the conditional behavior of ChatInputValue attributes based on different combinations of accept_file and accept_audio parameters
  • Existing tests were updated to properly initialize ChatInputValue objects with the new required parameters

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Nov 20, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13079/streamlit-1.51.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13079.streamlit.app (☁️ Deploy here if not accessible)

Copy link
Contributor

Copilot AI left a 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 ChatInputValue dataclass to add _include_files and _include_audio private 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 raise AttributeError when 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

@sfc-gh-nbellante sfc-gh-nbellante changed the title adjusting return value of chat input [fix] Conditionally expose files/audio attributes in ChatInputValue based on accept parameters Nov 20, 2025
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-20-adjusting_return_value_of_chat_input branch from 7d6e8be to 7f04a08 Compare November 20, 2025 22:28
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-19-sample_rate_for_chat_input branch from 08e084b to 2ef7be8 Compare November 20, 2025 22:28
@sfc-gh-nbellante sfc-gh-nbellante marked this pull request as ready for review November 20, 2025 22:41
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-19-sample_rate_for_chat_input branch from 2ef7be8 to 3b51b15 Compare November 21, 2025 15:22
@sfc-gh-nbellante sfc-gh-nbellante requested a review from a team as a November 21, 2025 15:22
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-19-sample_rate_for_chat_input branch from 3b51b15 to 9f2d1e8 Compare November 21, 2025 15:22
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-20-adjusting_return_value_of_chat_input branch 2 times, most recently from 5bbe981 to 2565b0b Compare November 21, 2025 15:59
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-19-sample_rate_for_chat_input branch from 9f2d1e8 to a191b55 Compare November 21, 2025 20:19
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-20-adjusting_return_value_of_chat_input branch from 2565b0b to 7299b3e Compare November 21, 2025 20:19
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-20-adjusting_return_value_of_chat_input branch from 7299b3e to 752f938 Compare November 24, 2025 15:58
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-19-sample_rate_for_chat_input branch from a191b55 to f87f492 Compare November 24, 2025 15:58
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from 11-19-sample_rate_for_chat_input to graphite-base/13079 November 24, 2025 16:15
@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-20-adjusting_return_value_of_chat_input branch from 752f938 to 4dbf253 Compare November 24, 2025 16:16
@graphite-app graphite-app bot changed the base branch from graphite-base/13079 to develop November 24, 2025 16:16
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 24, 2025

Merge activity

  • Nov 24, 4:16 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.
  • Nov 24, 6:29 PM UTC: @sfc-gh-nbellante merged this pull request with Graphite.

@sfc-gh-nbellante sfc-gh-nbellante force-pushed the 11-20-adjusting_return_value_of_chat_input branch from 4dbf253 to 9b9bfc4 Compare November 24, 2025 16:17
@sfc-gh-nbellante sfc-gh-nbellante merged commit 4291205 into develop Nov 24, 2025
42 checks passed
@sfc-gh-nbellante sfc-gh-nbellante deleted the 11-20-adjusting_return_value_of_chat_input branch November 24, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:other PR contains other type of change impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants