examples: update Strands Agents with universal context and add evals

This commit is contained in:
Aleix Conchillo Flaqué
2025-09-23 11:35:03 -07:00
parent 667569ef47
commit 620b1f785c
3 changed files with 28 additions and 14 deletions

View File

@@ -10,12 +10,12 @@ from loguru import logger
from pipecat.frames.frames import (
Frame,
LLMContextFrame,
LLMFullResponseEndFrame,
LLMFullResponseStartFrame,
LLMTextFrame,
)
from pipecat.metrics.metrics import LLMTokenUsage
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContextFrame
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
try:
@@ -71,9 +71,11 @@ class StrandsAgentsProcessor(FrameProcessor):
direction: The direction of frame flow in the pipeline.
"""
await super().process_frame(frame, direction)
if isinstance(frame, OpenAILLMContextFrame):
text = frame.context.messages[-1]["content"]
await self._ainvoke(str(text).strip())
if isinstance(frame, LLMContextFrame):
messages = frame.context.get_messages()
if messages:
last_message = messages[-1]
await self._ainvoke(str(last_message["content"]).strip())
else:
await self.push_frame(frame, direction)