Update GeminiLiveLLMService to push Thought frames when thought content is returned
This commit is contained in:
@@ -44,6 +44,9 @@ from pipecat.frames.frames import (
|
|||||||
LLMMessagesAppendFrame,
|
LLMMessagesAppendFrame,
|
||||||
LLMSetToolsFrame,
|
LLMSetToolsFrame,
|
||||||
LLMTextFrame,
|
LLMTextFrame,
|
||||||
|
LLMThoughtEndFrame,
|
||||||
|
LLMThoughtStartFrame,
|
||||||
|
LLMThoughtTextFrame,
|
||||||
LLMUpdateSettingsFrame,
|
LLMUpdateSettingsFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
TranscriptionFrame,
|
TranscriptionFrame,
|
||||||
@@ -1455,10 +1458,19 @@ class GeminiLiveLLMService(LLMService):
|
|||||||
await self._set_bot_is_responding(True)
|
await self._set_bot_is_responding(True)
|
||||||
await self.push_frame(LLMFullResponseStartFrame())
|
await self.push_frame(LLMFullResponseStartFrame())
|
||||||
|
|
||||||
self._bot_text_buffer += text
|
# Check if this is a thought
|
||||||
self._search_result_buffer += text # Also accumulate for grounding
|
if part.thought:
|
||||||
frame = LLMTextFrame(text=text)
|
# Gemini Live emits fully-formed thoughts rather than chunks,
|
||||||
await self.push_frame(frame)
|
# so bracket each thought in start/end frames
|
||||||
|
await self.push_frame(LLMThoughtStartFrame())
|
||||||
|
await self.push_frame(LLMThoughtTextFrame(text))
|
||||||
|
await self.push_frame(LLMThoughtEndFrame(signature=part.thought_signature))
|
||||||
|
else:
|
||||||
|
# Regular text response
|
||||||
|
self._bot_text_buffer += text
|
||||||
|
self._search_result_buffer += text # Also accumulate for grounding
|
||||||
|
frame = LLMTextFrame(text=text)
|
||||||
|
await self.push_frame(frame)
|
||||||
|
|
||||||
# Check for grounding metadata in server content
|
# Check for grounding metadata in server content
|
||||||
if msg.server_content and msg.server_content.grounding_metadata:
|
if msg.server_content and msg.server_content.grounding_metadata:
|
||||||
|
|||||||
Reference in New Issue
Block a user