Merge pull request #2715 from pipecat-ai/pk/langchain-processor-support-univeral-context

Add support for universal `LLMContext` to `LangchainProcessor`
This commit is contained in:
kompfner
2025-09-23 11:54:44 -04:00
committed by GitHub
2 changed files with 14 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ from loguru import logger
from pipecat.frames.frames import (
Frame,
LLMContextFrame,
LLMFullResponseEndFrame,
LLMFullResponseStartFrame,
TextFrame,
@@ -64,11 +65,16 @@ class LangchainProcessor(FrameProcessor):
"""
await super().process_frame(frame, direction)
if isinstance(frame, OpenAILLMContextFrame):
if isinstance(frame, (LLMContextFrame, OpenAILLMContextFrame)):
# Messages are accumulated on the context as a list of messages.
# The last one by the human is the one we want to send to the LLM.
logger.debug(f"Got transcription frame {frame}")
text: str = frame.context.messages[-1]["content"]
messages = (
frame.context.messages
if isinstance(frame, OpenAILLMContextFrame)
else frame.context.get_messages()
)
text: str = messages[-1]["content"]
await self._ainvoke(text.strip())
else: