GenkitG
Genkit•14mo ago•
3 replies
verbal-lime

what do you think about public this

what do you think about public this registeredFlows prop? or something like optional flows prop on ai.startFlowServer, ex: ai.startFlowServer({flows?:[...ai.registeredFlows]})

We are registering flows by reading sub folders, so we don't want to imports a ton of flows again.

/src | /lib
  '- /flows/
       '- /users/
          '- flows.ts|.js <-- this point `export {userListFlow} from './list/userListFlow'`
          '- /list/
              '- userListFlow.ts|.js

const allFlowsDir = path.resolve(devEnv ? "src" : "lib", "flows");
fs.readdirSync(allFlowsDir).forEach((name) => {
    const flowDir = path.join(allFlowsDir, name);
    logInfo("loading flow:", flowDir);
    try {
        require(path.join(flowDir, "flows")); // require flows.ts|.js
        logSuccess(`loaded flow: ${flowDir}`);
    } catch (e:any) {
        console.log((e as Error).stack)
    }
});
Screenshot_2024-11-18_at_16.30.19.png
Was this page helpful?