firebase / genkit

An open source framework for building AI-powered apps with familiar code-centric patterns. Genkit makes it easy to integrate, test, and deploy sophisticated AI features to Firebase or Google Cloud.
Apache License 2.0
607 stars 74 forks source link

[JS] @genkit-ai/dotprompt package is not ESM compatible #160

Closed ssbushi closed 3 months ago

ssbushi commented 4 months ago

Describe the bug Trying to run the rag testapp as ESM module is throwing an error related to dotprompt

/usr/local/google/home/ssbushi/OpenSource/genkit/js/core/lib/action.js:156
    throw new Error(
          ^

Error: Unable to find plugin name used in the action name: dotprompt
    at validatePluginName (/usr/local/google/home/ssbushi/OpenSource/genkit/js/core/lib/action.js:156:11)
    at validateActionName (/usr/local/google/home/ssbushi/OpenSource/genkit/js/core/lib/action.js:149:5)
    at action (/usr/local/google/home/ssbushi/OpenSource/genkit/js/core/lib/action.js:90:56)
    at defineAction (/usr/local/google/home/ssbushi/OpenSource/genkit/js/core/lib/action.js:169:15)
    at definePrompt (/usr/local/google/home/ssbushi/OpenSource/genkit/js/ai/lib/prompt.js:76:42)
    at Dotprompt.define (/usr/local/google/home/ssbushi/OpenSource/genkit/js/plugins/dotprompt/lib/prompt.js:165:32)
    at defineDotprompt (/usr/local/google/home/ssbushi/OpenSource/genkit/js/plugins/dotprompt/lib/prompt.js:215:10)
    at file:///usr/local/google/home/ssbushi/OpenSource/genkit/js/testapps/rag/lib/prompt.js:19:32
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)

To Reproduce

Expected behavior Genkit starts without errors

Runtime

Node version

maxl0rd commented 4 months ago

This error is the error you get when you call definePrompt but the dotprompt plugin has not been installed. I tried building the dotprompt extension as an ESM module and it seems to work fine. I don't think this is an issue with ESM compatibility.

ssbushi commented 4 months ago

The issue is with the way dotprompt is compiled in ESM mode I believe (The sample installs the plugin correctly).

Based on conversations with @pavelgj, a possible fix is to make it so that defineDotprompt does not depend on dotprompt plugin.

davidoort commented 3 months ago

Having the same here!

maxl0rd commented 3 months ago

Resolved in 952b3054