From 116d3d126d27e400b0ba5cae8892b375a246283f Mon Sep 17 00:00:00 2001 From: Niek Date: Thu, 6 Jun 2024 14:45:35 +0000 Subject: [PATCH] deploy: fc1fdca28c571f85bc39c6f99ae17a8ea35742e4 --- assets/{index-5ea4aa72.js => index-d7e808b0.js} | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/{index-5ea4aa72.js => index-d7e808b0.js} (99%) diff --git a/assets/index-5ea4aa72.js b/assets/index-d7e808b0.js similarity index 99% rename from assets/index-5ea4aa72.js rename to assets/index-d7e808b0.js index 126afa3c..45f747b8 100644 --- a/assets/index-5ea4aa72.js +++ b/assets/index-d7e808b0.js @@ -132,7 +132,7 @@ Initial scene: - USE AT YOUR OWN RISK. ::NOTE::`,sendSystemPromptLast:!1,autoStartSession:!0,trainingPrompts:[],hiddenPromptPrefix:"",hppContinuePrompt:"",hppWithSummaryPrompt:!1,imageGenerationModel:"",startSequence:"###",stopSequence:"###,User:,,Current user request:",aggressiveStop:!0,delimiter:` ### -### `,userMessageStart:"User:",userMessageEnd:" ",assistantMessageStart:"[[CHARACTER_NAME]]: ",assistantMessageEnd:" ",systemMessageStart:" ",systemMessageEnd:" ",leadPrompt:"[[CHARACTER_NAME]]: ",repetitionPenalty:1.16,hideSystemPrompt:!0,holdSocket:!0}};Object.entries(s3).forEach(([d,l])=>{l.profile=d});var T9={local:{},session:{}};function Oa(d){return d==="local"?localStorage:sessionStorage}function G5(d,l,I){var c,G;const a=(c=I==null?void 0:I.serializer)!=null?c:JSON,b=(G=I==null?void 0:I.storage)!=null?G:"local",W=typeof window<"u"&&typeof document<"u",t=W?Oa(b):null;function n(s,o){t==null||t.setItem(s,a.stringify(o))}if(!T9[b][d]){const s=K1(l,F=>{const X=t==null?void 0:t.getItem(d);if(X&&F(a.parse(X)),W&&b=="local"){const R=i=>{i.key===d&&F(i.newValue?a.parse(i.newValue):null)};return window.addEventListener("storage",R),()=>window.removeEventListener("storage",R)}}),{subscribe:o,set:A}=s;T9[b][d]={set(F){n(d,F),A(F)},update(F){return s.update(X=>{const R=F(X);return n(d,R),R})},subscribe:o}}return T9[b][d]}const N0=G5("chats",[]),s4=G5("latestModelMap",{}),Z1=G5("global",{}),Pa={}.OPENAI_API_KEY||"",Yl=G5("apiKey",Pa);let _1=K1(0),_5=K1(!1),$5=K1(!1),m3=K1(!1),l9=K1(""),Il=K1([]),OI=K1(!1),Dl=K1(0),Tl=G5("lastChatId",0);const m4=Bl(),Mc=()=>e0(Yl),K4=()=>e0(N0).reduce((I,c)=>Math.max(I,c.id),0)+1,Ol=(d=void 0)=>{const l=e0(N0),I=K4();d=JSON.parse(JSON.stringify(d||e9("")));const c=l.reduce((G,a)=>(G[a.name]=a,G),{});return l.push({id:I,name:y4(`Chat ${I}`,c),settings:d,messages:[],usage:{},startSession:!1,sessionStarted:!1,created:Date.now(),lastUse:Date.now(),lastAccess:Date.now()}),N0.set(l),rl(I),I},qa=async d=>{const l=e0(N0),I=K4();let c;try{if(c=JSON.parse(d),!c.settings||!c.messages||isNaN(c.id))return N1("Not valid Chat JSON"),0}catch{return N1("Can't parse file JSON"),0}return c.id=I,c.created=Date.now(),await Dc(I,c),l.push(c),N0.set(l),xc(I),I},xc=d=>{const l=e0(N0),I=l.find(G=>G.id===d);if(I.settings||(I.settings={}),zc(I.settings,!1),I.messages.forEach(G=>{G.uuid=G.uuid||H1(),delete G.streaming}),!(I.usage&&!Array.isArray(I.usage)&&typeof I.usage=="object"&&Object.values(I.usage).find(G=>"prompt_tokens"in G))){const G={};I.usage=G}I.startSession===void 0&&(I.startSession=!1),I.sessionStarted===void 0&&(I.sessionStarted=!!I.messages.find(G=>G.role==="user")),N0.set(l)},zc=(d,l)=>{if(Object.entries(Bl()).forEach(([I,c])=>{const G=d[I];d[I]=G==null?c:d[I]}),"useSummarization"in d||!("continuousChat"in d)){const I=d.useSummarization;I&&!d.summaryPrompt?d.continuousChat="fifo":I?d.continuousChat="summary":d.continuousChat="",delete d.useSummarization}return l&&Object.keys(wl()).forEach(I=>{delete d[I]}),d},Tc=(d,l=!1)=>{const I=e0(N0),c=I.find(b=>b.id===d),G=e9(c.settings.profile),a=wl();l&&Object.entries(Bl()).forEach(([b,W])=>{c.settings[b]=W}),Object.entries(G).forEach(([b,W])=>{a[b]||(c.settings[b]=W)}),N0.set(I)},_a=()=>{N0.set([]),C7()},v1=()=>{const d=e0(N0);N0.set(d)},$1=d=>e0(N0).find(I=>I.id===d),E0=d=>e0(N0).find(I=>I.id===d).settings,PI=(d,l,I)=>{const c=e0(N0),G=c.find(b=>b.id===d);let a=G.usage[I];a||(a={prompt_tokens:0,completion_tokens:0,total_tokens:0},G.usage[I]=a),a.completion_tokens+=(l==null?void 0:l.completion_tokens)||0,a.prompt_tokens+=(l==null?void 0:l.prompt_tokens)||0,a.total_tokens+=(l==null?void 0:l.total_tokens)||0,N0.set(c)},$a=(d,l,I)=>{const c=e0(N0),G=c.find(b=>b.id===d);let a=G.usage[I];a||(a={prompt_tokens:0,completion_tokens:0,total_tokens:0},G.usage[I]=a),a.completion_tokens-=(l==null?void 0:l.completion_tokens)||0,a.prompt_tokens-=(l==null?void 0:l.prompt_tokens)||0,a.total_tokens-=(l==null?void 0:l.total_tokens)||0,N0.set(c)},A3=d=>e0(Dl)===d?e0(Il):$1(d).messages;let qI;const _I=d=>{if(clearTimeout(qI),!d){Dl.set(0),Tl.set(0),Il.set([]);return}qI=setTimeout(()=>{Dl.set(d),Tl.set(d),Il.set($1(d).messages)},10)},$I={},l8=(d,l)=>{clearTimeout($I[d]),$I[d]=setTimeout(()=>{$1(d).lastUse=l,v1()},500)},f9={},al=(d,l)=>{e0(Dl)===d?(Il.set(l),clearTimeout(f9[d]),f9[d]=setTimeout(()=>{$1(d).messages=l,v1(),l8(d,Date.now())},200)):(clearTimeout(f9[d]),$1(d).messages=l,v1(),l8(d,Date.now()))},dl=d=>{al(d,A3(d))},j9=(d,l)=>{g3(d,{content:l})},g3=(d,l)=>{const I=A3(d);l.uuid||(l.uuid=H1()),l.created||(l.created=Date.now()),I.indexOf(l)<0&&(I[I.length]=l),al(d,I)},Pl=(d,l)=>A3(d).find(I=>I.uuid===l),lb=(d,l,I)=>{const c=A3(d),G=c.findIndex(a=>a.uuid===l.uuid);if(G===void 0||G<0){console.error("Couldn't insert after message:",l);return}I.forEach(a=>{a.uuid=a.uuid||H1(),a.created=a.created||Date.now()}),c.splice(G+1,0,...I),al(d,c.filter(a=>!0))},fc=(d,l)=>{const I=Pl(d,l);if(I&&I.summarized)throw new Error("Unable to delete summarized message");I&&I.summary&&(I.summary.forEach(c=>{const G=Pl(d,c);G&&delete G.summarized}),delete I.summary),dl(d),n9(d,l)},n9=(d,l)=>{const I=A3(d),c=I.findIndex(a=>a.uuid===l),G=Pl(d,l);if(G!=null&&G.summarized)throw new Error("Unable to delete summarized message");if(G!=null&&G.summary)throw new Error("Unable to directly delete message summary");if(c<0){console.error(`Unable to find and delete message with ID: ${l}`);return}G!=null&&G.image&&ac(d,G.image.id),I.splice(c,1),al(d,I.filter(a=>!0))},E4=(d,l)=>{l.forEach(I=>{I.image&&ac(d,I.image.id)})},I8=(d,l)=>{const I=A3(d),c=I.findIndex(b=>b.uuid===l),G=Pl(d,l);if(G&&G.summarized)throw new Error("Unable to truncate from a summarized message");if(c<0)throw new Error(`Unable to find message with ID: ${l}`);const a=I.splice(c+1);E4(d,a),al(d,I.filter(b=>!0))},jc=d=>{E4(d,A3(d)),al(d,[])},ul=d=>{const l=e0(N0);E4(d,A3(d)||[]),N0.set(l.filter(I=>I.id!==d))},Dc=async(d,l)=>{const I=l.messages;for(let c=0;c{const l=e0(N0),I=l.find(b=>b.id===d),c=l.reduce((b,W)=>(b[W.name]=W,b),{}),G=y4(I.name,c),a=JSON.parse(JSON.stringify(I));a.id=K4(),a.created=Date.now(),a.name=G,await Dc(d,a),l.push(a),N0.set(l)},ql=(d,l)=>{switch(d){case"number":case"select-number":return l=parseFloat(l),isNaN(l)&&(l=null),l;case"boolean":return typeof l=="string"&&(l=l.trim().toLocaleLowerCase()),l==="true"||l==="yes"||(l?l!=="false"&&l!=="no"&&!!l:!1);default:return l}},db=(d,l,I)=>{const c=x1(l);if(c)return xl(d,c,I);if(!(l in m4))throw new Error("Invalid chat setting: "+l);const G=m4[l];if(G==null)throw new Error('Unable to determine setting type for "'+l+' from default of "'+G+'"');const W=e0(N0).find(t=>t.id===d).settings;W[l]=ql(typeof G,I)},xl=(d,l,I)=>{const c=e0(N0),G=c.find(b=>b.id===d);let a=G.settings;a||(a={},G.settings=a),a[l.key]=ql(l.type,I),N0.set(c)},cb=(d,l)=>{const c=e0(N0).find(a=>a.id===d);let G=c.settings&&c.settings[l.key];return G=G===void 0?null:G,!l.forceApi&&G===m4[l.key]&&(G=null),G},r3=(d,l)=>Gb(va(d),l),Gb=(d,l)=>{const I=e0(Z1);I[d.key]=ql(d.type,l),Z1.set(I)},J4=()=>e0(Z1),ab=()=>e0(Z1).profiles||{},bb=(d,l)=>{if(H4(l))throw new Error("Sorry, you can't delete a static profile.");const c=e0(N0).find(a=>a.id===d),G=e0(Z1);if(G.defaultProfile===c.settings.profile)throw new Error("Sorry, you can't delete the default profile.");delete G.profiles[l],Z1.set(G),c5(!0)},L5=d=>{const l=e0(Z1);let I=l.profiles;I||(I={},l.profiles=I),d.profile||(d.profile=H1());const c=d.profileName&&d.profileName.trim().toLocaleLowerCase();if(Object.values(I).find(b=>b.profile!==d.profile&&b.profileName&&b.profileName.trim().toLocaleLowerCase()===c))throw new Error(`Sorry, another profile already exists with the name "${d.profileName}"`);if(!c)throw new Error("Sorry, you need to enter a valid name for your profile.");if(!d.characterName||d.characterName.length<3)throw new Error("Your profile's character needs a valid name.");H4(d.profile)&&(d.profileName=P5(d.profileName),d.profile=H1());const a=JSON.parse(JSON.stringify(d));Object.keys(wl()).forEach(b=>{delete a[b]}),I[d.profile]=a,Z1.set(l),d.isDirty=!1,v1(),c5(!0)},D9=()=>{const d=e0(Z1);return gl[d.chatSort]||gl[vc.chatSort]},Wb=d=>{const l=e0(Z1);l.chatSort=gl[d]?d:vc.chatSort,Z1.set(l),_1.set(e0(_1)+1)},y4=(d,l)=>{if(!l[d])return d;const I=d.match(/^(.*[^0-9]+)([- ])*([0-9]+)$/);let c=1,G=" ";I&&(d=I[1],G=I[2]||"",c=parseInt(I[3]));let a=`${d}${G}${c}`;for(;l[a];)c++,a=`${d}${G}${c}`;return a},tb=d=>e0(s4)[d]||d,eb=(d,l)=>{const I=e0(s4);I[d]=l,s4.set(I)},Oc="/chatgpt-web/assets/logo-3651fe68.svg",w5=parseFloat;function p4(d,l=";"){let I;if(Array.isArray(d))I=d.filter(c=>c);else{I=[];for(const c in d)d[c]&&I.push(`${c}:${d[c]}`)}return I.join(l)}function nb(d,l,I,c){let G,a;const b="1em";let W,t,n,s="-.125em";const o="visible";return c&&(n="center",a="1.25em"),I&&(G=I),l&&(l=="lg"?(t="1.33333em",W=".75em",s="-.225em"):l=="xs"?t=".75em":l=="sm"?t=".875em":t=l.replace("x","em")),p4([p4({float:G,width:a,height:b,"line-height":W,"font-size":t,"text-align":n,"vertical-align":s,"transform-origin":"center",overflow:o}),d])}function Zb(d,l,I,c,G,a=1,b="",W=""){let t=1,n=1;return G&&(G=="horizontal"?t=-1:G=="vertical"?n=-1:t=n=-1),p4([`translate(${w5(l)*a}${b},${w5(I)*a}${b})`,`scale(${t*w5(d)},${n*w5(d)})`,c&&`rotate(${c}${W})`]," ")}function d8(d){let l,I,c,G,a,b,W,t;function n(A,F){return typeof A[10][4]=="string"?mb:sb}let s=n(d),o=s(d);return{c(){l=j3("svg"),I=j3("g"),c=j3("g"),o.c(),p(c,"transform",d[12]),p(I,"transform",G="translate("+d[10][0]/2+" "+d[10][1]/2+")"),p(I,"transform-origin",a=d[10][0]/4+" 0"),p(l,"id",b=d[1]||void 0),p(l,"class",W="svelte-fa "+d[0]+" svelte-1cj2gr0"),p(l,"style",d[11]),p(l,"viewBox",t="0 0 "+d[10][0]+" "+d[10][1]),p(l,"aria-hidden","true"),p(l,"role","img"),p(l,"xmlns","http://www.w3.org/2000/svg"),n2(l,"pulse",d[4]),n2(l,"spin",d[3])},m(A,F){L(A,l,F),V(l,I),V(I,c),o.m(c,null)},p(A,F){s===(s=n(A))&&o?o.p(A,F):(o.d(1),o=s(A),o&&(o.c(),o.m(c,null))),F&4096&&p(c,"transform",A[12]),F&1024&&G!==(G="translate("+A[10][0]/2+" "+A[10][1]/2+")")&&p(I,"transform",G),F&1024&&a!==(a=A[10][0]/4+" 0")&&p(I,"transform-origin",a),F&2&&b!==(b=A[1]||void 0)&&p(l,"id",b),F&1&&W!==(W="svelte-fa "+A[0]+" svelte-1cj2gr0")&&p(l,"class",W),F&2048&&p(l,"style",A[11]),F&1024&&t!==(t="0 0 "+A[10][0]+" "+A[10][1])&&p(l,"viewBox",t),F&17&&n2(l,"pulse",A[4]),F&9&&n2(l,"spin",A[3])},d(A){A&&y(l),o.d()}}}function sb(d){let l,I,c,G,a,b,W,t,n,s;return{c(){l=j3("path"),b=j3("path"),p(l,"d",I=d[10][4][0]),p(l,"fill",c=d[6]||d[2]||"currentColor"),p(l,"fill-opacity",G=d[9]!=!1?d[7]:d[8]),p(l,"transform",a="translate("+d[10][0]/-2+" "+d[10][1]/-2+")"),p(b,"d",W=d[10][4][1]),p(b,"fill",t=d[5]||d[2]||"currentColor"),p(b,"fill-opacity",n=d[9]!=!1?d[8]:d[7]),p(b,"transform",s="translate("+d[10][0]/-2+" "+d[10][1]/-2+")")},m(o,A){L(o,l,A),L(o,b,A)},p(o,A){A&1024&&I!==(I=o[10][4][0])&&p(l,"d",I),A&68&&c!==(c=o[6]||o[2]||"currentColor")&&p(l,"fill",c),A&896&&G!==(G=o[9]!=!1?o[7]:o[8])&&p(l,"fill-opacity",G),A&1024&&a!==(a="translate("+o[10][0]/-2+" "+o[10][1]/-2+")")&&p(l,"transform",a),A&1024&&W!==(W=o[10][4][1])&&p(b,"d",W),A&36&&t!==(t=o[5]||o[2]||"currentColor")&&p(b,"fill",t),A&896&&n!==(n=o[9]!=!1?o[8]:o[7])&&p(b,"fill-opacity",n),A&1024&&s!==(s="translate("+o[10][0]/-2+" "+o[10][1]/-2+")")&&p(b,"transform",s)},d(o){o&&y(l),o&&y(b)}}}function mb(d){let l,I,c,G;return{c(){l=j3("path"),p(l,"d",I=d[10][4]),p(l,"fill",c=d[2]||d[5]||"currentColor"),p(l,"transform",G="translate("+d[10][0]/-2+" "+d[10][1]/-2+")")},m(a,b){L(a,l,b)},p(a,b){b&1024&&I!==(I=a[10][4])&&p(l,"d",I),b&36&&c!==(c=a[2]||a[5]||"currentColor")&&p(l,"fill",c),b&1024&&G!==(G="translate("+a[10][0]/-2+" "+a[10][1]/-2+")")&&p(l,"transform",G)},d(a){a&&y(l)}}}function pb(d){let l,I=d[10][4]&&d8(d);return{c(){I&&I.c(),l=G0()},m(c,G){I&&I.m(c,G),L(c,l,G)},p(c,[G]){c[10][4]?I?I.p(c,G):(I=d8(c),I.c(),I.m(l.parentNode,l)):I&&(I.d(1),I=null)},i:U2,o:U2,d(c){I&&I.d(c),c&&y(l)}}}function ob(d,l,I){let{class:c=""}=l,{id:G=""}=l,{style:a=""}=l,{icon:b}=l,{size:W=""}=l,{color:t=""}=l,{fw:n=!1}=l,{pull:s=""}=l,{scale:o=1}=l,{translateX:A=0}=l,{translateY:F=0}=l,{rotate:X=""}=l,{flip:R=!1}=l,{spin:i=!1}=l,{pulse:K=!1}=l,{primaryColor:k=""}=l,{secondaryColor:J=""}=l,{primaryOpacity:C=1}=l,{secondaryOpacity:N=.4}=l,{swapOpacity:B=!1}=l,j,c2,s2;return d.$$set=x=>{"class"in x&&I(0,c=x.class),"id"in x&&I(1,G=x.id),"style"in x&&I(13,a=x.style),"icon"in x&&I(14,b=x.icon),"size"in x&&I(15,W=x.size),"color"in x&&I(2,t=x.color),"fw"in x&&I(16,n=x.fw),"pull"in x&&I(17,s=x.pull),"scale"in x&&I(18,o=x.scale),"translateX"in x&&I(19,A=x.translateX),"translateY"in x&&I(20,F=x.translateY),"rotate"in x&&I(21,X=x.rotate),"flip"in x&&I(22,R=x.flip),"spin"in x&&I(3,i=x.spin),"pulse"in x&&I(4,K=x.pulse),"primaryColor"in x&&I(5,k=x.primaryColor),"secondaryColor"in x&&I(6,J=x.secondaryColor),"primaryOpacity"in x&&I(7,C=x.primaryOpacity),"secondaryOpacity"in x&&I(8,N=x.secondaryOpacity),"swapOpacity"in x&&I(9,B=x.swapOpacity)},d.$$.update=()=>{d.$$.dirty&16384&&I(10,j=b&&b.icon||[0,0,"",[],""]),d.$$.dirty&237568&&I(11,c2=nb(a,W,s,n)),d.$$.dirty&8126464&&I(12,s2=Zb(o,A,F,X,R,512))},[c,G,t,i,K,k,J,C,N,B,j,c2,s2,a,b,W,n,s,o,A,F,X,R]}class Ab extends s0{constructor(l){super(),Z0(this,l,ob,pb,d0,{class:0,id:1,style:13,icon:14,size:15,color:2,fw:16,pull:17,scale:18,translateX:19,translateY:20,rotate:21,flip:22,spin:3,pulse:4,primaryColor:5,secondaryColor:6,primaryOpacity:7,secondaryOpacity:8,swapOpacity:9})}}const $2=Ab;var Qb={prefix:"far",iconName:"message",icon:[512,512,["comment-alt"],"f27a","M160 368c26.5 0 48 21.5 48 48v16l72.5-54.4c8.3-6.2 18.4-9.6 28.8-9.6H448c8.8 0 16-7.2 16-16V64c0-8.8-7.2-16-16-16H64c-8.8 0-16 7.2-16 16V352c0 8.8 7.2 16 16 16h96zm48 124l-.2 .2-5.1 3.8-17.1 12.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3V474.7v-6.4V468v-4V416H112 64c-35.3 0-64-28.7-64-64V64C0 28.7 28.7 0 64 0H448c35.3 0 64 28.7 64 64V352c0 35.3-28.7 64-64 64H309.3L208 492z"]},Fb={prefix:"far",iconName:"square-minus",icon:[448,512,[61767,"minus-square"],"f146","M64 80c-8.8 0-16 7.2-16 16V416c0 8.8 7.2 16 16 16H384c8.8 0 16-7.2 16-16V96c0-8.8-7.2-16-16-16H64zM0 96C0 60.7 28.7 32 64 32H384c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM152 232H296c13.3 0 24 10.7 24 24s-10.7 24-24 24H152c-13.3 0-24-10.7-24-24s10.7-24 24-24z"]},ub={prefix:"far",iconName:"clipboard",icon:[384,512,[128203],"f328","M280 64h40c35.3 0 64 28.7 64 64V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128C0 92.7 28.7 64 64 64h40 9.6C121 27.5 153.3 0 192 0s71 27.5 78.4 64H280zM64 112c-8.8 0-16 7.2-16 16V448c0 8.8 7.2 16 16 16H320c8.8 0 16-7.2 16-16V128c0-8.8-7.2-16-16-16H304v24c0 13.3-10.7 24-24 24H192 104c-13.3 0-24-10.7-24-24V112H64zm128-8a24 24 0 1 0 0-48 24 24 0 1 0 0 48z"]},Vb={prefix:"far",iconName:"square-plus",icon:[448,512,[61846,"plus-square"],"f0fe","M64 80c-8.8 0-16 7.2-16 16V416c0 8.8 7.2 16 16 16H384c8.8 0 16-7.2 16-16V96c0-8.8-7.2-16-16-16H64zM0 96C0 60.7 28.7 32 64 32H384c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM200 344V280H136c-13.3 0-24-10.7-24-24s10.7-24 24-24h64V168c0-13.3 10.7-24 24-24s24 10.7 24 24v64h64c13.3 0 24 10.7 24 24s-10.7 24-24 24H248v64c0 13.3-10.7 24-24 24s-24-10.7-24-24z"]};const Xb=d=>{const I=e0(N0).find(t=>t.id===d),c=I.messages;let G=`# ${I.name} +### `,userMessageStart:"User:",userMessageEnd:" ",assistantMessageStart:"[[CHARACTER_NAME]]: ",assistantMessageEnd:" ",systemMessageStart:" ",systemMessageEnd:" ",leadPrompt:"[[CHARACTER_NAME]]: ",repetitionPenalty:1.16,hideSystemPrompt:!0,holdSocket:!0}};Object.entries(s3).forEach(([d,l])=>{l.profile=d});var T9={local:{},session:{}};function Oa(d){return d==="local"?localStorage:sessionStorage}function G5(d,l,I){var c,G;const a=(c=I==null?void 0:I.serializer)!=null?c:JSON,b=(G=I==null?void 0:I.storage)!=null?G:"local",W=typeof window<"u"&&typeof document<"u",t=W?Oa(b):null;function n(s,o){t==null||t.setItem(s,a.stringify(o))}if(!T9[b][d]){const s=K1(l,F=>{const X=t==null?void 0:t.getItem(d);if(X&&F(a.parse(X)),W&&b=="local"){const R=i=>{i.key===d&&F(i.newValue?a.parse(i.newValue):null)};return window.addEventListener("storage",R),()=>window.removeEventListener("storage",R)}}),{subscribe:o,set:A}=s;T9[b][d]={set(F){n(d,F),A(F)},update(F){return s.update(X=>{const R=F(X);return n(d,R),R})},subscribe:o}}return T9[b][d]}const N0=G5("chats",[]),s4=G5("latestModelMap",{}),Z1=G5("global",{}),Pa={}.VITE_OPENAI_API_KEY||"",Yl=G5("apiKey",Pa);let _1=K1(0),_5=K1(!1),$5=K1(!1),m3=K1(!1),l9=K1(""),Il=K1([]),OI=K1(!1),Dl=K1(0),Tl=G5("lastChatId",0);const m4=Bl(),Mc=()=>e0(Yl),K4=()=>e0(N0).reduce((I,c)=>Math.max(I,c.id),0)+1,Ol=(d=void 0)=>{const l=e0(N0),I=K4();d=JSON.parse(JSON.stringify(d||e9("")));const c=l.reduce((G,a)=>(G[a.name]=a,G),{});return l.push({id:I,name:y4(`Chat ${I}`,c),settings:d,messages:[],usage:{},startSession:!1,sessionStarted:!1,created:Date.now(),lastUse:Date.now(),lastAccess:Date.now()}),N0.set(l),rl(I),I},qa=async d=>{const l=e0(N0),I=K4();let c;try{if(c=JSON.parse(d),!c.settings||!c.messages||isNaN(c.id))return N1("Not valid Chat JSON"),0}catch{return N1("Can't parse file JSON"),0}return c.id=I,c.created=Date.now(),await Dc(I,c),l.push(c),N0.set(l),xc(I),I},xc=d=>{const l=e0(N0),I=l.find(G=>G.id===d);if(I.settings||(I.settings={}),zc(I.settings,!1),I.messages.forEach(G=>{G.uuid=G.uuid||H1(),delete G.streaming}),!(I.usage&&!Array.isArray(I.usage)&&typeof I.usage=="object"&&Object.values(I.usage).find(G=>"prompt_tokens"in G))){const G={};I.usage=G}I.startSession===void 0&&(I.startSession=!1),I.sessionStarted===void 0&&(I.sessionStarted=!!I.messages.find(G=>G.role==="user")),N0.set(l)},zc=(d,l)=>{if(Object.entries(Bl()).forEach(([I,c])=>{const G=d[I];d[I]=G==null?c:d[I]}),"useSummarization"in d||!("continuousChat"in d)){const I=d.useSummarization;I&&!d.summaryPrompt?d.continuousChat="fifo":I?d.continuousChat="summary":d.continuousChat="",delete d.useSummarization}return l&&Object.keys(wl()).forEach(I=>{delete d[I]}),d},Tc=(d,l=!1)=>{const I=e0(N0),c=I.find(b=>b.id===d),G=e9(c.settings.profile),a=wl();l&&Object.entries(Bl()).forEach(([b,W])=>{c.settings[b]=W}),Object.entries(G).forEach(([b,W])=>{a[b]||(c.settings[b]=W)}),N0.set(I)},_a=()=>{N0.set([]),C7()},v1=()=>{const d=e0(N0);N0.set(d)},$1=d=>e0(N0).find(I=>I.id===d),E0=d=>e0(N0).find(I=>I.id===d).settings,PI=(d,l,I)=>{const c=e0(N0),G=c.find(b=>b.id===d);let a=G.usage[I];a||(a={prompt_tokens:0,completion_tokens:0,total_tokens:0},G.usage[I]=a),a.completion_tokens+=(l==null?void 0:l.completion_tokens)||0,a.prompt_tokens+=(l==null?void 0:l.prompt_tokens)||0,a.total_tokens+=(l==null?void 0:l.total_tokens)||0,N0.set(c)},$a=(d,l,I)=>{const c=e0(N0),G=c.find(b=>b.id===d);let a=G.usage[I];a||(a={prompt_tokens:0,completion_tokens:0,total_tokens:0},G.usage[I]=a),a.completion_tokens-=(l==null?void 0:l.completion_tokens)||0,a.prompt_tokens-=(l==null?void 0:l.prompt_tokens)||0,a.total_tokens-=(l==null?void 0:l.total_tokens)||0,N0.set(c)},A3=d=>e0(Dl)===d?e0(Il):$1(d).messages;let qI;const _I=d=>{if(clearTimeout(qI),!d){Dl.set(0),Tl.set(0),Il.set([]);return}qI=setTimeout(()=>{Dl.set(d),Tl.set(d),Il.set($1(d).messages)},10)},$I={},l8=(d,l)=>{clearTimeout($I[d]),$I[d]=setTimeout(()=>{$1(d).lastUse=l,v1()},500)},f9={},al=(d,l)=>{e0(Dl)===d?(Il.set(l),clearTimeout(f9[d]),f9[d]=setTimeout(()=>{$1(d).messages=l,v1(),l8(d,Date.now())},200)):(clearTimeout(f9[d]),$1(d).messages=l,v1(),l8(d,Date.now()))},dl=d=>{al(d,A3(d))},j9=(d,l)=>{g3(d,{content:l})},g3=(d,l)=>{const I=A3(d);l.uuid||(l.uuid=H1()),l.created||(l.created=Date.now()),I.indexOf(l)<0&&(I[I.length]=l),al(d,I)},Pl=(d,l)=>A3(d).find(I=>I.uuid===l),lb=(d,l,I)=>{const c=A3(d),G=c.findIndex(a=>a.uuid===l.uuid);if(G===void 0||G<0){console.error("Couldn't insert after message:",l);return}I.forEach(a=>{a.uuid=a.uuid||H1(),a.created=a.created||Date.now()}),c.splice(G+1,0,...I),al(d,c.filter(a=>!0))},fc=(d,l)=>{const I=Pl(d,l);if(I&&I.summarized)throw new Error("Unable to delete summarized message");I&&I.summary&&(I.summary.forEach(c=>{const G=Pl(d,c);G&&delete G.summarized}),delete I.summary),dl(d),n9(d,l)},n9=(d,l)=>{const I=A3(d),c=I.findIndex(a=>a.uuid===l),G=Pl(d,l);if(G!=null&&G.summarized)throw new Error("Unable to delete summarized message");if(G!=null&&G.summary)throw new Error("Unable to directly delete message summary");if(c<0){console.error(`Unable to find and delete message with ID: ${l}`);return}G!=null&&G.image&&ac(d,G.image.id),I.splice(c,1),al(d,I.filter(a=>!0))},E4=(d,l)=>{l.forEach(I=>{I.image&&ac(d,I.image.id)})},I8=(d,l)=>{const I=A3(d),c=I.findIndex(b=>b.uuid===l),G=Pl(d,l);if(G&&G.summarized)throw new Error("Unable to truncate from a summarized message");if(c<0)throw new Error(`Unable to find message with ID: ${l}`);const a=I.splice(c+1);E4(d,a),al(d,I.filter(b=>!0))},jc=d=>{E4(d,A3(d)),al(d,[])},ul=d=>{const l=e0(N0);E4(d,A3(d)||[]),N0.set(l.filter(I=>I.id!==d))},Dc=async(d,l)=>{const I=l.messages;for(let c=0;c{const l=e0(N0),I=l.find(b=>b.id===d),c=l.reduce((b,W)=>(b[W.name]=W,b),{}),G=y4(I.name,c),a=JSON.parse(JSON.stringify(I));a.id=K4(),a.created=Date.now(),a.name=G,await Dc(d,a),l.push(a),N0.set(l)},ql=(d,l)=>{switch(d){case"number":case"select-number":return l=parseFloat(l),isNaN(l)&&(l=null),l;case"boolean":return typeof l=="string"&&(l=l.trim().toLocaleLowerCase()),l==="true"||l==="yes"||(l?l!=="false"&&l!=="no"&&!!l:!1);default:return l}},db=(d,l,I)=>{const c=x1(l);if(c)return xl(d,c,I);if(!(l in m4))throw new Error("Invalid chat setting: "+l);const G=m4[l];if(G==null)throw new Error('Unable to determine setting type for "'+l+' from default of "'+G+'"');const W=e0(N0).find(t=>t.id===d).settings;W[l]=ql(typeof G,I)},xl=(d,l,I)=>{const c=e0(N0),G=c.find(b=>b.id===d);let a=G.settings;a||(a={},G.settings=a),a[l.key]=ql(l.type,I),N0.set(c)},cb=(d,l)=>{const c=e0(N0).find(a=>a.id===d);let G=c.settings&&c.settings[l.key];return G=G===void 0?null:G,!l.forceApi&&G===m4[l.key]&&(G=null),G},r3=(d,l)=>Gb(va(d),l),Gb=(d,l)=>{const I=e0(Z1);I[d.key]=ql(d.type,l),Z1.set(I)},J4=()=>e0(Z1),ab=()=>e0(Z1).profiles||{},bb=(d,l)=>{if(H4(l))throw new Error("Sorry, you can't delete a static profile.");const c=e0(N0).find(a=>a.id===d),G=e0(Z1);if(G.defaultProfile===c.settings.profile)throw new Error("Sorry, you can't delete the default profile.");delete G.profiles[l],Z1.set(G),c5(!0)},L5=d=>{const l=e0(Z1);let I=l.profiles;I||(I={},l.profiles=I),d.profile||(d.profile=H1());const c=d.profileName&&d.profileName.trim().toLocaleLowerCase();if(Object.values(I).find(b=>b.profile!==d.profile&&b.profileName&&b.profileName.trim().toLocaleLowerCase()===c))throw new Error(`Sorry, another profile already exists with the name "${d.profileName}"`);if(!c)throw new Error("Sorry, you need to enter a valid name for your profile.");if(!d.characterName||d.characterName.length<3)throw new Error("Your profile's character needs a valid name.");H4(d.profile)&&(d.profileName=P5(d.profileName),d.profile=H1());const a=JSON.parse(JSON.stringify(d));Object.keys(wl()).forEach(b=>{delete a[b]}),I[d.profile]=a,Z1.set(l),d.isDirty=!1,v1(),c5(!0)},D9=()=>{const d=e0(Z1);return gl[d.chatSort]||gl[vc.chatSort]},Wb=d=>{const l=e0(Z1);l.chatSort=gl[d]?d:vc.chatSort,Z1.set(l),_1.set(e0(_1)+1)},y4=(d,l)=>{if(!l[d])return d;const I=d.match(/^(.*[^0-9]+)([- ])*([0-9]+)$/);let c=1,G=" ";I&&(d=I[1],G=I[2]||"",c=parseInt(I[3]));let a=`${d}${G}${c}`;for(;l[a];)c++,a=`${d}${G}${c}`;return a},tb=d=>e0(s4)[d]||d,eb=(d,l)=>{const I=e0(s4);I[d]=l,s4.set(I)},Oc="/chatgpt-web/assets/logo-3651fe68.svg",w5=parseFloat;function p4(d,l=";"){let I;if(Array.isArray(d))I=d.filter(c=>c);else{I=[];for(const c in d)d[c]&&I.push(`${c}:${d[c]}`)}return I.join(l)}function nb(d,l,I,c){let G,a;const b="1em";let W,t,n,s="-.125em";const o="visible";return c&&(n="center",a="1.25em"),I&&(G=I),l&&(l=="lg"?(t="1.33333em",W=".75em",s="-.225em"):l=="xs"?t=".75em":l=="sm"?t=".875em":t=l.replace("x","em")),p4([p4({float:G,width:a,height:b,"line-height":W,"font-size":t,"text-align":n,"vertical-align":s,"transform-origin":"center",overflow:o}),d])}function Zb(d,l,I,c,G,a=1,b="",W=""){let t=1,n=1;return G&&(G=="horizontal"?t=-1:G=="vertical"?n=-1:t=n=-1),p4([`translate(${w5(l)*a}${b},${w5(I)*a}${b})`,`scale(${t*w5(d)},${n*w5(d)})`,c&&`rotate(${c}${W})`]," ")}function d8(d){let l,I,c,G,a,b,W,t;function n(A,F){return typeof A[10][4]=="string"?mb:sb}let s=n(d),o=s(d);return{c(){l=j3("svg"),I=j3("g"),c=j3("g"),o.c(),p(c,"transform",d[12]),p(I,"transform",G="translate("+d[10][0]/2+" "+d[10][1]/2+")"),p(I,"transform-origin",a=d[10][0]/4+" 0"),p(l,"id",b=d[1]||void 0),p(l,"class",W="svelte-fa "+d[0]+" svelte-1cj2gr0"),p(l,"style",d[11]),p(l,"viewBox",t="0 0 "+d[10][0]+" "+d[10][1]),p(l,"aria-hidden","true"),p(l,"role","img"),p(l,"xmlns","http://www.w3.org/2000/svg"),n2(l,"pulse",d[4]),n2(l,"spin",d[3])},m(A,F){L(A,l,F),V(l,I),V(I,c),o.m(c,null)},p(A,F){s===(s=n(A))&&o?o.p(A,F):(o.d(1),o=s(A),o&&(o.c(),o.m(c,null))),F&4096&&p(c,"transform",A[12]),F&1024&&G!==(G="translate("+A[10][0]/2+" "+A[10][1]/2+")")&&p(I,"transform",G),F&1024&&a!==(a=A[10][0]/4+" 0")&&p(I,"transform-origin",a),F&2&&b!==(b=A[1]||void 0)&&p(l,"id",b),F&1&&W!==(W="svelte-fa "+A[0]+" svelte-1cj2gr0")&&p(l,"class",W),F&2048&&p(l,"style",A[11]),F&1024&&t!==(t="0 0 "+A[10][0]+" "+A[10][1])&&p(l,"viewBox",t),F&17&&n2(l,"pulse",A[4]),F&9&&n2(l,"spin",A[3])},d(A){A&&y(l),o.d()}}}function sb(d){let l,I,c,G,a,b,W,t,n,s;return{c(){l=j3("path"),b=j3("path"),p(l,"d",I=d[10][4][0]),p(l,"fill",c=d[6]||d[2]||"currentColor"),p(l,"fill-opacity",G=d[9]!=!1?d[7]:d[8]),p(l,"transform",a="translate("+d[10][0]/-2+" "+d[10][1]/-2+")"),p(b,"d",W=d[10][4][1]),p(b,"fill",t=d[5]||d[2]||"currentColor"),p(b,"fill-opacity",n=d[9]!=!1?d[8]:d[7]),p(b,"transform",s="translate("+d[10][0]/-2+" "+d[10][1]/-2+")")},m(o,A){L(o,l,A),L(o,b,A)},p(o,A){A&1024&&I!==(I=o[10][4][0])&&p(l,"d",I),A&68&&c!==(c=o[6]||o[2]||"currentColor")&&p(l,"fill",c),A&896&&G!==(G=o[9]!=!1?o[7]:o[8])&&p(l,"fill-opacity",G),A&1024&&a!==(a="translate("+o[10][0]/-2+" "+o[10][1]/-2+")")&&p(l,"transform",a),A&1024&&W!==(W=o[10][4][1])&&p(b,"d",W),A&36&&t!==(t=o[5]||o[2]||"currentColor")&&p(b,"fill",t),A&896&&n!==(n=o[9]!=!1?o[8]:o[7])&&p(b,"fill-opacity",n),A&1024&&s!==(s="translate("+o[10][0]/-2+" "+o[10][1]/-2+")")&&p(b,"transform",s)},d(o){o&&y(l),o&&y(b)}}}function mb(d){let l,I,c,G;return{c(){l=j3("path"),p(l,"d",I=d[10][4]),p(l,"fill",c=d[2]||d[5]||"currentColor"),p(l,"transform",G="translate("+d[10][0]/-2+" "+d[10][1]/-2+")")},m(a,b){L(a,l,b)},p(a,b){b&1024&&I!==(I=a[10][4])&&p(l,"d",I),b&36&&c!==(c=a[2]||a[5]||"currentColor")&&p(l,"fill",c),b&1024&&G!==(G="translate("+a[10][0]/-2+" "+a[10][1]/-2+")")&&p(l,"transform",G)},d(a){a&&y(l)}}}function pb(d){let l,I=d[10][4]&&d8(d);return{c(){I&&I.c(),l=G0()},m(c,G){I&&I.m(c,G),L(c,l,G)},p(c,[G]){c[10][4]?I?I.p(c,G):(I=d8(c),I.c(),I.m(l.parentNode,l)):I&&(I.d(1),I=null)},i:U2,o:U2,d(c){I&&I.d(c),c&&y(l)}}}function ob(d,l,I){let{class:c=""}=l,{id:G=""}=l,{style:a=""}=l,{icon:b}=l,{size:W=""}=l,{color:t=""}=l,{fw:n=!1}=l,{pull:s=""}=l,{scale:o=1}=l,{translateX:A=0}=l,{translateY:F=0}=l,{rotate:X=""}=l,{flip:R=!1}=l,{spin:i=!1}=l,{pulse:K=!1}=l,{primaryColor:k=""}=l,{secondaryColor:J=""}=l,{primaryOpacity:C=1}=l,{secondaryOpacity:N=.4}=l,{swapOpacity:B=!1}=l,j,c2,s2;return d.$$set=x=>{"class"in x&&I(0,c=x.class),"id"in x&&I(1,G=x.id),"style"in x&&I(13,a=x.style),"icon"in x&&I(14,b=x.icon),"size"in x&&I(15,W=x.size),"color"in x&&I(2,t=x.color),"fw"in x&&I(16,n=x.fw),"pull"in x&&I(17,s=x.pull),"scale"in x&&I(18,o=x.scale),"translateX"in x&&I(19,A=x.translateX),"translateY"in x&&I(20,F=x.translateY),"rotate"in x&&I(21,X=x.rotate),"flip"in x&&I(22,R=x.flip),"spin"in x&&I(3,i=x.spin),"pulse"in x&&I(4,K=x.pulse),"primaryColor"in x&&I(5,k=x.primaryColor),"secondaryColor"in x&&I(6,J=x.secondaryColor),"primaryOpacity"in x&&I(7,C=x.primaryOpacity),"secondaryOpacity"in x&&I(8,N=x.secondaryOpacity),"swapOpacity"in x&&I(9,B=x.swapOpacity)},d.$$.update=()=>{d.$$.dirty&16384&&I(10,j=b&&b.icon||[0,0,"",[],""]),d.$$.dirty&237568&&I(11,c2=nb(a,W,s,n)),d.$$.dirty&8126464&&I(12,s2=Zb(o,A,F,X,R,512))},[c,G,t,i,K,k,J,C,N,B,j,c2,s2,a,b,W,n,s,o,A,F,X,R]}class Ab extends s0{constructor(l){super(),Z0(this,l,ob,pb,d0,{class:0,id:1,style:13,icon:14,size:15,color:2,fw:16,pull:17,scale:18,translateX:19,translateY:20,rotate:21,flip:22,spin:3,pulse:4,primaryColor:5,secondaryColor:6,primaryOpacity:7,secondaryOpacity:8,swapOpacity:9})}}const $2=Ab;var Qb={prefix:"far",iconName:"message",icon:[512,512,["comment-alt"],"f27a","M160 368c26.5 0 48 21.5 48 48v16l72.5-54.4c8.3-6.2 18.4-9.6 28.8-9.6H448c8.8 0 16-7.2 16-16V64c0-8.8-7.2-16-16-16H64c-8.8 0-16 7.2-16 16V352c0 8.8 7.2 16 16 16h96zm48 124l-.2 .2-5.1 3.8-17.1 12.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3V474.7v-6.4V468v-4V416H112 64c-35.3 0-64-28.7-64-64V64C0 28.7 28.7 0 64 0H448c35.3 0 64 28.7 64 64V352c0 35.3-28.7 64-64 64H309.3L208 492z"]},Fb={prefix:"far",iconName:"square-minus",icon:[448,512,[61767,"minus-square"],"f146","M64 80c-8.8 0-16 7.2-16 16V416c0 8.8 7.2 16 16 16H384c8.8 0 16-7.2 16-16V96c0-8.8-7.2-16-16-16H64zM0 96C0 60.7 28.7 32 64 32H384c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM152 232H296c13.3 0 24 10.7 24 24s-10.7 24-24 24H152c-13.3 0-24-10.7-24-24s10.7-24 24-24z"]},ub={prefix:"far",iconName:"clipboard",icon:[384,512,[128203],"f328","M280 64h40c35.3 0 64 28.7 64 64V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128C0 92.7 28.7 64 64 64h40 9.6C121 27.5 153.3 0 192 0s71 27.5 78.4 64H280zM64 112c-8.8 0-16 7.2-16 16V448c0 8.8 7.2 16 16 16H320c8.8 0 16-7.2 16-16V128c0-8.8-7.2-16-16-16H304v24c0 13.3-10.7 24-24 24H192 104c-13.3 0-24-10.7-24-24V112H64zm128-8a24 24 0 1 0 0-48 24 24 0 1 0 0 48z"]},Vb={prefix:"far",iconName:"square-plus",icon:[448,512,[61846,"plus-square"],"f0fe","M64 80c-8.8 0-16 7.2-16 16V416c0 8.8 7.2 16 16 16H384c8.8 0 16-7.2 16-16V96c0-8.8-7.2-16-16-16H64zM0 96C0 60.7 28.7 32 64 32H384c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V96zM200 344V280H136c-13.3 0-24-10.7-24-24s10.7-24 24-24h64V168c0-13.3 10.7-24 24-24s24 10.7 24 24v64h64c13.3 0 24 10.7 24 24s-10.7 24-24 24H248v64c0 13.3-10.7 24-24 24s-24-10.7-24-24z"]};const Xb=d=>{const I=e0(N0).find(t=>t.id===d),c=I.messages;let G=`# ${I.name} `;c.forEach(t=>{const n=t.role,s=t.content,o=`## ${n} ${s} diff --git a/index.html b/index.html index 5b175711..5cd9678d 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ ChatGPT-web - +