prompt-compose
Version:
A JS library for building and managing GPT prompts documents.
4 lines (3 loc) • 1.21 kB
JavaScript
let e=()=>()=>"",t=(t=e())=>(r=e())=>{let a=t,n=r;for(;"function"==typeof a;)a=a();for(;"function"==typeof n;)n=n();return`${a}${n}`},r={CONFIG:{dividerType:" ",dividerRepeat:5,dividerBefore:"\n",dividerAfter:"\n",tabType:" ",tabRepeat:4,instructionSpacing:"\n"}};function a(){return r.CONFIG}function n(e){r.CONFIG={...r.CONFIG,...e}}let i=()=>{let e=a(),r=e.dividerType,n=e.dividerRepeat;return t(`${e.dividerBefore}${r.repeat(n)}${e.dividerAfter}`)},$=r=>(n=e())=>{let i=a(),$=i.tabType.repeat(i.tabRepeat),b=t(r)(n);return(b=$+b).replaceAll("\n",`
${$}`)},b=(...e)=>r=>{let a=t()(r);return e.reduceRight((e,r)=>t(r)(e),a)},d=(e,r)=>b(t(e),t(`:${a().instructionSpacing}`),$(t(r)));function o(e){return d("Answer should be in a valid JSON, use the following structure",`ResponseJSON: ${JSON.stringify(e)}`)}let c=(e,...r)=>{let a;switch(r.length){case 0:a=t("");break;case 1:a=r[0];break;default:{let e=[];r.forEach(t=>{e.push(t),e.push(i())}),e.pop(),a=b(...e)}}return b(d(e,a),i())};function f(e){return c(t("System"),e)}export{i as Divider,o as Format,d as Instruction,c as Section,t as Statement,e as None,f as System,$ as Tabs,b as compose,a as getConfig,n as setConfig};
//# sourceMappingURL=main.mjs.map