Skip to content

feat(tools): support middlware in dotprompt export#5223

Merged
MichaelDoyle merged 2 commits intomainfrom
md/create-prompt
May 2, 2026
Merged

feat(tools): support middlware in dotprompt export#5223
MichaelDoyle merged 2 commits intomainfrom
md/create-prompt

Conversation

@MichaelDoyle
Copy link
Copy Markdown
Contributor

@MichaelDoyle MichaelDoyle commented May 1, 2026

Added support for middleware in the createPrompt endpoint for dev-ui (i.e. prompt export).

Made some clean-up/improvements to YAML rendering.

  • Filtering empty objects/arrays
  • Fixed various formatting and encoding issues
  • Better UX around unsupported message/part types

I think this strikes the right balance. Nota bene, Dev UI can always choose to omit these types (and does in some scenarios).

image

Checklist (if applicable):

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for a use field in prompt frontmatter and API requests to handle middleware references. It also includes a new cleanupFrontmatter utility to remove empty or null values from the generated YAML and refactors message part stringification for better maintainability. Feedback was provided to correct the schema type for the use field in CreatePromptRequestSchema, suggesting the use of MiddlewareRefSchema instead of ModelReferenceSchema to maintain consistency across the API.

Comment thread genkit-tools/common/src/types/apis.ts
Comment thread genkit-tools/common/src/types/apis.ts Outdated
@MichaelDoyle MichaelDoyle force-pushed the md/create-prompt branch 4 times, most recently from 135279e to 81c71af Compare May 1, 2026 15:04
@MichaelDoyle
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for middleware in prompt frontmatter and enhances the rendering of messages in Dotprompt templates. Key changes include adding a "use" field to the prompt schemas and refactoring the "fromMessages" utility to gracefully handle unsupported message parts, such as tool requests and responses, by omitting them with descriptive comments. Additionally, a new "cleanupFrontmatter" function ensures cleaner YAML output by removing empty or null values. I have no feedback to provide.

@MichaelDoyle
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces middleware support to prompt frontmatter and refactors the prompt rendering logic to handle unsupported message parts and clean up frontmatter metadata. The reviewer suggested improving the consistency of the anyOmitted flag to account for partially omitted messages and recommended using more idiomatic TypeScript patterns, such as the in operator for property checks and Object.keys() for object iteration.

Comment thread genkit-tools/common/src/utils/prompt.ts Outdated
Comment thread genkit-tools/common/src/utils/prompt.ts
Copy link
Copy Markdown
Contributor

@ssbushi ssbushi left a comment

Choose a reason for hiding this comment

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

LGTM. +1 to gemini-code-review comments.

@MichaelDoyle MichaelDoyle merged commit 36b5e63 into main May 2, 2026
21 checks passed
@MichaelDoyle MichaelDoyle deleted the md/create-prompt branch May 2, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants