Merge pull request #1404 from pipecat-ai/aleix/gemini-push-frame-fixes
GeminiMultimodalLiveLLMService: fix duplicated messages in context
This commit is contained in:
@@ -149,6 +149,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed a `GeminiMultimodalLiveLLMService` issue that was causing messages to be
|
||||||
|
duplicated in the context when pushing `LLMMessagesAppendFrame` frames.
|
||||||
|
|
||||||
- Fixed an issue with `SegmentedSTTService` based services
|
- Fixed an issue with `SegmentedSTTService` based services
|
||||||
(e.g. `GroqSTTService`) that was not allow audio to pass-through downstream.
|
(e.g. `GroqSTTService`) that was not allow audio to pass-through downstream.
|
||||||
|
|
||||||
|
|||||||
@@ -341,10 +341,8 @@ class GeminiMultimodalLiveLLMService(LLMService):
|
|||||||
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
||||||
await super().process_frame(frame, direction)
|
await super().process_frame(frame, direction)
|
||||||
|
|
||||||
# logger.debug(f"Processing frame: {frame}")
|
|
||||||
|
|
||||||
if isinstance(frame, TranscriptionFrame):
|
if isinstance(frame, TranscriptionFrame):
|
||||||
pass
|
await self.push_frame(frame, direction)
|
||||||
elif isinstance(frame, OpenAILLMContextFrame):
|
elif isinstance(frame, OpenAILLMContextFrame):
|
||||||
context: GeminiMultimodalLiveContext = GeminiMultimodalLiveContext.upgrade(
|
context: GeminiMultimodalLiveContext = GeminiMultimodalLiveContext.upgrade(
|
||||||
frame.context
|
frame.context
|
||||||
@@ -361,31 +359,35 @@ class GeminiMultimodalLiveLLMService(LLMService):
|
|||||||
# Support just one tool call per context frame for now
|
# Support just one tool call per context frame for now
|
||||||
tool_result_message = context.messages[-1]
|
tool_result_message = context.messages[-1]
|
||||||
await self._tool_result(tool_result_message)
|
await self._tool_result(tool_result_message)
|
||||||
|
|
||||||
elif isinstance(frame, InputAudioRawFrame):
|
elif isinstance(frame, InputAudioRawFrame):
|
||||||
await self._send_user_audio(frame)
|
await self._send_user_audio(frame)
|
||||||
|
await self.push_frame(frame, direction)
|
||||||
elif isinstance(frame, InputImageRawFrame):
|
elif isinstance(frame, InputImageRawFrame):
|
||||||
await self._send_user_video(frame)
|
await self._send_user_video(frame)
|
||||||
|
await self.push_frame(frame, direction)
|
||||||
elif isinstance(frame, StartInterruptionFrame):
|
elif isinstance(frame, StartInterruptionFrame):
|
||||||
await self._handle_interruption()
|
await self._handle_interruption()
|
||||||
|
await self.push_frame(frame, direction)
|
||||||
elif isinstance(frame, UserStartedSpeakingFrame):
|
elif isinstance(frame, UserStartedSpeakingFrame):
|
||||||
await self._handle_user_started_speaking(frame)
|
await self._handle_user_started_speaking(frame)
|
||||||
|
await self.push_frame(frame, direction)
|
||||||
elif isinstance(frame, UserStoppedSpeakingFrame):
|
elif isinstance(frame, UserStoppedSpeakingFrame):
|
||||||
await self._handle_user_stopped_speaking(frame)
|
await self._handle_user_stopped_speaking(frame)
|
||||||
|
await self.push_frame(frame, direction)
|
||||||
elif isinstance(frame, BotStartedSpeakingFrame):
|
elif isinstance(frame, BotStartedSpeakingFrame):
|
||||||
# Ignore this frame. Use the serverContent API message instead
|
# Ignore this frame. Use the serverContent API message instead
|
||||||
pass
|
await self.push_frame(frame, direction)
|
||||||
elif isinstance(frame, BotStoppedSpeakingFrame):
|
elif isinstance(frame, BotStoppedSpeakingFrame):
|
||||||
# ignore this frame. Use the serverContent.turnComplete API message
|
# ignore this frame. Use the serverContent.turnComplete API message
|
||||||
pass
|
await self.push_frame(frame, direction)
|
||||||
elif isinstance(frame, LLMMessagesAppendFrame):
|
elif isinstance(frame, LLMMessagesAppendFrame):
|
||||||
await self._create_single_response(frame.messages)
|
await self._create_single_response(frame.messages)
|
||||||
elif isinstance(frame, LLMUpdateSettingsFrame):
|
elif isinstance(frame, LLMUpdateSettingsFrame):
|
||||||
await self._update_settings(frame.settings)
|
await self._update_settings(frame.settings)
|
||||||
elif isinstance(frame, LLMSetToolsFrame):
|
elif isinstance(frame, LLMSetToolsFrame):
|
||||||
await self._update_settings()
|
await self._update_settings()
|
||||||
|
else:
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
|
|
||||||
#
|
#
|
||||||
# websocket communication
|
# websocket communication
|
||||||
|
|||||||
Reference in New Issue
Block a user