diff --git a/examples/foundational/37-mem0.py b/examples/foundational/37-mem0.py index 57be73df4..436f0a452 100644 --- a/examples/foundational/37-mem0.py +++ b/examples/foundational/37-mem0.py @@ -55,7 +55,8 @@ from pipecat.frames.frames import LLMRunFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask -from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext +from pipecat.processors.aggregators.llm_context import LLMContext +from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair from pipecat.processors.frameworks.rtvi import RTVIConfig, RTVIObserver, RTVIProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport @@ -244,8 +245,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Set up conversation context and management # The context_aggregator will automatically collect conversation context - context = OpenAILLMContext(messages) - context_aggregator = llm.create_context_aggregator(context) + context = LLMContext(messages) + context_aggregator = LLMContextAggregatorPair(context) rtvi = RTVIProcessor(config=RTVIConfig(config=[])) pipeline = Pipeline( diff --git a/src/pipecat/services/mem0/memory.py b/src/pipecat/services/mem0/memory.py index b134f5162..a80398728 100644 --- a/src/pipecat/services/mem0/memory.py +++ b/src/pipecat/services/mem0/memory.py @@ -16,7 +16,8 @@ from typing import Any, Dict, List, Optional from loguru import logger from pydantic import BaseModel, Field -from pipecat.frames.frames import ErrorFrame, Frame, LLMMessagesFrame +from pipecat.frames.frames import ErrorFrame, Frame, LLMContextFrame, LLMMessagesFrame +from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.openai_llm_context import ( OpenAILLMContext, OpenAILLMContextFrame, @@ -180,11 +181,11 @@ class Mem0MemoryService(FrameProcessor): logger.error(f"Error retrieving memories from Mem0: {e}") return [] - def _enhance_context_with_memories(self, context: OpenAILLMContext, query: str): + def _enhance_context_with_memories(self, context: LLMContext | OpenAILLMContext, query: str): """Enhance the LLM context with relevant memories. Args: - context: The OpenAILLMContext to enhance with memory information. + context: The LLM context to enhance with memory information. query: The query to search for relevant memories. """ # Skip if this is the same query we just processed @@ -222,11 +223,11 @@ class Mem0MemoryService(FrameProcessor): context = None messages = None - if isinstance(frame, OpenAILLMContextFrame): + if isinstance(frame, (LLMContextFrame, OpenAILLMContextFrame)): context = frame.context elif isinstance(frame, LLMMessagesFrame): messages = frame.messages - context = OpenAILLMContext.from_messages(messages) + context = LLMContext(messages) if context: try: