File size: 9,301 Bytes
7c89823 |
1 |
!function(){var e,o,n,t,r,i,s,c,l={50495:function(){},27147:function(){},31418:function(){},68741:function(){},70319:function(){},78386:function(){},73342:function(){},83743: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})}}var i=n(36393),s=n(22170),c=n.n(s);let l="rakisSettings",a=null,d={initialLLMWorkers:[{modelName:"gemma-2b-it-q4f16_1",count:2}],initialEmbeddingWorkers:[{modelName:"nomic-ai/nomic-embed-text-v1.5",count:1}]},u={maxReceivedPacketQueueSize:100,receivePacketQueueDebounceMs:100,peerHeartLimit:20,peerCommunicationCount:40,maxPacketDBSize:5e3},g={topic:"rakis1",maxTransmissionErrorsBeforeRestart:5},f={dAppName:"Rakis",url:"https://rakis.ai"},m={maxLogsInMemory:1e3,loggersToSkipForInMemoryLog:["P2P: NKN","P2P: PewPewDB","P2P: nostr (trystero)","P2P: torrent (trystero)","PacketDB"],newLogEventDebounceMs:150},b={enabledP2PNetworks:["nostr","gun","torrent","nkn"],waitForP2PBootupMs:5e3,inferencePollingIntervalMs:5e3,inferenceRequestQueueDebounceMs:1e3,embeddingsQueueDebounceMs:100,requestSimilarityTimeWindowMs:2e3},v={quorumRevealRequestIssueTimeoutMs:1e4,quorumRevealTimeoutMs:2e4,quorumConsensusWindowMs:3e4,bEmbeddingThreshold:0},p={engineLogLimit:2e3,debounceLoadingProgressEventMs:50},w=function(){let e={};try{window.localStorage&&window.localStorage&&window.localStorage.getItem(l)&&(a=e=JSON.parse(window.localStorage.getItem(l)))}catch(o){console.error("Error loading settings from localStorage, loading saved settings if we have them",a),a&&(console.log("Using last loaded settings - ",a),e=a)}return e.packetDBSettings={...u,...e.packetDBSettings},e.p2pSettings={...g,...e.p2pSettings},e.chainConnectionSettings={...f,...e.chainConnectionSettings},e.loggerSettings={...m,...e.loggerSettings},e.theDomainSettings={...b,...e.theDomainSettings},e.quorumSettings={...v,...e.quorumSettings},e.llmEngineSettings={...p,...e.llmEngineSettings},e.workerSettings={...d,...e.workerSettings},e}().loggerSettings,y=0;class k extends i.Z{static getInstance(){return k.instance||(k.instance=new k),k.instance}static addLog(e,o,n){k.getInstance().logs.push({at:new Date,logger:e,type:o,id:y++,message:n}),k.getInstance().logs=k.getInstance().logs.slice(-w.maxLogsInMemory).sort((e,o)=>o.at.getTime()-e.at.getTime()),k.getInstance().emitNewLogs()}constructor(){super(),this.logs=[],this.emitNewLogs=c()(()=>{this.emit("newLog")},w.newLogEventDebounceMs)}}let L=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,c,l=arguments.length,a=Array(l>1?l-1:0),d=1;d<l;d++)a[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===(c=window)||void 0===c?void 0:null===(s=c.blockedLoggers)||void 0===s?void 0:s.includes(e)))||console.log("%c[T] ".concat(e,":"),o,t,...a)},debug:function(t){for(var r,i,s,c,l=arguments.length,a=Array(l>1?l-1:0),d=1;d<l;d++)a[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===(c=window)||void 0===c?void 0:null===(s=c.blockedLoggers)||void 0===s?void 0:s.includes(e)))||(w.loggersToSkipForInMemoryLog.includes(e)||k.addLog(e,"debug",t),console.log("%c[D] ".concat(e,":"),o,t,...a))},info:function(t){for(var r,i,s,c,l=arguments.length,a=Array(l>1?l-1:0),d=1;d<l;d++)a[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===(c=window)||void 0===c?void 0:null===(s=c.blockedLoggers)||void 0===s?void 0:s.includes(e)))||(w.loggersToSkipForInMemoryLog.includes(e)||k.addLog(e,"info",t),console.log("%c[I] ".concat(e,":"),o,t,...a))},warn:function(t){for(var r,i,s,c,l=arguments.length,a=Array(l>1?l-1:0),d=1;d<l;d++)a[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===(c=window)||void 0===c?void 0:null===(s=c.blockedLoggers)||void 0===s?void 0:s.includes(e)))||(w.loggersToSkipForInMemoryLog.includes(e)||k.addLog(e,"warn",t),console.warn("%c[W] ".concat(e,":"),o,t,...a))},error:function(t){for(var r,i,s,c,l=arguments.length,a=Array(l>1?l-1:0),d=1;d<l;d++)a[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===(c=window)||void 0===c?void 0:null===(s=c.blockedLoggers)||void 0===s?void 0:s.includes(e)))||(w.loggersToSkipForInMemoryLog.includes(e)||k.addLog(e,"error",t),console.error("%c[ERROR] ".concat(e,":"),o,t,...a))}}}("Embedding Worker","background: #f0fff0; color: #90ee90;",!0);console.log("Created embedding worker logger ",L);let h=null;function S(e){self.postMessage(e)}async function P(e,o){try{h||((h={workerId:o,modelName:e,busyEmbedding:!1,modelLoadingProgress:0,modelLoadingPromise:new r}).pipeline=await (0,t.EUT)("feature-extraction",e,{quantized:!1,progress_callback:e=>{h&&(isNaN(e.progress)||(h.modelLoadingProgress=e.progress/100),e.progress>=100&&h.modelLoadingPromise.resolve())}}))}catch(e){return e.message}return await h.modelLoadingPromise.promise,!0}async function I(e,o){if(!h||!h.pipeline)return{success:!1,reason:"Model could not be loaded."};if(h.busyEmbedding)return{success:!1,reason:"Worker is busy embedding."};h.busyEmbedding=!0,S({type:"workerBusyEmbedding",batchId:o});try{L.debug("Worker ".concat(h.workerId," is now embedding ").concat(o),JSON.stringify(e));let n=await h.pipeline(e,{normalize:!0,pooling:"mean"});h.busyEmbedding=!1,S({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})));return{success:!0,results:i}}catch(e){return h.busyEmbedding=!1,S({type:"workerIdle"}),{success:!1,reason:e.message}}}self.onmessage=async e=>{let o=e.data;switch(o.type){case"loadWorker":let n=await P(o.modelName,o.workerId);!0===n?S({type:"workerLoaded",modelName:o.modelName}):S({type:"workerLoadFailure",modelName:o.modelName,err:n});break;case"embedText":let t=await I(o.texts,o.batchId);t.success?S({type:"embeddingSuccess",batchId:o.batchId,results:t.results}):S({type:"embeddingFailure",batchId:o.batchId,reason:t.reason});break;default:L.error("EMBEDDING WORKER GOT ",e," - THIS SHOULDNT HAPPEN!")}}}},a={};function d(e){var o=a[e];if(void 0!==o)return o.exports;var n=a[e]={exports:{}},t=!0;try{l[e](n,n.exports,d),t=!1}finally{t&&delete a[e]}return n.exports}d.m=l,d.x=function(){var e=d.O(void 0,[165,132,15,708,109,611],function(){return d(83743)});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],c=!0,l=0;l<n.length;l++)s>=r&&Object.keys(d.O).every(function(e){return d.O[e](n[l])})?n.splice(l--,1):(c=!1,r<s&&(s=r));if(c){e.splice(i--,1);var a=t();void 0!==a&&(o=a)}}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",109:"4494b95474b67c66",132:"f7be02f919211e5d",165:"51e5370714aa8292",611:"f019be0ba621c646"})[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={460: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)},c=d.x,d.x=function(){return Promise.all([165,132,15,708,109,611].map(d.e,d)).then(c)},_N_E=d.x()}(); |