Adapters
LLM adapter for normalizing function and message formats.
This module provides the LLMAdapter class that normalizes interactions between the flow manager and Pipecat’s universal LLMContext. It handles:
Function name extraction from FlowsFunctionSchema
Function formatting into ToolsSchema for LLMSetToolsFrame
Summary message formatting
Summary generation via out-of-band LLM inference
- class pipecat_flows.adapters.LLMAdapter[source]
Bases:
objectAdapter for normalizing function and message formats.
Normalizes interactions between the flow manager and Pipecat’s universal LLMContext. Functions must be provided as FlowsFunctionSchema or FunctionSchema objects.
- format_functions(functions: list[FunctionSchema | FlowsFunctionSchema]) ToolsSchema | NotGiven[source]
Format functions into a ToolsSchema for use in LLMSetToolsFrame.
- Parameters:
functions – List of function definitions (schema objects).
- Returns:
ToolsSchema containing the functions, or NOT_GIVEN if no functions.
- format_summary_message(summary: str) dict[source]
Format a summary as a developer message.
Summary messages use the LLMContextMessage format (OpenAI-style), as summarization triggers an LLMMessagesUpdateFrame.
- Parameters:
summary – The generated summary text.
- Returns:
A developer message containing the summary.
- async generate_summary(llm: Any, summary_prompt: str, context: LLMContext) str | None[source]
Generate a summary by running a direct one-shot, out-of-band inference with the LLM.
- Parameters:
llm – LLM service instance containing client/credentials.
summary_prompt – Prompt text to guide summary generation.
context – Context object containing conversation history for the summary.
- Returns:
Generated summary text, or None if generation fails.