feat: conditionally render voice button based on voice mode state (#8561)

* chore: update webrtcvad dependency and add optional audio support

- Updated webrtcvad version requirement to >=1.9.4 in pyproject.toml and uv.lock.
- Moved webrtcvad to optional dependencies under the new 'audio' category in both pyproject.toml files for better modularity.
- Ensured compatibility with existing dependencies while enhancing documentation for optional audio features.

* fix: handle optional import of voice_mode_router in API initialization

- Updated the API router initialization to conditionally include the voice_mode_router if it is available, improving modularity and preventing import errors.
- Adjusted the import statement for voice_mode_router to handle ImportError gracefully, ensuring the application remains robust in its absence.

* feat: add voice mode flag to API configuration

- Introduced a new function `get_voice_mode_enabled` to check for the availability of the `webrtcvad` library, enhancing the API's capability to support voice mode features.
- Updated the `ConfigResponse` schema to include `voice_mode_enabled` flag, allowing clients to query the status of voice mode support.
- Integrated the voice mode feature flag into the `get_config` endpoint response, improving the configurability of the API.

* test: skip voice mode tests if webrtcvad is not installed

- Added a conditional import for the webrtcvad library in the voice mode test suite.
- Implemented a pytest marker to skip tests when webrtcvad is unavailable, enhancing test robustness and preventing unnecessary failures.

* feat: add voice mode state management to flows manager store

- Introduced `voiceModeEnabled` state and `setVoiceModeEnabled` action in the flows manager store to manage the voice mode feature.
- Updated the `ConfigResponse` interface and `useGetConfig` hook to integrate the new voice mode state, allowing for dynamic configuration updates.
- Enhanced the API's configurability by ensuring the voice mode state is properly set based on the API response.

* feat: conditionally render voice button based on voice mode state

- Integrated `voiceModeEnabled` from the flows manager store to control the visibility of the VoiceButton component.
- The VoiceButton will now return null if voice mode is not enabled, enhancing the user interface by preventing unnecessary rendering.

* fix: ensure boolean conversion for voice mode state in config hook

- Updated the `setVoiceModeEnabled` function in the `useGetConfig` hook to explicitly convert the `voice_mode_enabled` value to a boolean, ensuring consistent handling of the voice mode state based on API responses.

* refactor: conditionally import voice_mode_router in API initialization

- Updated the API router to conditionally include the voice_mode_router based on its availability, enhancing modularity and preventing import errors.
- Adjusted the __init__.py file to dynamically add voice_mode_router to the __all__ list if the import is successful, improving the API's robustness.

* chore: revert mcp version update

* refactor: reorder router initialization and add audio flag to backend install task

* feat: add audio module to backend installation command in VS Code tasks

* ci: add audio extras to uv sync in frontend tests
This commit is contained in:
Gabriel Luiz Freitas Almeida 2025-06-17 12:23:12 -03:00 • committed by GitHub
commit 4d3eae63ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 73 additions and 24 deletions

16
uv.lock generated
View file

@ -4746,7 +4746,6 @@ dependencies = [
{ name = "upstash-vector" },
{ name = "uv" },
{ name = "weaviate-client" },
{ name = "webrtcvad" },
{ name = "wikipedia" },
{ name = "wolframalpha" },
{ name = "yfinance" },
@ -4755,6 +4754,9 @@ dependencies = [
]
[package.optional-dependencies]
audio = [
{ name = "webrtcvad" },
]
cassio = [
{ name = "cassio" },
]
@ -4940,14 +4942,14 @@ requires-dist = [
{ name = "upstash-vector", specifier = "==0.6.0" },
{ name = "uv", specifier = ">=0.5.7" },
{ name = "weaviate-client", specifier = "==4.10.2" },
{ name = "webrtcvad", specifier = ">=2.0.10" },
{ name = "webrtcvad", marker = "extra == 'audio'", specifier = ">=2.0.10" },
{ name = "wikipedia", specifier = "==1.4.0" },
{ name = "wolframalpha", specifier = "==5.1.3" },
{ name = "yfinance", specifier = "==0.2.50" },
{ name = "youtube-transcript-api", specifier = "==0.6.3" },
{ name = "zep-python", specifier = "==2.0.2" },
]
provides-extras = ["couchbase", "cassio", "local", "clickhouse-connect", "nv-ingest", "postgresql"]
provides-extras = ["audio", "couchbase", "cassio", "local", "clickhouse-connect", "nv-ingest", "postgresql"]
[package.metadata.requires-dev]
dev = [
@ -5073,7 +5075,6 @@ dependencies = [
{ name = "uncurl" },
{ name = "uvicorn" },
{ name = "validators" },
{ name = "webrtcvad" },
]
[package.optional-dependencies]
@ -5082,6 +5083,9 @@ all = [
{ name = "llama-cpp-python" },
{ name = "sentence-transformers" },
]
audio = [
{ name = "webrtcvad" },
]
local = [
{ name = "ctransformers" },
{ name = "llama-cpp-python" },
@ -5210,9 +5214,9 @@ requires-dist = [
{ name = "uncurl", specifier = ">=0.0.11,<1.0.0" },
{ name = "uvicorn", specifier = ">=0.30.0,<1.0.0" },
{ name = "validators", specifier = ">=0.34.0" },
{ name = "webrtcvad", specifier = ">=2.0.10" },
{ name = "webrtcvad", marker = "extra == 'audio'", specifier = ">=2.0.10" },
]
provides-extras = ["postgresql", "local", "all"]
provides-extras = ["audio", "postgresql", "local", "all"]
[package.metadata.requires-dev]
dev = [