genkit icon indicating copy to clipboard operation
genkit copied to clipboard

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

Open ssbushi opened this issue 1 year ago • 3 comments

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

  • Add "type": "module" to testapps/rag/pacakge.json
  • Build and run with genkit start
  • ~Remove genkitEvals plugin in testapps/rag/src/index.ts if #158 is not merged yet.~ (This is now merged)

Expected behavior Genkit starts without errors

Runtime

  • OS: Linux

Node version

  • v20.11.1

ssbushi avatar May 14 '24 16:05 ssbushi

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.

maxl0rd avatar May 14 '24 19:05 maxl0rd

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.

ssbushi avatar May 15 '24 16:05 ssbushi

Having the same here!

davidoort avatar May 18 '24 11:05 davidoort

Resolved in 952b3054

maxl0rd avatar May 28 '24 14:05 maxl0rd