Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving the dotprompt package into a plugin #80

Merged
merged 1 commit into from
May 9, 2024
Merged

Conversation

maxl0rd
Copy link
Contributor

@maxl0rd maxl0rd commented May 8, 2024

  • Dotprompt should now be configured as a plugin but has fallback behavior to look in a default prompts folder so no existing code should break.
  • Async init used to load the entire prompts folder even if prompts are not explicitly referenced in code.

@maxl0rd maxl0rd force-pushed the dotprompt_plugin branch from f4ba7e5 to b9df14f Compare May 8, 2024 20:54
@maxl0rd maxl0rd requested a review from mbleigh May 8, 2024 20:58
@maxl0rd maxl0rd force-pushed the dotprompt_plugin branch from b9df14f to c059619 Compare May 8, 2024 21:14
js/plugins/dotprompt/src/registry.ts Outdated Show resolved Hide resolved
js/plugins/dotprompt/src/index.ts Outdated Show resolved Hide resolved
js/plugins/dotprompt/src/index.ts Outdated Show resolved Hide resolved
@maxl0rd maxl0rd force-pushed the dotprompt_plugin branch 3 times, most recently from 72e3c71 to 1815bb6 Compare May 9, 2024 13:28
): Promise<void> {
const promptsPath = resolve(dir);
return new Promise<void>((resolve, reject) => {
readdir(
Copy link
Collaborator

@pavelgj pavelgj May 9, 2024

Choose a reason for hiding this comment

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

Optional: there's a readdirSync variant... that you can use to avoid all this boilerplate with Promises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked at that, but it was slightly harder to resolve the initialization at the right place.

@MichaelDoyle
Copy link
Member

MichaelDoyle commented May 9, 2024

Any samples that need to get updated based on this new plugin? I see the dev-ui one, for some reason I was expecting a few more.

- Dotprompt should now be configured as a plugin
  but has fallback behavior to look in a default prompts folder
  so no existing code should break.
- Async init used to load the entire prompts folder even if
  prompts are not explicitly referenced in code.
@maxl0rd maxl0rd force-pushed the dotprompt_plugin branch from 1815bb6 to 9df4ddd Compare May 9, 2024 14:13
@maxl0rd
Copy link
Contributor Author

maxl0rd commented May 9, 2024

One clarification: as long as the prompts are in the default location, the library has exactly the same behavior as before even when the plugin isn't initialized due to a friendly fallback behavior. But for correctness, you should begin adding the plugin to genkit.conf

@maxl0rd maxl0rd merged commit f2c3fd3 into main May 9, 2024
4 checks passed
@maxl0rd maxl0rd deleted the dotprompt_plugin branch May 9, 2024 14:21
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.

4 participants