chore(py): flatten prompt opts to kwargs#5062
Merged
huangjeff5 merged 4 commits intomainfrom Apr 6, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the ExecutablePrompt API to transition from a single opts dictionary to using keyword arguments for generation options, leveraging Unpack[PromptGenerateOptions] for type safety. The implementation introduces internal helper methods _call_impl and _render_impl to consolidate logic, along with a _coerce_prompt_opts utility that validates input and provides explicit error messages if the deprecated opts parameter is used. Corresponding test cases have been updated and expanded to verify the new keyword-based interface and the removal of the legacy parameter. I have no feedback to provide.
apascal07
approved these changes
Apr 6, 2026
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.
Previously, callers had to bundle generation options into a single
optsdict:This PR flattens those options into keyword arguments using
Unpack[PromptGenerateOptions]:This way we still have a shared type for the stream/non-streaming path, but the syntax is more pythonic (using kwargs instead of an opts dict), and all the various prompt options should surface correctly inline in the IDE (as opposed to being hidden behind an opaque type where you have to further inspect to see the real fields).