@miso.ai/doggoganger 0.9.0-beta.12 → 0.9.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).doggoganger=e()}(this,(function(){"use strict";function t(t,e){return null!=e&&e>t?t+Math.floor(Math.random()*(e-t)):t}function e(){return Math.random().toString(36).substring(2,10)}function n(t){return`https://picsum.photos/seed/${Math.floor(1e3*Math.random())}/${Array.isArray(t)?t.length>1?`${t[0]}/${t[1]}`:""+t[0]:""+t}`}function r(t,e){return void 0!==e?Math.ceil(t*e):t}var o=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","curabitur","vel","hendrerit","libero","eleifend","blandit","nunc","ornare","odio","ut","orci","gravida","imperdiet","nullam","purus","lacinia","a","pretium","quis","congue","praesent","sagittis","laoreet","auctor","mauris","non","velit","eros","dictum","proin","accumsan","sapien","nec","massa","volutpat","venenatis","sed","eu","molestie","lacus","quisque","porttitor","ligula","dui","mollis","tempus","at","magna","vestibulum","turpis","ac","diam","tincidunt","id","condimentum","enim","sodales","in","hac","habitasse","platea","dictumst","aenean","neque","fusce","augue","leo","eget","semper","mattis","tortor","scelerisque","nulla","interdum","tellus","malesuada","rhoncus","porta","sem","aliquet","et","nam","suspendisse","potenti","vivamus","luctus","fringilla","erat","donec","justo","vehicula","ultricies","varius","ante","primis","faucibus","ultrices","posuere","cubilia","curae","etiam","cursus","aliquam","quam","dapibus","nisl","feugiat","egestas","class","aptent","taciti","sociosqu","ad","litora","torquent","per","conubia","nostra","inceptos","himenaeos","phasellus","nibh","pulvinar","vitae","urna","iaculis","lobortis","nisi","viverra","arcu","morbi","pellentesque","metus","commodo","ut","facilisis","felis","tristique","ullamcorper","placerat","aenean","convallis","sollicitudin","integer","rutrum","duis","est","etiam","bibendum","donec","pharetra","vulputate","maecenas","mi","fermentum","consequat","suscipit","aliquam","habitant","senectus","netus","fames","quisque","euismod","curabitur","lectus","elementum","tempor","risus","cras"];function s({decorates:e=[],output:n="string",size:r,min:s,max:i,...u}={}){let c=function(e=[5,10]){const n="number"==typeof e?e:t(...e);return function*(t){let e=0;for(let r of t){if(e++>=n)break;yield r}}}(r||[s,i])(function*({words:t=o,fixedStarts:e=0}={}){const n=t.length;for(let r=0;;r++)yield t[e>r?r:Math.floor(Math.random()*n)]}(u));for(const t of e)c=a(t)(c);return a(n)(c)}const i={string:function({separator:t=" "}={}){return e=>[...e].join(t)},array:function(){return t=>[...t]},title:function({}={}){return function*(t){for(let e of t)yield u(e)}},description:function({wordsPerSentence:t={avg:24,std:5,min:1}}={}){return function*(e){let n,r=0;for(let o of e)n&&(yield n),n=o,0===r&&(n=u(n),r=c(t)),0==--r&&(n+=".");n&&(n.endsWith(".")||(n+="."),yield n)}},multiline:function({wordsPerLine:t={avg:10,std:3,min:1}}={}){return e=>{let n=c(t),r="";for(let o of e)r&&(0==n--?(r+="\n",n=c(t)):r+=" "),r+=o;return r}}};function a(t){return"string"==typeof t?i[t]():t}function u(t){return t[0].toUpperCase()+t.substring(1)}function c(t){if("number"==typeof t)return Math.round(e);let{avg:e,std:n,min:r,max:o}=t;void 0===n&&(n=e/4);let s=(l()+l()+l())*n+e;return void 0!==r&&(s=Math.max(r,s)),void 0!==o&&(s=Math.min(o,s)),Math.round(s)}function l(){return 2*Math.random()-1}const f="// module\nimport { a, b } from './module';\nimport * as module from './module';\nimport module from './module';\nexport default module;\nexport const a = 0;\nexport * from './module';\nexport * as module from './module';\n\n// variables\nlet a = 10;\nconst b = 20;\n\n// function declaration\nfunction sum(x, y) {\n return x + y;\n}\n\n// generator function\nfunction* iterator() {\n yield 0;\n yield 1;\n}\n\n// arrow function\nconst multiply = (x, y) => x * y;\n\n// class\nclass Person {\n constructor(name, age) {\n this.name = name;\n this.age = age;\n }\n\n greet() {\n console.log('Hello, my name is Miso.');\n }\n}\n\n// primitive\nconst str = 'Hello, world!';\nconst num = 10.99;\n\n// object\nconst person = new Person('John', 30);\nperson.greet();\n\n// object literal\nconst object = {\n name: 'John',\n [x]: 10,\n ...props,\n};\n\n// array literal\nconst arr = [1, 2, 3, 4, 5, ...props];\n\n// regexp literal\nconst regexp = /\\w+/g;\n\n// operators\nconst sum = a + b;\nconst product = a * b;\nconst negation = -a;\nconst max = a > b ? a : b;\n\n// flow control\nlet i = 9;\nfor (const n of arr) {\n if (n > i) {\n console.log(n);\n }\n i++;\n}\n\n// async/await\n(async () => {\n const result = await asyncFunction();\n})();\n\n// try/catch\ntry {\n} catch (e) {\n}\n\n// destructuring\nconst { name, age, ...rest } = person;\nconst [ x, y, ...rest ] = arr;\n\n// template literals\nconsole.log(`The sum of ${a} and ${b} is ${sum(a, b)}.`);";var d=Object.freeze({__proto__:null,javascript:function(){return f},js:function(){return f}});function m({features:e,blocks:r=[8,12],sampling:o=1}={}){let i=[];return[i,e]=function(t=[]){const e=new Set,n=[];for(const r of t)if(r.startsWith("lang-")){let t=r.slice(5);"javascript"===t&&(t="js"),e.add(t)}else n.push(r);return[[...e],n]}(e),function(t,e){const n=[];for(const r of t)1>e&&Math.random()>=e||n.push(r());return n}([()=>p({features:e}),()=>g({features:e}),...i.map((t=>()=>h({lang:t,features:e}))),...i.length?[]:[()=>h({features:e})],()=>g({features:e}),()=>function({columns:e=[2,4],rows:n=[2,8]}){e=t(...e),n=t(...n);const r=[...$({size:1},e-1),{size:[3,8]}],o=s({size:e,output:"array"}),i=r.map((()=>"---")),a=[o,i];for(let t=0;n-1>t;t++)a.push(r.map((({size:t})=>s({size:t}))));return a.map(x).join("\n")}({features:e}),()=>function({url:t,imageSize:e=[400,250],...r}={}){return t=t||n(e),`![${function({size:t=[1,3],content:e}={}){return e||s({size:t})}(r)}](${t})`}(),()=>g({features:e}),()=>"*-_".charAt(t(0,2)).repeat(t(3,6)),()=>p({features:e}),()=>g({features:e}),()=>w({features:e}),()=>g({features:e})],o).join("\n\n")}function p({level:e=[1,6],size:n=[1,8],content:r}){const o=r||s({size:n});return`${"#".repeat(t(...e))} ${o}`}function h({lang:e,content:n,size:r,fenceChar:o="`"}){return"random"===o&&(o="`~".charAt(t(0,1))),n=n||function({lang:t,size:e=[10,30]}){return t&&d[t]?d[t]():s({output:"multiline",size:e})}({lang:e,size:r}),`${o.repeat(3)}${e||""}\n${n}\n${o.repeat(3)}`}function g({size:t=[20,50]}){return s({size:t,decorates:["description",z()]})}const _=["ordered","bullet","task"];function w({features:e,type:n="random",count:r=[1,8],size:o=[5,15]}){r="number"==typeof r?r:t(...r);const s="random"===n?_[Math.floor(3*Math.random())]:n,i=[];for(;r>0;){const a=t(1,r);let u=g({features:e,size:o});a>1&&(u+="\n"+w({features:e,type:n,count:a-1,size:o})),i.push(M(s,u)),r-=a}return i.join("\n")}const y={"code-span":()=>["`","`"],"emphasis-1":()=>$(b(1),2),"emphasis-2":()=>$(b(2),2),"emphasis-3":()=>$(b(3),2),strikethrough:()=>["~","~"],link:({url:t="https://miso.ai"}={})=>["[",`](${t})`]};function b(e=[1,3]){return e="number"==typeof e?e:t(...e),"_*".charAt(t(0,1)).repeat(e)}const v=Object.keys(y),q=new Set(v);function z({features:e=v,size:n=[1,3],rest:r=[0,8]}={}){e=e.filter((t=>q.has(t)));const o=function(t){for(let e=t.length-1;e>0;e--){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}([...e]);let s=o.length-1;const i=()=>"number"==typeof r?r:t(...r);return function*(r){let a,u,c=i();for(const l of r)if(u&&(yield u),0===c)if(a)u=`${l}${a}`,a=void 0,c=i();else{const[r,i]=y[0>s?e[t(0,e.length-1)]:o[s--]]();u=`${r}${l}`,a=i,c="number"==typeof n?n:t(...n)}else u=l,c--;u&&(yield void 0!==a?`${u}${a}`:u)}}function M(t,e){const[n,r]=e.split("\n",2),o=`${function(t,e="random"){switch(t){case"ordered":return"1.";case"bullet":return"-";case"task":return`- [${("random"===e?.5>Math.random():e)?"x":" "}]`;default:throw Error("unknown list item type: "+t)}}(t)} ${n}`;return r?o+"\n"+function(t,e){return e.split("\n").map((e=>" ".repeat(t)+e)).join("\n")}("ordered"===t?3:2,r):o}function x(t){return`| ${t.join(" | ")} |`}function $(t,e){const n=[];for(let r=0;e>r;r++)n.push("function"==typeof t?t():t);return n}function j({size:t=300}={}){return n(t)}function S({size:t=[1,3]}={}){return s({size:t,decorates:["title"],output:"array"})}function k({size:t=[1,4]}={}){return s({size:t,output:"array"})}function O({size:t=[2,6]}={}){return s({size:t,decorates:["title"]})}function A({size:t=[10,20]}={}){return s({size:t,decorates:["description"]})}function T(){return Math.floor(1e4*Math.random())/100}function*C({rows:t,...e}={}){for(let n=0;t>n;n++)yield F({...e,index:n})}function F({}={}){const n=e(),r=function(e,n){const r=t(...n),o=[];for(let t=0;r>t;t++)o.push(e());return o}(T,[1,2]);return r.sort(),{product_id:n,authors:S(),categories:[],tags:k(),title:O(),description:A(),cover_image:j(),url:"/products/"+n,sale_price:r[0],original_price:r[r.length-1],rating:Math.floor(500*Math.random())/100+1,availability:Math.random()>.3?"IN_STOCK":"OUT_OF_STOCK"}}function*D({rows:t,...e}={}){for(let n=0;t>n;n++)yield L({...e,index:n})}function L({}={}){const t=e();return{product_id:t,authors:S(),categories:[],tags:k(),title:O({size:[4,10]}),snippet:A({size:[20,40]}),cover_image:j(),url:"/products/"+t}}function P({question:t,parent_question_id:e,timestamp:n=Date.now()},{answerFormat:o="markdown",answerSampling:i,answerLanguages:a=[]}={}){const u="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(t=>(t^16*Math.random()>>t/4).toString(16))),c=function(t){const e=new Date(t).toISOString();return e.endsWith("Z")?e.slice(0,-1):e}(n),l=void 0!==i?Math.max(0,Math.min(1,i)):void 0,f=function({format:t,sampling:e,features:n}){return"markdown"===t?m({sampling:e,features:n}):s({min:r(50,e),max:r(50,e),decorates:["description"]})}({format:o,sampling:l,features:a.length?a.map((t=>"lang-"+t)):void 0});return{question:t,question_id:u,...e&&{parent_question_id:e},datetime:c,answer:f,related_resources:[...D({rows:W(6,8,l)})],sources:[...D({rows:W(4,6,l)})]}}function W(e,n,o){return t(r(e,o),r(n,o))}const H=[{name:"fetch",duration:1.5,text:"Checking the question and fetching results... "},{name:"verify",duration:1.5,text:"Verifying results... "},{name:"generate",duration:1.5,text:"Generating answer... "}];class I{constructor(t={}){this._options=t,this._answers=new Map}questions(t,e={}){return new J(t,{...this._options,...e})}}class J{constructor({question:t,parent_question_id:e},{answerFormat:n,answerSampling:r,answerLanguages:o,...s}={}){this._options=Object.freeze(s);const i=this.timestamp=Date.now();this._data=P({question:t,parent_question_id:e,timestamp:i},{answerFormat:n,answerSampling:r,answerLanguages:o})}get question_id(){return this._data.question_id}get(){const t=(Date.now()-this.timestamp)*(this._options.speedRate||1)/1e3,[e,n,r]=this._answer(t),o=this._sources(t,r),s=this._related_resources(t,r),{question_id:i,question:a,datetime:u,parent_question_id:c}=this._data;return{answer:n,answer_stage:e,datetime:u,finished:r,parent_question_id:c,question:a,question_id:i,related_resources:s,sources:o}}_answer(t){for(const e of H)if(0>(t-=e.duration))return[e.name,e.text,!1];const{answer:e}=this._data,n=Math.floor(100*t),r=n>=e.length;return["result",r?e:e.slice(0,n),r]}_sources(t,e){const{sources:n}=this._data;if(e)return n;const{length:r}=n;return n.slice(0,Math.floor(r*t/3))}_related_resources(t,e){const{related_resources:n}=this._data;if(e)return n;const{length:r}=n;return n.slice(0,Math.floor(r*t/3))}}class K{constructor(t){this._options=t}search({rows:t=5}){return{products:[...C({rows:t})]}}}class U{constructor(t){this._options=t}user_to_products({rows:t=5}){return{products:[...C({rows:t})]}}product_to_products({rows:t=5}){return{products:[...C({rows:t})]}}}class E{constructor(t){this.ask=new I(t),this.search=new K(t),this.recommendation=new U(t)}}return doggoganger={buildApi:(...t)=>new E(...t)}}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).doggoganger=e()}(this,(function(){"use strict";function t(t,e){return null!=e&&e>t?t+Math.floor(Math.random()*(e-t)):t}function e(){return Math.random().toString(36).substring(2,10)}function n(t){return`https://picsum.photos/seed/${Math.floor(1e3*Math.random())}/${Array.isArray(t)?t.length>1?`${t[0]}/${t[1]}`:""+t[0]:""+t}`}function r(t,e){return void 0!==e?Math.ceil(t*e):t}var o=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","curabitur","vel","hendrerit","libero","eleifend","blandit","nunc","ornare","odio","ut","orci","gravida","imperdiet","nullam","purus","lacinia","a","pretium","quis","congue","praesent","sagittis","laoreet","auctor","mauris","non","velit","eros","dictum","proin","accumsan","sapien","nec","massa","volutpat","venenatis","sed","eu","molestie","lacus","quisque","porttitor","ligula","dui","mollis","tempus","at","magna","vestibulum","turpis","ac","diam","tincidunt","id","condimentum","enim","sodales","in","hac","habitasse","platea","dictumst","aenean","neque","fusce","augue","leo","eget","semper","mattis","tortor","scelerisque","nulla","interdum","tellus","malesuada","rhoncus","porta","sem","aliquet","et","nam","suspendisse","potenti","vivamus","luctus","fringilla","erat","donec","justo","vehicula","ultricies","varius","ante","primis","faucibus","ultrices","posuere","cubilia","curae","etiam","cursus","aliquam","quam","dapibus","nisl","feugiat","egestas","class","aptent","taciti","sociosqu","ad","litora","torquent","per","conubia","nostra","inceptos","himenaeos","phasellus","nibh","pulvinar","vitae","urna","iaculis","lobortis","nisi","viverra","arcu","morbi","pellentesque","metus","commodo","ut","facilisis","felis","tristique","ullamcorper","placerat","aenean","convallis","sollicitudin","integer","rutrum","duis","est","etiam","bibendum","donec","pharetra","vulputate","maecenas","mi","fermentum","consequat","suscipit","aliquam","habitant","senectus","netus","fames","quisque","euismod","curabitur","lectus","elementum","tempor","risus","cras"];function s({decorates:e=[],output:n="string",size:r,min:s,max:i,...u}={}){let c=function(e=[5,10]){const n="number"==typeof e?e:t(...e);return function*(t){let e=0;for(let r of t){if(e++>=n)break;yield r}}}(r||[s,i])(function*({words:t=o,fixedStarts:e=0}={}){const n=t.length;for(let r=0;;r++)yield t[e>r?r:Math.floor(Math.random()*n)]}(u));for(const t of e)c=a(t)(c);return a(n)(c)}const i={string:function({separator:t=" "}={}){return e=>[...e].join(t)},array:function(){return t=>[...t]},title:function({}={}){return function*(t){for(let e of t)yield u(e)}},description:function({wordsPerSentence:t={avg:24,std:5,min:1}}={}){return function*(e){let n,r=0;for(let o of e)n&&(yield n),n=o,0===r&&(n=u(n),r=c(t)),0==--r&&(n+=".");n&&(n.endsWith(".")||(n+="."),yield n)}},multiline:function({wordsPerLine:t={avg:10,std:3,min:1}}={}){return e=>{let n=c(t),r="";for(let o of e)r&&(0==n--?(r+="\n",n=c(t)):r+=" "),r+=o;return r}}};function a(t){return"string"==typeof t?i[t]():t}function u(t){return t[0].toUpperCase()+t.substring(1)}function c(t){if("number"==typeof t)return Math.round(e);let{avg:e,std:n,min:r,max:o}=t;void 0===n&&(n=e/4);let s=(l()+l()+l())*n+e;return void 0!==r&&(s=Math.max(r,s)),void 0!==o&&(s=Math.min(o,s)),Math.round(s)}function l(){return 2*Math.random()-1}const f="// module\nimport { a, b } from './module';\nimport * as module from './module';\nimport module from './module';\nexport default module;\nexport const a = 0;\nexport * from './module';\nexport * as module from './module';\n\n// variables\nlet a = 10;\nconst b = 20;\n\n// function declaration\nfunction sum(x, y) {\n return x + y;\n}\n\n// generator function\nfunction* iterator() {\n yield 0;\n yield 1;\n}\n\n// arrow function\nconst multiply = (x, y) => x * y;\n\n// class\nclass Person {\n constructor(name, age) {\n this.name = name;\n this.age = age;\n }\n\n greet() {\n console.log('Hello, my name is Miso.');\n }\n}\n\n// primitive\nconst str = 'Hello, world!';\nconst num = 10.99;\n\n// object\nconst person = new Person('John', 30);\nperson.greet();\n\n// object literal\nconst object = {\n name: 'John',\n [x]: 10,\n ...props,\n};\n\n// array literal\nconst arr = [1, 2, 3, 4, 5, ...props];\n\n// regexp literal\nconst regexp = /\\w+/g;\n\n// operators\nconst sum = a + b;\nconst product = a * b;\nconst negation = -a;\nconst max = a > b ? a : b;\n\n// flow control\nlet i = 9;\nfor (const n of arr) {\n if (n > i) {\n console.log(n);\n }\n i++;\n}\n\n// async/await\n(async () => {\n const result = await asyncFunction();\n})();\n\n// try/catch\ntry {\n} catch (e) {\n}\n\n// destructuring\nconst { name, age, ...rest } = person;\nconst [ x, y, ...rest ] = arr;\n\n// template literals\nconsole.log(`The sum of ${a} and ${b} is ${sum(a, b)}.`);";var d=Object.freeze({__proto__:null,javascript:function(){return f},js:function(){return f}});function m({features:e,blocks:r=[8,12],sampling:o=1}={}){let i=[];return[i,e]=function(t=[]){const e=new Set,n=[];for(const r of t)if(r.startsWith("lang-")){let t=r.slice(5);"javascript"===t&&(t="js"),e.add(t)}else n.push(r);return[[...e],n]}(e),function(t,e){const n=[];for(const r of t)1>e&&Math.random()>=e||n.push(r());return n}([()=>p({features:e}),()=>g({features:e}),...i.map((t=>()=>h({lang:t,features:e}))),...i.length?[]:[()=>h({features:e})],()=>g({features:e}),()=>function({columns:e=[2,4],rows:n=[2,8]}){e=t(...e),n=t(...n);const r=[...$({size:1},e-1),{size:[3,8]}],o=s({size:e,output:"array"}),i=r.map((()=>"---")),a=[o,i];for(let t=0;n-1>t;t++)a.push(r.map((({size:t})=>s({size:t}))));return a.map(x).join("\n")}({features:e}),()=>function({url:t,imageSize:e=[400,250],...r}={}){return t=t||n(e),`![${function({size:t=[1,3],content:e}={}){return e||s({size:t})}(r)}](${t})`}(),()=>g({features:e}),()=>"*-_".charAt(t(0,2)).repeat(t(3,6)),()=>p({features:e}),()=>g({features:e}),()=>w({features:e}),()=>g({features:e})],o).join("\n\n")}function p({level:e=[1,6],size:n=[1,8],content:r}){const o=r||s({size:n});return`${"#".repeat(t(...e))} ${o}`}function h({lang:e,content:n,size:r,fenceChar:o="`"}){return"random"===o&&(o="`~".charAt(t(0,1))),n=n||function({lang:t,size:e=[10,30]}){return t&&d[t]?d[t]():s({output:"multiline",size:e})}({lang:e,size:r}),`${o.repeat(3)}${e||""}\n${n}\n${o.repeat(3)}`}function g({size:t=[20,50]}){return s({size:t,decorates:["description",z()]})}const _=["ordered","bullet","task"];function w({features:e,type:n="random",count:r=[1,8],size:o=[5,15]}){r="number"==typeof r?r:t(...r);const s="random"===n?_[Math.floor(3*Math.random())]:n,i=[];for(;r>0;){const a=t(1,r);let u=g({features:e,size:o});a>1&&(u+="\n"+w({features:e,type:n,count:a-1,size:o})),i.push(M(s,u)),r-=a}return i.join("\n")}const y={"code-span":()=>["`","`"],"emphasis-1":()=>$(b(1),2),"emphasis-2":()=>$(b(2),2),"emphasis-3":()=>$(b(3),2),strikethrough:()=>["~","~"],link:({url:t="https://miso.ai"}={})=>["[",`](${t})`]};function b(e=[1,3]){return e="number"==typeof e?e:t(...e),"_*".charAt(t(0,1)).repeat(e)}const v=Object.keys(y),q=new Set(v);function z({features:e=v,size:n=[1,3],rest:r=[0,8]}={}){e=e.filter((t=>q.has(t)));const o=function(t){for(let e=t.length-1;e>0;e--){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}([...e]);let s=o.length-1;const i=()=>"number"==typeof r?r:t(...r);return function*(r){let a,u,c=i();for(const l of r)if(u&&(yield u),0===c)if(a)u=`${l}${a}`,a=void 0,c=i();else{const[r,i]=y[0>s?e[t(0,e.length-1)]:o[s--]]();u=`${r}${l}`,a=i,c="number"==typeof n?n:t(...n)}else u=l,c--;u&&(yield void 0!==a?`${u}${a}`:u)}}function M(t,e){const[n,r]=e.split("\n",2),o=`${function(t,e="random"){switch(t){case"ordered":return"1.";case"bullet":return"-";case"task":return`- [${("random"===e?.5>Math.random():e)?"x":" "}]`;default:throw Error("unknown list item type: "+t)}}(t)} ${n}`;return r?o+"\n"+function(t,e){return e.split("\n").map((e=>" ".repeat(t)+e)).join("\n")}("ordered"===t?3:2,r):o}function x(t){return`| ${t.join(" | ")} |`}function $(t,e){const n=[];for(let r=0;e>r;r++)n.push("function"==typeof t?t():t);return n}function j({size:t=300}={}){return n(t)}function S({size:t=[1,3]}={}){return s({size:t,decorates:["title"],output:"array"})}function k({size:t=[1,4]}={}){return s({size:t,output:"array"})}function O({size:t=[2,6]}={}){return s({size:t,decorates:["title"]})}function A({size:t=[10,20]}={}){return s({size:t,decorates:["description"]})}function T(){return Math.floor(1e4*Math.random())/100}function*C({rows:t,...e}={}){for(let n=0;t>n;n++)yield F({...e,index:n})}function F({}={}){const n=e(),r=function(e,n){const r=t(...n),o=[];for(let t=0;r>t;t++)o.push(e());return o}(T,[1,2]);return r.sort(),{product_id:n,authors:S(),categories:[],tags:k(),title:O(),description:A(),cover_image:j(),url:"/products/"+n,sale_price:r[0],original_price:r[r.length-1],rating:Math.floor(500*Math.random())/100+1,availability:Math.random()>.3?"IN_STOCK":"OUT_OF_STOCK"}}function*D({rows:t,...e}={}){for(let n=0;t>n;n++)yield L({...e,index:n})}function L({}={}){const t=e();return{product_id:t,authors:S(),categories:[],tags:k(),title:O({size:[4,10]}),snippet:A({size:[20,40]}),cover_image:j(),url:"/products/"+t}}function P({question:t,parent_question_id:e,timestamp:n=Date.now()},{answerFormat:o="markdown",answerSampling:i,answerLanguages:a=[]}={}){const u="10000000-1000-4000-8000-100000000000".replace(/[018]/g,(t=>(t^16*Math.random()>>t/4).toString(16))),c=function(t){const e=new Date(t).toISOString();return e.endsWith("Z")?e.slice(0,-1):e}(n),l=void 0!==i?Math.max(0,Math.min(1,i)):void 0,f=function({format:t,sampling:e,features:n}){return"markdown"===t?m({sampling:e,features:n}):s({min:r(50,e),max:r(50,e),decorates:["description"]})}({format:o,sampling:l,features:a.length?a.map((t=>"lang-"+t)):void 0});return{question:t,question_id:u,...e&&{parent_question_id:e},datetime:c,answer:f,related_resources:[...D({rows:W(6,8,l)})],sources:[...D({rows:W(4,6,l)})]}}function W(e,n,o){return t(r(e,o),r(n,o))}const H=[{name:"fetch",duration:1.5,text:"Checking the question and fetching results... "},{name:"verify",duration:1.5,text:"Verifying results... "},{name:"generate",duration:1.5,text:"Generating answer... "}];class I{constructor(t={}){this._options=t,this._answers=new Map}questions(t,e={}){return new J(t,{...this._options,...e})}}class J{constructor({question:t,parent_question_id:e},{answerFormat:n,answerSampling:r,answerLanguages:o,...s}={}){this._options=Object.freeze(s);const i=this.timestamp=Date.now();this._data=P({question:t,parent_question_id:e,timestamp:i},{answerFormat:n,answerSampling:r,answerLanguages:o})}get question_id(){return this._data.question_id}get(){const t=(Date.now()-this.timestamp)*(this._options.speedRate||1)/1e3,[e,n,r]=this._answer(t),o=this._sources(t,r),s=this._related_resources(t,r),{question_id:i,question:a,datetime:u,parent_question_id:c}=this._data;return{answer:n,answer_stage:e,datetime:u,finished:r,parent_question_id:c,question:a,question_id:i,related_resources:s,sources:o}}_answer(t){for(const e of H)if(0>(t-=e.duration))return[e.name,e.text,!1];const{answer:e}=this._data,n=Math.floor(100*t),r=n>=e.length;return["result",r?e:e.slice(0,n),r]}_sources(t,e){const{sources:n}=this._data;if(e)return n;const{length:r}=n;return n.slice(0,Math.floor(r*t/3))}_related_resources(t,e){const{related_resources:n}=this._data;if(e)return n;const{length:r}=n;return n.slice(0,Math.floor(r*t/3))}}class K{constructor(t){this._options=t}search({rows:t=5}){return{products:[...C({rows:t})]}}}class U{constructor(t){this._options=t}user_to_products({rows:t=5}){return{products:[...C({rows:t})]}}product_to_products({rows:t=5}){return{products:[...C({rows:t})]}}}class E{constructor(t){this.ask=new I(t),this.search=new K(t),this.recommendation=new U(t)}}return{buildApi:(...t)=>new E(...t)}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miso.ai/doggoganger",
3
- "version": "0.9.0-beta.12",
3
+ "version": "0.9.0-beta.13",
4
4
  "description": "A dummy miso endpoint for demo and testing",
5
5
  "type": "module",
6
6
  "bin": {
package/src/browser.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Api from './api/index.js';
2
2
 
3
- export default doggoganger = {
3
+ export default {
4
4
  buildApi: (...args) => new Api(...args),
5
5
  };