gemini_adapter
Gemini LLM adapter for Pipecat.
- class pipecat.adapters.services.gemini_adapter.GeminiLLMInvocationParams[source]
Bases:
TypedDictContext-based parameters for invoking Gemini LLM.
- system_instruction: str | None
- messages: list[Content]
- tools: list[Any] | NotGiven
- class pipecat.adapters.services.gemini_adapter.GeminiLLMAdapter[source]
Bases:
BaseLLMAdapter[GeminiLLMInvocationParams]Gemini-specific adapter for Pipecat.
Handles: - Extracting parameters for Gemini’s API from a universal LLM context - Converting Pipecat’s standardized tools schema to Gemini’s function-calling format. - Extracting and sanitizing messages from the LLM context for logging with Gemini.
- property id_for_llm_specific_messages: str
Get the identifier used in LLMSpecificMessage instances for Google.
- get_llm_invocation_params(context: LLMContext, *, system_instruction: str | None = None) GeminiLLMInvocationParams[source]
Get Gemini-specific LLM invocation parameters from a universal LLM context.
- Parameters:
context – The LLM context containing messages, tools, etc.
system_instruction – Optional system instruction from service settings or
run_inference.
- Returns:
Dictionary of parameters for Gemini’s API.
- to_provider_tools_format(tools_schema: ToolsSchema) list[dict[str, Any]][source]
Convert tool schemas to Gemini’s function-calling format.
- Parameters:
tools_schema – The tools schema containing standard and custom tool definitions.
- Returns:
List of tool definitions formatted for Gemini’s function-calling API. Includes both converted standard tools and any custom Gemini-specific tools.
- get_messages_for_logging(context: LLMContext) list[dict[str, Any]][source]
Get messages from a universal LLM context in a format ready for logging about Gemini.
Removes or truncates sensitive data like image content for safe logging.
- Parameters:
context – The LLM context containing messages.
- Returns:
List of messages in a format ready for logging about Gemini.
- class ConvertedMessages(messages: list[Content], system_instruction: str | None = None)[source]
Bases:
objectContainer for Google-formatted messages converted from universal context.
- messages: list[Content]
- system_instruction: str | None = None
- class MessageConversionResult(content: Content | None = None, tool_call_id_to_name_mapping: dict[str, str]=<factory>)[source]
Bases:
objectResult of converting a single universal context message to Google format.
Contains a Google Content object and a tool call ID to name mapping for any tool calls discovered in the message.
- content: Content | None = None
- tool_call_id_to_name_mapping: dict[str, str]