filler phrase while starting tool call#232
Conversation
📝 WalkthroughWalkthroughAdds a new multilingual constant FILLER_PHRASES and registers an LLM event handler in the Pipecat service to emit a language-aware random filler phrase (as a TTSSpeakFrame) when function calls start, skipping when language switching is detected. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Pipecat as PipecatService
participant LLM
participant LangState as LanguageState
participant Phrases as FILLER_PHRASES
participant TTSQueue as TTSQueue
Client->>Pipecat: request triggering function calls
Pipecat->>LLM: send prompt / await function calls
LLM-->>Pipecat: event stream (function calls started)
Pipecat->>Pipecat: on_function_calls_started handler
Pipecat->>LangState: read current_language
LangState-->>Pipecat: language code
Pipecat->>Phrases: fetch phrases[language]
Phrases-->>Pipecat: list of phrases
Pipecat->>Pipecat: select random phrase
Pipecat->>TTSQueue: enqueue TTSSpeakFrame(phrase)
TTSQueue-->>Client: play spoken filler phrase
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)
527-530: Harden phrase fallback when a language key exists but has an empty list.Current logic falls back only for missing keys; if a configured list is empty, Line 530 can raise on
random.choice.Suggested fix
- phrases = FILLER_PHRASES.get( - current_lang, FILLER_PHRASES.get('en', ['Please wait a moment']) - ) + phrases = ( + FILLER_PHRASES.get(current_lang) + or FILLER_PHRASES.get('en') + or ('Please wait a moment.',) + ) phrase = random.choice(phrases)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py` around lines 527 - 530, The code uses FILLER_PHRASES.get(current_lang, ...) then does random.choice(phrases) which will raise if the key exists but maps to an empty list; update the logic around FILLER_PHRASES/current_lang/phrases/phrase so you explicitly ensure phrases is a non-empty list before calling random.choice by checking if not phrases and then assigning FILLER_PHRASES.get('en') or a hardcoded default like ['Please wait a moment']; apply this fix in the block that sets phrases and phrase so it safely falls back when the language key exists but the list is empty.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Line 525: The on_function_calls_started callback defines unused parameters
`service` and `function_calls` causing ARG001; fix it by renaming the parameters
to indicate intentional unused (e.g., `_service` and `_function_calls`) or
prefixing them with underscores so the linter ignores them while keeping the
function signature (update the async def on_function_calls_started definition
accordingly).
---
Nitpick comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Around line 527-530: The code uses FILLER_PHRASES.get(current_lang, ...) then
does random.choice(phrases) which will raise if the key exists but maps to an
empty list; update the logic around FILLER_PHRASES/current_lang/phrases/phrase
so you explicitly ensure phrases is a non-empty list before calling
random.choice by checking if not phrases and then assigning
FILLER_PHRASES.get('en') or a hardcoded default like ['Please wait a moment'];
apply this fix in the block that sets phrases and phrase so it safely falls back
when the language key exists but the list is empty.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
wavefront/server/apps/call_processing/call_processing/constants/filler_phrases.pywavefront/server/apps/call_processing/call_processing/services/pipecat_service.py
|
|
||
| # Register event handlers | ||
| @llm.event_handler('on_function_calls_started') | ||
| async def on_function_calls_started(service, function_calls): |
There was a problem hiding this comment.
Resolve unused callback parameters to keep lint clean.
Line 525 introduces service and function_calls but does not use them (Ruff ARG001).
Suggested fix
- async def on_function_calls_started(service, function_calls):
+ async def on_function_calls_started(_service, _function_calls):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async def on_function_calls_started(service, function_calls): | |
| async def on_function_calls_started(_service, _function_calls): |
🧰 Tools
🪛 Ruff (0.15.2)
[warning] 525-525: Unused function argument: service
(ARG001)
[warning] 525-525: Unused function argument: function_calls
(ARG001)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`
at line 525, The on_function_calls_started callback defines unused parameters
`service` and `function_calls` causing ARG001; fix it by renaming the parameters
to indicate intentional unused (e.g., `_service` and `_function_calls`) or
prefixing them with underscores so the linter ignores them while keeping the
function signature (update the async def on_function_calls_started definition
accordingly).
There was a problem hiding this comment.
♻️ Duplicate comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)
525-525:⚠️ Potential issue | 🟡 MinorRename unused callback arg to clear Ruff ARG001.
serviceis still unused in this handler. Prefix it with_to make intent explicit and keep lint clean.Suggested fix
- async def on_function_calls_started(service, function_calls): + async def on_function_calls_started(_service, function_calls):🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py` at line 525, The handler on_function_calls_started currently declares an unused parameter named service which triggers Ruff ARG001; rename that parameter to _service (or _ ) in the async def on_function_calls_started signature to mark it as intentionally unused and update any internal references (none expected) accordingly so the lint error is resolved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Line 525: The handler on_function_calls_started currently declares an unused
parameter named service which triggers Ruff ARG001; rename that parameter to
_service (or _ ) in the async def on_function_calls_started signature to mark it
as intentionally unused and update any internal references (none expected)
accordingly so the lint error is resolved.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)
526-526:⚠️ Potential issue | 🟡 MinorRename the unused callback parameter at Line 526.
serviceis currently unused and still triggers RuffARG001.Suggested fix
- async def on_function_calls_started(service, function_calls): + async def on_function_calls_started(_service, function_calls):🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py` at line 526, The callback on_function_calls_started currently declares a parameter named service that is unused and triggers Ruff ARG001; rename the parameter in the function signature (e.g., from service to _service or _) to mark it as intentionally unused and update any callers or references to the callback registration if they rely on positional args, leaving the function body unchanged (function name: on_function_calls_started).
🧹 Nitpick comments (1)
wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py (1)
528-531: Cache the feature flag once instead of reading env on every callback.Reading/parsing
ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALLper event is avoidable overhead and can cause runtime behavior drift if env changes mid-call.Refactor sketch
+ enable_filler_phrases_before_tool_call = ( + os.getenv('ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL', '').strip().lower() + == 'true' + ) + `@llm.event_handler`('on_function_calls_started') async def on_function_calls_started(_service, function_calls): - if ( - os.getenv('ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL', '').lower() - != 'true' - ): + if not enable_filler_phrases_before_tool_call: return🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py` around lines 528 - 531, Cache the ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL flag once instead of calling os.getenv(...) on every event: read and parse the env var to a boolean at module import or in the PipecatService initializer (e.g., store as module-level ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL or self.enable_filler_phrases_before_tool_call) and replace the per-callback check that currently uses os.getenv('ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL', '').lower() != 'true' with a check against the cached boolean; ensure the variable name matches existing style and is used wherever that runtime check appears.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Line 526: The callback on_function_calls_started currently declares a
parameter named service that is unused and triggers Ruff ARG001; rename the
parameter in the function signature (e.g., from service to _service or _) to
mark it as intentionally unused and update any callers or references to the
callback registration if they rely on positional args, leaving the function body
unchanged (function name: on_function_calls_started).
---
Nitpick comments:
In
`@wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py`:
- Around line 528-531: Cache the ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL flag
once instead of calling os.getenv(...) on every event: read and parse the env
var to a boolean at module import or in the PipecatService initializer (e.g.,
store as module-level ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL or
self.enable_filler_phrases_before_tool_call) and replace the per-callback check
that currently uses os.getenv('ENABLE_FILLER_PHRASES_BEFORE_TOOL_CALL',
'').lower() != 'true' with a check against the cached boolean; ensure the
variable name matches existing style and is used wherever that runtime check
appears.
Summary by CodeRabbit