feat(plugin-api): export the interactive prompt content models - #2145
Draft
DABH wants to merge 1 commit into
Draft
feat(plugin-api): export the interactive prompt content models#2145DABH wants to merge 1 commit into
DABH wants to merge 1 commit into
Conversation
The plugin-api facade exports the interactive response models and InteractionPrompt, but not the concrete prompt content models behind the HumanPrompt union. Plugin authors building interaction flows construct prompts, not just responses, and today must import them from nat.data_models.interactive in violation of the import-only-from-plugin_api contract. Export HumanPromptText, HumanPromptNotification, HumanPromptBinary, HumanPromptRadio, HumanPromptCheckbox, and HumanPromptDropdown, together with the BinaryHumanPromptOption and MultipleChoiceOption models that binary and multiple-choice prompts and responses embed. Pin the new symbols in the expected-exports test, extend the denied-import patterns, add a consumer-style test constructing every prompt variant through facade-only imports, and document the new surface in docs/source/extend/plugin-api.md. Signed-off-by: David Hyde <DABH@users.noreply.github.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Third-party plugin packages are asked to import plugin-authoring symbols only from the stable
nat.plugin_apifacade (perdocs/source/extend/third-party-plugins.md). PR #2113 exported the interactive response side of that surface:InteractionPrompt,InteractionResponse, and theHumanResponseunion with its concrete response models. The prompt side is still missing: the concrete prompt content models behind theHumanPromptunion are only importable from the implementation modulenat.data_models.interactive.Plugin authors do not only consume responses. HITL middleware hooks, user-input callbacks, and front-end integrations construct prompts: any plugin that calls
Context.get().user_interaction_manager.prompt_user_input(...)first has to build aHumanPromptText(or a notification, binary, radio, checkbox, or dropdown variant). The in-repo HITL examples importHumanPromptTextfromnat.data_models.interactive, and the interactive workflows guide constructs it while pointing readers at that same internal module path — exactly the dependency an external package following the facade contract is told not to take. In addition, the binary and multiple-choice prompt models embed required option models, and those same option models are the field types of the already-exportedHumanResponseBinary,HumanResponseRadio,HumanResponseCheckbox, andHumanResponseDropdown(selected_option), so typed construction of the exported response models also needs them.This change is purely additive and completes the prompt-and-response symmetry of the interactive surface:
HumanPromptText,HumanPromptNotification,HumanPromptBinary,HumanPromptRadio,HumanPromptCheckbox, andHumanPromptDropdown, together with the embedded option modelsBinaryHumanPromptOptionandMultipleChoiceOption, throughnat.plugin_api, and extend__all__.EXPECTED_PLUGIN_API_EXPORTSand extend the denied-import patterns in the plugin-authoring docs test (the existingHumanPromptpattern already covers theHumanPrompt*model imports as substrings, so only the two option-model patterns are new).nat.plugin_apiimports alone and round-trips each one throughInteractionPromptto check the discriminated union resolves the concrete types.docs/source/extend/plugin-api.md, extending the interactive-models bullet and the "HITL middleware" surface-review row (the models follow that row's existing provisional public, trusted plugin status).Deliberately not exported: the OAuth consent prompt variant stays private (it is underscore-prefixed by design), and the abstract bases (
HumanPromptBase,HumanPromptMultipleChoiceBase) stay internal, mirroring howInteractionBaseis not exported; the already-exportedHumanPromptunion covers the "any prompt" typing need.Migrating the in-repo consumers (the two HITL examples and the interactive workflows guide) to the facade imports is deliberately left as a follow-up so this change stays purely additive. No tracking issue exists for this yet; happy to file one — also covering that migration — if the team prefers.
Testing
uv run pytest packages/nvidia_nat_core/tests/nat/test_plugin_api.py— 8 passed (includes the new consumer-style prompt-construction test).uv run pytest packages/nvidia_nat_core/tests/nat/builder packages/nvidia_nat_core/tests/nat/middleware packages/nvidia_nat_core/tests/nat/runtime packages/nvidia_nat_core/tests/nat/data_models— 852 passed.uv run pre-commit run yapf --files <touched files>anduv run pre-commit run ruff-check --files <touched files>— passed.uv run python ci/scripts/copyright.py --verify-apache-v2— passed.uv run python ci/scripts/path_checks.py— passed.uv run vale docs/source/extend/plugin-api.md— 0 errors, 0 warnings, 0 suggestions.By Submitting this PR I confirm: