Merge pull request #2032 from pipecat-ai/aleix/aws-nova-sonic-function-calls

AWSNovaSonicLLMService: fix function calling
This commit is contained in:
Aleix Conchillo Flaqué
2025-06-19 14:42:47 -07:00
committed by GitHub
2 changed files with 13 additions and 6 deletions

View File

@@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed function calling in `AWSNovaSonicLLMService`.
- Fixed an issue that would cause multiple `PipelineTask.on_idle_timeout` - Fixed an issue that would cause multiple `PipelineTask.on_idle_timeout`
events to be triggered repeatedly. events to be triggered repeatedly.

View File

@@ -25,6 +25,7 @@ from pipecat.frames.frames import (
CancelFrame, CancelFrame,
EndFrame, EndFrame,
Frame, Frame,
FunctionCallFromLLM,
InputAudioRawFrame, InputAudioRawFrame,
InterimTranscriptionFrame, InterimTranscriptionFrame,
LLMFullResponseEndFrame, LLMFullResponseEndFrame,
@@ -804,12 +805,16 @@ class AWSNovaSonicLLMService(LLMService):
# Call tool function # Call tool function
if self.has_function(function_name): if self.has_function(function_name):
if function_name in self._functions.keys() or None in self._functions.keys(): if function_name in self._functions.keys() or None in self._functions.keys():
await self.call_function( function_calls_llm = [
context=self._context, FunctionCallFromLLM(
tool_call_id=tool_call_id, context=self._context,
function_name=function_name, tool_call_id=tool_call_id,
arguments=arguments, function_name=function_name,
) arguments=arguments,
)
]
await self.run_function_calls(function_calls_llm)
else: else:
raise AWSNovaSonicUnhandledFunctionException( raise AWSNovaSonicUnhandledFunctionException(
f"The LLM tried to call a function named '{function_name}', but there isn't a callback registered for that function." f"The LLM tried to call a function named '{function_name}', but there isn't a callback registered for that function."