From f457d007608b173dc0b8d30da8dcc8d04d5cfffd Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Tue, 26 Aug 2025 11:13:24 -0400 Subject: [PATCH] Update types for tools in `LLMSetToolsFrame` and `LLMContextAggregator.set_tools()`, for two reason: 1. `ToolsSchema` has been supported in `LLMSetToolsFrame` for a while but wasn't properly reflected in these type hints 2. The new universal `LLMContext` expects tools to be either a `ToolsSchema` or `NOT_GIVEN`. --- src/pipecat/frames/frames.py | 5 +++-- src/pipecat/processors/aggregators/llm_response_universal.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index 01c840a71..139857297 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -27,6 +27,7 @@ from typing import ( Tuple, ) +from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.audio.interruptions.base_interruption_strategy import BaseInterruptionStrategy from pipecat.audio.turn.smart_turn.base_smart_turn import SmartTurnParams from pipecat.audio.vad.vad_analyzer import VADParams @@ -36,7 +37,7 @@ from pipecat.utils.time import nanoseconds_to_str from pipecat.utils.utils import obj_count, obj_id if TYPE_CHECKING: - from pipecat.processors.aggregators.llm_context import LLMContext + from pipecat.processors.aggregators.llm_context import LLMContext, NotGiven from pipecat.processors.frame_processor import FrameProcessor @@ -576,7 +577,7 @@ class LLMSetToolsFrame(DataFrame): tools: List of tool/function definitions for the LLM. """ - tools: List[dict] + tools: List[dict] | ToolsSchema | "NotGiven" @dataclass diff --git a/src/pipecat/processors/aggregators/llm_response_universal.py b/src/pipecat/processors/aggregators/llm_response_universal.py index e84194b78..ad4eced64 100644 --- a/src/pipecat/processors/aggregators/llm_response_universal.py +++ b/src/pipecat/processors/aggregators/llm_response_universal.py @@ -18,6 +18,7 @@ from typing import Any, Dict, List, Literal, Optional, Set from loguru import logger +from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.audio.interruptions.base_interruption_strategy import BaseInterruptionStrategy from pipecat.audio.turn.smart_turn.base_smart_turn import SmartTurnParams from pipecat.audio.vad.vad_analyzer import VADParams @@ -57,6 +58,7 @@ from pipecat.processors.aggregators.llm_context import ( LLMContext, LLMContextMessage, LLMSpecificMessage, + NotGiven, ) from pipecat.processors.aggregators.llm_response import ( LLMAssistantAggregatorParams, @@ -148,7 +150,7 @@ class LLMContextAggregator(FrameProcessor): """ self._context.set_messages(messages) - def set_tools(self, tools: List): + def set_tools(self, tools: ToolsSchema | NotGiven): """Set tools in the context. Args: