File size: 9,650 Bytes
a1de0a7
1
!function(){var e,o,n,t,r,i,s,a,c={50495:function(){},27147:function(){},31418:function(){},68741:function(){},70319:function(){},78386:function(){},73342:function(){},58517:function(e,o,n){"use strict";var t=n(78703);class r{constructor(){this.promise=new Promise((e,o)=>{this.resolve=e,this.reject=o})}}n(9109);var i=n(69893),s=n(78967);async function a(e){let o=new Uint8Array(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",o))).map(e=>e.toString(16).padStart(2,"0")).join("")}i.UG.sha512Sync=function(){for(var e=arguments.length,o=Array(e),n=0;n<e;n++)o[n]=arguments[n];return(0,s.o)(i.UG.concatBytes(...o))};var c=n(36393),l=n(22170),d=n.n(l);let u="rakisSettings",g=null,f={initialLLMWorkers:[{modelName:"gemma-2b-it-q4f16_1",count:2}],initialEmbeddingWorkers:[{modelName:"nomic-ai/nomic-embed-text-v1.5",count:1}]},m={maxReceivedPacketQueueSize:100,receivePacketQueueDebounceMs:100,peerHeartLimit:20,peerCommunicationCount:40,maxPacketDBSize:5e3},b={topic:"rakis1",maxTransmissionErrorsBeforeRestart:5},v={dAppName:"Rakis",url:"https://rakis.ai"},p={maxLogsInMemory:1e3,loggersToSkipForInMemoryLog:["P2P: NKN","P2P: PewPewDB","P2P: nostr (trystero)","P2P: torrent (trystero)","PacketDB"],newLogEventDebounceMs:150},w={enabledP2PNetworks:["nostr","gun","torrent","nkn"],waitForP2PBootupMs:5e3,inferencePollingIntervalMs:5e3,inferenceRequestQueueDebounceMs:1e3,embeddingsQueueDebounceMs:100,requestSimilarityTimeWindowMs:2e3},y={quorumRevealRequestIssueTimeoutMs:1e4,quorumRevealTimeoutMs:2e4,quorumConsensusWindowMs:3e4,bEmbeddingThreshold:0},k={engineLogLimit:2e3,debounceLoadingProgressEventMs:50},h=function(){let e={};try{window.localStorage&&window.localStorage&&window.localStorage.getItem(u)&&(g=e=JSON.parse(window.localStorage.getItem(u)))}catch(o){console.error("Error loading settings from localStorage, loading saved settings if we have them",g),g&&(console.log("Using last loaded settings - ",g),e=g)}return e.packetDBSettings={...m,...e.packetDBSettings},e.p2pSettings={...b,...e.p2pSettings},e.chainConnectionSettings={...v,...e.chainConnectionSettings},e.loggerSettings={...p,...e.loggerSettings},e.theDomainSettings={...w,...e.theDomainSettings},e.quorumSettings={...y,...e.quorumSettings},e.llmEngineSettings={...k,...e.llmEngineSettings},e.workerSettings={...f,...e.workerSettings},e}().loggerSettings,L=0;class S extends c.Z{static getInstance(){return S.instance||(S.instance=new S),S.instance}static addLog(e,o,n){S.getInstance().logs.push({at:new Date,logger:e,type:o,id:L++,message:n}),S.getInstance().logs=S.getInstance().logs.slice(-h.maxLogsInMemory).sort((e,o)=>o.at.getTime()-e.at.getTime()),S.getInstance().emitNewLogs()}constructor(){super(),this.logs=[],this.emitNewLogs=d()(()=>{this.emit("newLog")},h.newLogEventDebounceMs)}}let P=function(e,o){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return!n&&window&&(window.blockedLogLevels=localStorage.getItem("blockedLogLevels")||[],window.blockedLoggers=localStorage.getItem("blockedLoggers")||[]),{trace:function(t){for(var r,i,s,a,c=arguments.length,l=Array(c>1?c-1:0),d=1;d<c;d++)l[d-1]=arguments[d];!n&&((null===(i=window)||void 0===i?void 0:null===(r=i.blockedLogLevels)||void 0===r?void 0:r.includes("trace"))||(null===(a=window)||void 0===a?void 0:null===(s=a.blockedLoggers)||void 0===s?void 0:s.includes(e)))||console.log("%c[T] ".concat(e,":"),o,t,...l)},debug:function(t){for(var r,i,s,a,c=arguments.length,l=Array(c>1?c-1:0),d=1;d<c;d++)l[d-1]=arguments[d];!n&&((null===(i=window)||void 0===i?void 0:null===(r=i.blockedLogLevels)||void 0===r?void 0:r.includes("debug"))||(null===(a=window)||void 0===a?void 0:null===(s=a.blockedLoggers)||void 0===s?void 0:s.includes(e)))||(h.loggersToSkipForInMemoryLog.includes(e)||S.addLog(e,"debug",t),console.log("%c[D] ".concat(e,":"),o,t,...l))},info:function(t){for(var r,i,s,a,c=arguments.length,l=Array(c>1?c-1:0),d=1;d<c;d++)l[d-1]=arguments[d];!n&&((null===(i=window)||void 0===i?void 0:null===(r=i.blockedLogLevels)||void 0===r?void 0:r.includes("info"))||(null===(a=window)||void 0===a?void 0:null===(s=a.blockedLoggers)||void 0===s?void 0:s.includes(e)))||(h.loggersToSkipForInMemoryLog.includes(e)||S.addLog(e,"info",t),console.log("%c[I] ".concat(e,":"),o,t,...l))},warn:function(t){for(var r,i,s,a,c=arguments.length,l=Array(c>1?c-1:0),d=1;d<c;d++)l[d-1]=arguments[d];!n&&((null===(i=window)||void 0===i?void 0:null===(r=i.blockedLogLevels)||void 0===r?void 0:r.includes("warn"))||(null===(a=window)||void 0===a?void 0:null===(s=a.blockedLoggers)||void 0===s?void 0:s.includes(e)))||(h.loggersToSkipForInMemoryLog.includes(e)||S.addLog(e,"warn",t),console.warn("%c[W] ".concat(e,":"),o,t,...l))},error:function(t){for(var r,i,s,a,c=arguments.length,l=Array(c>1?c-1:0),d=1;d<c;d++)l[d-1]=arguments[d];!n&&((null===(i=window)||void 0===i?void 0:null===(r=i.blockedLogLevels)||void 0===r?void 0:r.includes("error"))||(null===(a=window)||void 0===a?void 0:null===(s=a.blockedLoggers)||void 0===s?void 0:s.includes(e)))||(h.loggersToSkipForInMemoryLog.includes(e)||S.addLog(e,"error",t),console.error("%c[ERROR] ".concat(e,":"),o,t,...l))}}}("Embedding Worker","background: #f0fff0; color: #90ee90;",!0);console.log("Created embedding worker logger ",P);let I=null;function E(e){self.postMessage(e)}async function M(e,o){try{I||((I={workerId:o,modelName:e,busyEmbedding:!1,modelLoadingProgress:0,modelLoadingPromise:new r}).pipeline=await (0,t.EUT)("feature-extraction",e,{quantized:!1,progress_callback:e=>{I&&(isNaN(e.progress)||(I.modelLoadingProgress=e.progress/100),e.progress>=100&&I.modelLoadingPromise.resolve())}}))}catch(e){return e.message}return await I.modelLoadingPromise.promise,!0}async function O(e,o){if(!I||!I.pipeline)return{success:!1,reason:"Model could not be loaded."};if(I.busyEmbedding)return{success:!1,reason:"Worker is busy embedding."};I.busyEmbedding=!0,E({type:"workerBusyEmbedding",batchId:o});try{P.debug("Worker ".concat(I.workerId," is now embedding ").concat(o),JSON.stringify(e));let n=await I.pipeline(e,{normalize:!0,pooling:"mean"});I.busyEmbedding=!1,E({type:"workerIdle"});let r=(0,t.eaU)(n,"ubinary"),i=await Promise.all(e.map(async(e,o)=>({text:e,embedding:n.slice([o,o+1]).data,binaryEmbedding:r.slice([o,o+1]).data,bEmbeddingHash:await a(r.slice([o,o+1]).data)})));return{success:!0,results:i}}catch(e){return I.busyEmbedding=!1,E({type:"workerIdle"}),{success:!1,reason:e.message}}}self.onmessage=async e=>{let o=e.data;switch(o.type){case"loadWorker":let n=await M(o.modelName,o.workerId);!0===n?E({type:"workerLoaded",modelName:o.modelName}):E({type:"workerLoadFailure",modelName:o.modelName,err:n});break;case"embedText":let t=await O(o.texts,o.batchId);t.success?E({type:"embeddingSuccess",batchId:o.batchId,results:t.results}):E({type:"embeddingFailure",batchId:o.batchId,reason:t.reason});break;default:P.error("EMBEDDING WORKER GOT ",e," - THIS SHOULDNT HAPPEN!")}}}},l={};function d(e){var o=l[e];if(void 0!==o)return o.exports;var n=l[e]={exports:{}},t=!0;try{c[e](n,n.exports,d),t=!1}finally{t&&delete l[e]}return n.exports}d.m=c,d.x=function(){var e=d.O(void 0,[165,132,15,708,687],function(){return d(58517)});return d.O(e)},e=[],d.O=function(o,n,t,r){if(n){r=r||0;for(var i=e.length;i>0&&e[i-1][2]>r;i--)e[i]=e[i-1];e[i]=[n,t,r];return}for(var s=1/0,i=0;i<e.length;i++){for(var n=e[i][0],t=e[i][1],r=e[i][2],a=!0,c=0;c<n.length;c++)s>=r&&Object.keys(d.O).every(function(e){return d.O[e](n[c])})?n.splice(c--,1):(a=!1,r<s&&(s=r));if(a){e.splice(i--,1);var l=t();void 0!==l&&(o=l)}}return o},d.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(o,{a:o}),o},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},d.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);d.r(r);var i={};o=o||[null,n({}),n([]),n(n)];for(var s=2&t&&e;"object"==typeof s&&!~o.indexOf(s);s=n(s))Object.getOwnPropertyNames(s).forEach(function(o){i[o]=function(){return e[o]}});return i.default=function(){return e},d.d(r,i),r},d.d=function(e,o){for(var n in o)d.o(o,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},d.f={},d.e=function(e){return Promise.all(Object.keys(d.f).reduce(function(o,n){return d.f[n](e,o),o},[]))},d.u=function(e){return 708===e?"static/chunks/708-689e257ca99149f8.js":"static/chunks/"+(({15:"b2db8554",132:"6139e184",165:"590caa2a"})[e]||e)+"."+({15:"daf562cf211503d9",132:"f7be02f919211e5d",165:"51e5370714aa8292",687:"3b9d24743f561986"})[e]+".js"},d.miniCssF=function(e){},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},d.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.tt=function(){return void 0===t&&(t={createScriptURL:function(e){return e}},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(t=trustedTypes.createPolicy("nextjs#bundler",t))),t},d.tu=function(e){return d.tt().createScriptURL(e)},d.p="/_next/",r={99:1},d.f.i=function(e,o){r[e]||importScripts(d.tu(d.p+d.u(e)))},s=(i=self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push.bind(i),i.push=function(e){var o=e[0],n=e[1],t=e[2];for(var i in n)d.o(n,i)&&(d.m[i]=n[i]);for(t&&t(d);o.length;)r[o.pop()]=1;s(e)},a=d.x,d.x=function(){return Promise.all([165,132,15,708,687].map(d.e,d)).then(a)},_N_E=d.x()}();