microsoft / genaiscript

Automatable GenAI Scripting
https://microsoft.github.io/genaiscript/
MIT License
167 stars 31 forks source link

Using runPrompt inside a tool errors with "runPrompt is not defined" #715

Closed alZyad closed 3 days ago

alZyad commented 3 days ago

i get the error "runPrompt is not defined" with this sample code:

defTool("poet", "Writes 4 line poems", {}, async () => {
  const result = await runPrompt(`Write a 4 line poem`, {
    model: "openai:gpt-4o",
    label: "Poem writer",
  });
  return result.text;
});

script({
  description: "Writes poems using the poet tool.",
  model: "gpt-4o",
  maxTokens: 4000,
  tools: ["poet"],
});

$`Write a poem with the poet tool`;

Error stack :

runPrompt is not defined
ReferenceError: runPrompt is not defined
    at Object.impl (file:///Users/alzyad/Dev/myProject/genaisrc/writePoemByTool.genai.mts?tsx-namespace=1726655022826:1:64)
    at runToolCalls (/Users/alzyad/.npm/_npx/d3761ca94263c43f/node_modules/genaiscript/built/genaiscript.cjs:137950:35)
    at processChatMessage (/Users/alzyad/.npm/_npx/d3761ca94263c43f/node_modules/genaiscript/built/genaiscript.cjs:138134:11)
    at executeChatSession (/Users/alzyad/.npm/_npx/d3761ca94263c43f/node_modules/genaiscript/built/genaiscript.cjs:138265:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runTemplate (/Users/alzyad/.npm/_npx/d3761ca94263c43f/node_modules/genaiscript/built/genaiscript.cjs:143643:20)
    at async runScript (/Users/alzyad/.npm/_npx/d3761ca94263c43f/node_modules/genaiscript/built/genaiscript.cjs:144464:14)

Am I doing something wrong ? or is this not working correctly ?

pelikhan commented 3 days ago

looks like a bug, invesigating. which version are you running?

alZyad commented 3 days ago

I updated to the last version and it works correctly now ! the version i had prior was v1.51.1