const getModel = Effect.sync(() => {
return USE.load();
}).pipe(Effect.cached); // expensive process
export const handler: Handler = (event: { query: string }, _: Context) =>
Effect.gen(function* () {
const cached = yield* getModel;
return yield* cached.pipe(Effect.map((model) => model.embed(event.query)));
}).pipe(Effect.runPromise);
const getModel = Effect.sync(() => {
return USE.load();
}).pipe(Effect.cached); // expensive process
export const handler: Handler = (event: { query: string }, _: Context) =>
Effect.gen(function* () {
const cached = yield* getModel;
return yield* cached.pipe(Effect.map((model) => model.embed(event.query)));
}).pipe(Effect.runPromise);