AiElementsRenderers
@Immutable
App-wide overrides for how parts render — the extension point for customising the chat without forking Conversation or the message rows. Provide it with CompositionLocalProvider(LocalAiElementsRenderers provides AiElementsRenderers(...)).
AiElementsRenderers(
tools = mapOf("get_weather" to ToolRenderer { part, _ -> WeatherCard(part.output) }),
data = mapOf("chart" to DataRenderer { part -> MyChart(part.data) }),
)Content copied to clipboard
Constructors
Link copied to clipboard
constructor(tools: Map<String, ToolRenderer> = emptyMap(), data: Map<String, DataRenderer> = emptyMap(), tool: (ToolPart) -> ToolRenderer?? = null, codeBlocks: Map<String, CodeBlockRenderer> = emptyMap())
Properties
Link copied to clipboard
by fence language (lower case), e.g. a live preview for jsx fences.
Link copied to clipboard
by data part name (DataPart.name, without data-), including keys of the agent's shared state (DataPart.STATE).
Link copied to clipboard
a catch-all consulted after tools: return null to keep the built-in rendering.
Link copied to clipboard
by tool name (ToolPart.name); checked before the built-in elements.