Skip to content

API Reference parrot.integrations.msagentsdk.cards

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.integrations.msagentsdk.cards

View source

Deterministic Adaptive Card renderer for the Semantic UI Model (FEAT-303).

Pure functions turning a :class:~parrot.integrations.msagentsdk.semantic. SemanticUIResult into Adaptive Card 1.5 JSON (plain dict), plus a total plain-text fallback (:func:render_text) that never raises.

Delegates to the shared :mod:parrot.outputs.cards builder for card construction (AC 1.5, native Table element). This module remains the public API surface for the msagentsdk bridge.

This module must be importable without microsoft_agents.* installed — cards are plain dicts here; wrapping them in SDK Activity objects is the bridge's job (agent.py, TASK-1753).

Alias ActionOpenUrl

Re-exported from parrot.outputs.cards.ActionOpenUrl.

Alias ActionSubmit

Re-exported from parrot.outputs.cards.ActionSubmit.

Alias CardRenderError

Re-exported from parrot.outputs.cards.CardRenderError.

Alias CardSpec

Re-exported from parrot.outputs.cards.CardSpec.

Alias DetailField

Re-exported from parrot.outputs.cards.DetailField.

Alias DetailPayload

Re-exported from parrot.integrations.msagentsdk.semantic.DetailPayload.

Alias DetailSection

Re-exported from parrot.outputs.cards.DetailSection.

Alias MetricEntry

Re-exported from parrot.outputs.cards.MetricEntry.

Alias MetricsPayload

Re-exported from parrot.integrations.msagentsdk.semantic.MetricsPayload.

Alias MetricsSection

Re-exported from parrot.outputs.cards.MetricsSection.

Alias SemanticUIResult

Re-exported from parrot.integrations.msagentsdk.semantic.SemanticUIResult.

Alias StatusPayload

Re-exported from parrot.integrations.msagentsdk.semantic.StatusPayload.

Alias StatusSection

Re-exported from parrot.outputs.cards.StatusSection.

Alias TablePayload

Re-exported from parrot.integrations.msagentsdk.semantic.TablePayload.

Alias TableSection

Re-exported from parrot.outputs.cards.TableSection.

Alias TextSection

Re-exported from parrot.outputs.cards.TextSection.

Alias UIAction

Re-exported from parrot.integrations.msagentsdk.semantic.UIAction.

Alias build_attachment

Re-exported from parrot.outputs.cards.build_attachment.

Function build_card_attachment

Wrap card JSON in the Bot Framework attachment envelope.

build_card_attachment(card: dict) -> dict

Parameter Type Default Description
card dict The Adaptive Card JSON dict (as returned by render_card).

Returns: dict — The attachment envelope dict with contentType "application/vnd.microsoft.card.adaptive" and content set to card.

Function render_card

Render a SemanticUIResult as Adaptive Card 1.5 JSON.

render_card(result: SemanticUIResult, *, max_table_rows: int = 50, max_card_bytes: int = 25000) -> dict

Parameter Type Default Description
result SemanticUIResult The semantic UI result to render.
max_table_rows int 50 Maximum table rows to render before truncating with a "showing N of M" note.
max_card_bytes int 25000 Maximum serialized card size in bytes; exceeding it raises CardRenderError so the caller can fall back to render_text.

Returns: dict — The Adaptive Card as a plain dict (type, version, body, actions).

Raises:

  • CardRenderError — If the result cannot be rendered within limits (unknown result_type at runtime, or the serialized card exceeds max_card_bytes).

Function render_data_card

Build an Adaptive Card with an explanation block and a data table.

Used when the agent response carries structured tabular data (e.g. PandasAgentResponse with a data field) that should be rendered as a native Table element in Teams rather than discarded.

render_data_card(text: str, columns: list[str], rows: list[list], *, max_table_rows: int = 50) -> dict

Parameter Type Default Description
text str Explanation / summary text shown above the table.
columns list[str] Column header names.
rows list[list] Row data as lists of scalars aligned with columns.
max_table_rows int 50 Maximum rows rendered before a truncation note.

Returns: dict — The Adaptive Card as a plain dict.

Function render_text

Render a SemanticUIResult as plain/markdown text.

Total fallback: handles every payload shape (including empty lists and None fields) and never raises.

render_text(result: SemanticUIResult) -> str

Parameter Type Default Description
result SemanticUIResult The semantic UI result to render.

Returns: str — A readable plain/markdown text rendering of result.

Function render_text_card

Wrap a plain/markdown text string in a minimal Adaptive Card 1.5.

Teams renders markdown inside a TextBlock when markdown style is used, giving proper formatting (bold, lists, tables, code blocks) that TextFormatTypes.plain strips away.

render_text_card(text: str) -> dict

Parameter Type Default Description
text str The markdown/plain text to wrap.

Returns: dict — The Adaptive Card as a plain dict (type, version, body).

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally