Skip to content

Conversation

@jiwon-oai
Copy link
Collaborator

@jiwon-oai jiwon-oai commented Nov 21, 2025

  • WidgetTemplate lets you build widgets server-side using .widget files downloaded from https://widgets.chatkit.studio.
  • build() returns a dynamic widget type (that does not specify fields and is a parsed version of the widget built from the file/definition)

This changeset will be included in the next minor version bump for the following mildly backwards-incompatible parts:

  • jinja2 is added as a dependency
  • There will now be deprecation warnings when instantiating the named widget / action classes (e.g. Card, ListView, ActionConfig)

Testing

  • Added unit tests for WidgetTemplate and DynamicWidgetRoot
  • Tested against chatkit studio and verified that (1) existing direct usage of Card, ListWidget, etc. are unchanged; (2) WidgetTemplate.from_file works as expected at runtime

env = Environment(undefined=StrictUndefined)

direct_usage_of_named_widget_types_deprecated = deprecated(
"Direct usage of named widget classes are deprecated; use WidgetTemplate to build widgets from .widget files/definitions instead."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should link to widget studio probably (and docs ideally)

"""

model_config = ConfigDict(extra="allow")
children: list["DynamicWidgetComponent"] | None = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transition takes DynamicWidgetComponent not list[DynamicWidgetComponent]

Suggested change
children: list["DynamicWidgetComponent"] | None = None
children: "DynamicWidgetComponent" | "list[DynamicWidgetComponent]" | None = None

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good catch!!

@jiwon-oai jiwon-oai changed the title WIP WidgetTemplate Add WidgetTemplate with dynamic widget types; add deprecation warning to named widget & action classes Nov 21, 2025
@jiwon-oai jiwon-oai marked this pull request as ready for review November 21, 2025 22:48
@jiwon-oai jiwon-oai added this pull request to the merge queue Nov 24, 2025
Merged via the queue into main with commit 31f0778 Nov 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants