new build
Browse files
dist/assets/{index-CUpq6zXX.js → index-Cjniv5yr.js}
RENAMED
@@ -5,4 +5,4 @@
|
|
5 |
*/var Re;function yt(){return Re||(Re=1,function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",a=0;a<arguments.length;a++){var c=arguments[a];c&&(r=s(r,o(c)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var a="";for(var c in r)t.call(r,c)&&r[c]&&(a=s(a,c));return a}function s(r,a){return a?r?r+" "+a:r+a:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()}(re)),re.exports}var bt=yt();const ne=vt(bt),wt="_spinnerSquare_4vgl0_1",$t="_square1_4vgl0_14",kt="_square2_4vgl0_18",St="_square3_4vgl0_22",B={spinnerSquare:wt,square1:$t,"square-anim":"_square-anim_4vgl0_1",square2:kt,square3:St};function xt(e){return _("div",{className:ne(B.spinnerSquare,e.className),children:[_("div",{className:B.square1}),_("div",{className:B.square2}),_("div",{className:B.square3})]})}const Nt="_spinner_1pqws_1",Tt="_list_1pqws_5",Ct="_highlight_1pqws_44",Pt="_head_1pqws_48",It="_generationSettings_1pqws_52",U={spinner:Nt,list:Tt,highlight:Ct,head:Pt,generationSettings:It},H={home:"home",topic:"topic",settings:"settings"},jt="_btn_1ts7o_1",qt="_disabled_1ts7o_18",Ht="_secondary_1ts7o_22",Lt="_spinner_1ts7o_32",Rt="_load3_1ts7o_1",V={btn:jt,disabled:qt,secondary:Ht,spinner:Lt,load3:Rt};function Y(e){const t=e.disabled||e.loading,n=ne(V.btn,{[V.secondary]:e.secondary},"button",e.className,{[V.disabled]:t});let o;return e.loading&&(o=_("span",{className:V.spinner})),_("button",{type:"button",onClick:()=>{t||e.onClick()},className:n,disabled:t,title:e.title,children:[o,e.children]})}const At=/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/;function ge(e){console.log("iso8601ToTokens",e);const t=e.match(At),n=t[1],o=Ye[parseInt(t[2],10)-1],s=t[3],r=t[4],a=t[5],c=t[6];return`${s} ${o} ${n} à ${r}:${a}:${c}`}const Et=/(\d{1,2}) ([a-zA-Z\u00C0-\u024F]+) (\d{4}) à (\d{2}):(\d{2}):(\d{2})/;function Ft(e){console.log("tokensToIso8601",e);const t=e.match(Et);if(!t)throw new Error("Invalid date format");const[,n,o,s,r,a,c]=t,u=(Ye.indexOf(o)+1).toString();if(!u)throw new Error("Invalid month name");return`${s}-${u.padStart(2,"0")}-${n.padStart(2,"0")}T${r}:${a}:${c}`}const Ye=["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],Ot="_formGroup_b3g81_1",Ut={formGroup:Ot};function ee(e){return _("div",{className:Ut.formGroup,children:e.children})}const Mt="_rangeSlider_1trvf_1",Dt="_rangeSlider__values_1trvf_99",zt="_progress_1trvf_116",Ae={rangeSlider:Mt,rangeSlider__values:Dt,progress:zt};function ve(e){return _("div",{className:Ae.rangeSlider,style:`--min:${e.min}; --max:${e.max}; --step:${e.step}; --value:${e.value}; --text-value:"${e.value}";`,children:[_("input",{name:e.name,type:"range",min:e.min,max:e.max,step:e.step,value:e.value,onInput:t=>e.onChange(Number(t.target.value))}),_("output",{}),_("div",{className:Ae.progress})]})}function Gt(e){const t=me(()=>e.topics===null||e.topics.length<1?e.topics:e.topics.sort((n,o)=>n.posts.length<1||o.posts.length<1?0:o.posts[o.posts.length-1].date.localeCompare(n.posts[n.posts.length-1].date)),[e.topics]);return _("div",{children:[t===null?_(xt,{className:U.spinner}):_(Wt,{topics:t,setRoute:e.setRoute,latestGeneratedTopicId:e.latestGeneratedTopicId}),_("div",{children:[_("h2",{children:"Nouveau sujet"}),_("div",{className:U.generationSettings,children:_(ee,{children:[_("label",{for:"postCount",children:"Nombre de posts"}),_(ve,{name:"postCount",value:e.settings.postCount,onChange:n=>e.setSettings({...e.settings,postCount:n}),min:1,max:10,step:1})]})}),_(Y,{onClick:()=>e.generateTopic(e.settings.postCount),secondary:!0,loading:e.pendingGeneration,children:"Générer"})]}),_("hr",{})]})}function Wt(e){return _("ul",{className:U.list,children:[_("li",{className:U.head,children:[_("span",{children:"Sujet"}),_("span",{children:"Auteur"}),_("span",{children:"NB"}),_("span",{children:"Dernier msg"})]}),e.topics.length<1&&_("li",{children:[_("span",{children:"Aucun sujet"}),_("span",{}),_("span",{}),_("span",{})]}),e.topics.map(t=>_("li",{className:ne({[U.highlight]:t.id===e.latestGeneratedTopicId}),children:[_("span",{children:_("a",{href:"#",onClick:n=>{n.preventDefault(),e.setRoute(H.topic,0,t.id)},children:t.title})}),_("span",{children:t.posts[0].user}),_("span",{children:t.posts.length}),_("span",{children:ge(t.posts[t.posts.length-1].date)})]}))]})}const Bt="_post_uuidr_1",Vt="_postHeader_uuidr_12",Jt="_avatar_uuidr_23",Kt="_user_uuidr_31",Zt="_date_uuidr_39",Qt="_generationSettings_uuidr_46",E={post:Bt,postHeader:Vt,avatar:Jt,user:Kt,date:Zt,generationSettings:Qt},Xt="_wrapper_cfqzy_1",Yt={wrapper:Xt},en=[[":)","1"],[":snif:","20"],[":gba:","17"],[":g)","3"],[":-)","46"],[":snif2:","13"],[":bravo:","69"],[":d)","4"],[":hap:","18"],[":ouch:","22"],[":pacg:","9"],[":cd:","5"],[":-)))","23"],[":ouch2:","57"],[":pacd:","10"],[":cute:","nyu"],[":content:","24"],[":p)","7"],[":-p","31"],[":noel:","11"],[":oui:","37"],[":(","45"],[":peur:","47"],[":question:","2"],[":cool:","26"],[":-(","14"],[":coeur:","54"],[":mort:","21"],[":rire:","39"],[":-((","15"],[":fou:","50"],[":sleep:","27"],[":-D","40"],[":nonnon:","25"],[":fier:","53"],[":honte:","30"],[":rire2:","41"],[":non2:","33"],[":sarcastic:","43"],[":monoeil:","34"],[":o))","12"],[":nah:","19"],[":doute:","28"],[":rouge:","55"],[":ok:","36"],[":non:","35"],[":malade:","8"],[":fete:","66"],[":sournois:","67"],[":hum:","68"],[":ange:","60"],[":diable:","61"],[":gni:","62"],[":play:","play"],[":desole:","65"],[":spoiler:","63"],[":merci:","58"],[":svp:","59"],[":sors:","56"],[":salut:","42"],[":rechercher:","38"],[":hello:","29"],[":up:","44"],[":bye:","48"],[":gne:","51"],[":lol:","32"],[":dpdr:","49"],[":dehors:","52"],[":hs:","64"],[":banzai:","70"],[":bave:","71"],[":pf:","pf"],[":cimer:","cimer"],[":ddb:","ddb"],[":pave:","pave"],[":objection:","objection"],[":siffle:","siffle"]];function tn(e){const t=me(()=>{const n=rn(e.raw);return on(n).replace(/\n/g,"<br/>")},[e.raw]);return _("div",{className:Yt.wrapper,dangerouslySetInnerHTML:{__html:t}})}const nn=[[/(^| )https?:\/\/image\.noelshack\.com\/(?:fichiers|minis)(\S+)/gm,'$1<img width="68" height="51" alt="noelshak" src="https://image.noelshack.com/minis/$2"/>'],[/(^| )https:\/\/vocaroo.com\/(.+)/gm,'$1<div><iframe width="300" height="60" src="https://vocaroo.com/embed/$2?autoplay=0" frameborder="0" allow="autoplay"></iframe></div>'],[/^(?:>.*(?:\n>.*)*)/g,(e,t)=>{const n=e.exec(t);if(!n)return t;console.log(n);const o=n.index,s=n[0].length;return t.substring(0,o)+`<blockquote>${n[0].replace(/^>/gm,"")}</blockquote>`+t.substring(o+s)}],[/<spoil>(.*?)<\/spoil>/gm,(e,t)=>t.replace(e,(n,o)=>{const s=(Math.random()+1).toString(36).substring(2);return`<span class="bloc-spoil-jv"><input type="checkbox" id="${s}" class="open-spoil"><label class="barre-head" for="${s}"><span class="txt-spoil">Spoil</span></label><span class="contenu-spoil">${o}</span></span>`})],[/(^| )(https?:\/\/\S+)/gm,'$1<a href="$2" target="_blank">$2</a>'],...en.map(e=>[new RegExp("(?:(^| )"+e[0].replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+")","gm"),`$1<img src="https://image.jeuxvideo.com/smileys_img/${e[1]}.gif" alt="${e[0]}"/>`])];function on(e){do for(const[t,n]of nn)n instanceof Function?e=n(t,e):e=e.replace(t,n);while(!1);return e}function rn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function sn(e){return console.log(e.topic),_("div",{children:[e.topic.posts.map(t=>_(an,{post:t})),_("div",{children:[_("h2",{children:"Ajout de posts"}),_("div",{className:E.generationSettings,children:_(ee,{children:[_("label",{htmlFor:"postCount",children:"Nombre de posts"}),_(ve,{name:"postCount",value:e.settings.postCount,onChange:t=>e.setSettings({...e.settings,postCount:t}),min:1,max:10,step:1})]})}),_(Y,{onClick:()=>e.addPosts(e.topic.id,e.settings.postCount),secondary:!0,loading:e.pendingGeneration,children:"Générer"})]}),_("hr",{})]})}function an(e){return _("div",{className:E.post,children:[_("div",{className:E.postHeader,children:[_("img",{src:"https://image.jeuxvideo.com/avatar-sm/default.jpg",className:E.avatar,alt:"ahi"}),_("div",{className:E.user,children:e.post.user}),_("div",{className:E.date,children:ge(e.post.date)})]}),_(tn,{raw:e.post.content})]})}const _n="_wrapper_1dmrl_1",cn="_icon_1dmrl_6",ln="_input_1dmrl_14",se={wrapper:_n,icon:cn,input:ln},un=({type:e,icon:t,value:n,placeholder:o,onChange:s,className:r,disabled:a,id:c,name:u})=>{const[l,f]=q(!1),i=ne(se.input,"generic-input",r,{focused:l,disabled:a}),h=g=>{console.log("handleInputChange");const k=g.target;s(e==="number"?parseFloat(k.value)||0:k.value)},d=t;return _("div",{className:se.wrapper,children:[_(d,{className:se.icon,size:18}),_("input",{title:"Le pseudo doit avoir une longueur comprise entre 3 et 15 caractères.",type:e,id:c,name:u,value:n,placeholder:o,onInput:h,className:i,disabled:a,onFocus:()=>f(!0),onBlur:()=>f(!1)})]})},dn=e=>{const t=e.color||"currentColor",n=e.size||24;return delete e.color,delete e.size,R("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:t,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},e),R("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),R("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}))},fn=e=>{const t=e.color||"currentColor",n=e.size||24;return delete e.color,delete e.size,R("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:t,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},e),R("circle",{cx:"12",cy:"12",r:"3"}),R("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"}))};function hn(e){return _("div",{children:_("form",{children:[_(ee,{children:[_("label",{htmlFor:"api",children:"API"}),_(un,{type:"text",placeholder:"URl d'API ex: https://ouruq7zepnehg2-5000.proxy.runpod.net/",icon:dn,value:e.settings.apiURL,onChange:t=>e.setSettings({...e.settings,apiURL:t})})]}),_(ee,{children:[_("label",{for:"temperature",children:"Temperature"}),_(ve,{name:"temperature",value:e.settings.temperature,onChange:t=>e.setSettings({...e.settings,temperature:t}),min:.1,max:2,step:.1})]}),_("div",{children:_(Y,{onClick:()=>{e.resetApp()},secondary:!0,title:"Tout réinitialiser",children:"Réinitialiser"})}),_("br",{}),_("div",{children:_(Y,{onClick:()=>{history.go(-1)},children:"Retour"})})]})})}const pn="_breadcrumbs_145yl_1",mn="_actions_145yl_10",Ee={breadcrumbs:pn,actions:mn};function gn(e){return _("div",{children:[_("nav",{className:Ee.breadcrumbs,children:[e.breadcrumbs,_("div",{className:Ee.actions,children:_("a",{href:"#",title:"Paramètres",onClick:t=>{t.preventDefault(),e.setRoute(H.settings)},children:_(fn,{size:18})})})]}),_("h2",{children:e.title}),e.children]})}const ye="settings",Fe={apiURL:"http://localhost:5000",temperature:.9,postCount:3};function Oe(){const e=localStorage.getItem(ye);return e?{...Fe,...JSON.parse(e)}:Fe}function vn(e){localStorage.setItem(ye,JSON.stringify(e))}function yn(){localStorage.removeItem(ye)}function bn(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}const wn=/Sujet\s+:\s+"(.+?)"?<\|eot_id\|>/,$n=/<\|im_pseudo\|>([^<]+)<\|end_pseudo\|>/,kn=/<\|im_date\|>([^<]+)<\|end_date\|>/,Sn=/<\|begin_of_post\|>([\s\S]+)(?:<\|end_of_post\|>)?$/;function xn(e){const t={id:bn(),title:"",posts:[]};for(const n of e.split("<|end_of_post|>").slice(0,-1)){if(console.log("Post tokens:"),console.log(n),t.posts.length<1){const o=n.match(wn);console.log(`title: ${o[1]}`),t.title=o[1]}t.posts=t.posts.concat(et(n))}return t}function et(e){const t=[];for(const n of e.split("<|end_of_post|>")){if(n.length<1)continue;console.log("Post tokens:"),console.log(n);const o=n.match($n);console.log(`user: ${o[1]}`);const s=n.match(kn);console.log(`date: ${s[1]}`);const r=n.match(Sn);console.log(`content: ${r[1]}`),t.push({user:o[1],date:Ft(s[1]),content:r[1]})}return t}function Nn(e){if(e.posts.length===0)throw new Error("Topic must have at least one post");const t=e.posts.map(o=>Tn(o,e.posts[0].user)).flat().join("");return["<|start_header_id|><|sujet|><|end_header_id|>","",`Sujet : "${e.title}"`].join(`
|
6 |
`)+t}function Tn(e,t){return[`<|eot_id|><|start_header_id|><|${e.user===t?"autheur":"khey"}|>`,"<|end_header_id|>","",`<|im_pseudo|>${e.user}<|end_pseudo|>`,`<|im_date|>Le ${ge(e.date)}<|end_date|>`,"",`<|begin_of_post|>${e.content}<|end_of_post|>`].join(`
|
7 |
`)}async function Cn(e,t){console.log(e);const n=await tt(e,"<|start_header_id|>",t);return xn(n)}async function Pn(e,t,n){const o=await tt(e,Nn(n),t);return console.log("rawOutput"),console.log(o),et(o)}const In="<|end_of_post|>";async function tt(e,t,n){const o=new AbortController,s=await fetch(new URL("/v1/completions",e.apiURL),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:t,temperature:e.temperature,max_tokens:2e3,stream:!0,skip_special_tokens:!1}),signal:o.signal});if(!s.ok)throw new Error(`Failed to fetch API (${s.status} ${s.statusText}): ${await s.text()}`);console.log(`Fetching topic with ${n} posts...`);let r=0,a="",c=null;try{await s.body.pipeThrough(new TextDecoderStream("utf-8")).pipeTo(new WritableStream({write(u){for(const l of u.split(`
|
8 |
-
`)){if(!l.startsWith("data:"))continue;const f=JSON.parse(l.slice(6)),i=f.choices[0].text;if(console.log(i),a+=f.choices[0].text,i.includes(In)){if(r++,r>=n){c="custom_stop",o.abort();break}}else c=f.choices[0].finish_reason}}}))}catch(u){if(u.name!=="AbortError")throw u}return console.log("Done fetching data"),console.log(`Finish reason: ${c}`),console.log(`Tokens: ${a}`),a}function jn(){const[e,t]=q(H.home),[n,o]=q(0),[s,r]=q(null),[a,c]=q(mt),[u,l]=q(null),[f,i]=q(!1);W(()=>{console.log("save !"),gt(a)},[a]);const h=async y=>{i(!0);const x=await Cn(g,y);l(x.id),c(T=>[...T,x]),i(!1)},d=async(y,x)=>{i(!0);const T=await Pn(g,x,a.find(C=>C.id===y)),S=[...a],j=S.findIndex(C=>C.id===y);S[j].posts=S[j].posts.concat(T),c(S),i(!1)},[g,k]=q(Oe);W(()=>{vn(g)},[g]);const w=()=>{yn(),k(Oe),c([])},m=je(()=>{const y=new URL(window.
|
|
|
5 |
*/var Re;function yt(){return Re||(Re=1,function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",a=0;a<arguments.length;a++){var c=arguments[a];c&&(r=s(r,o(c)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var a="";for(var c in r)t.call(r,c)&&r[c]&&(a=s(a,c));return a}function s(r,a){return a?r?r+" "+a:r+a:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()}(re)),re.exports}var bt=yt();const ne=vt(bt),wt="_spinnerSquare_4vgl0_1",$t="_square1_4vgl0_14",kt="_square2_4vgl0_18",St="_square3_4vgl0_22",B={spinnerSquare:wt,square1:$t,"square-anim":"_square-anim_4vgl0_1",square2:kt,square3:St};function xt(e){return _("div",{className:ne(B.spinnerSquare,e.className),children:[_("div",{className:B.square1}),_("div",{className:B.square2}),_("div",{className:B.square3})]})}const Nt="_spinner_1pqws_1",Tt="_list_1pqws_5",Ct="_highlight_1pqws_44",Pt="_head_1pqws_48",It="_generationSettings_1pqws_52",U={spinner:Nt,list:Tt,highlight:Ct,head:Pt,generationSettings:It},H={home:"home",topic:"topic",settings:"settings"},jt="_btn_1ts7o_1",qt="_disabled_1ts7o_18",Ht="_secondary_1ts7o_22",Lt="_spinner_1ts7o_32",Rt="_load3_1ts7o_1",V={btn:jt,disabled:qt,secondary:Ht,spinner:Lt,load3:Rt};function Y(e){const t=e.disabled||e.loading,n=ne(V.btn,{[V.secondary]:e.secondary},"button",e.className,{[V.disabled]:t});let o;return e.loading&&(o=_("span",{className:V.spinner})),_("button",{type:"button",onClick:()=>{t||e.onClick()},className:n,disabled:t,title:e.title,children:[o,e.children]})}const At=/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/;function ge(e){console.log("iso8601ToTokens",e);const t=e.match(At),n=t[1],o=Ye[parseInt(t[2],10)-1],s=t[3],r=t[4],a=t[5],c=t[6];return`${s} ${o} ${n} à ${r}:${a}:${c}`}const Et=/(\d{1,2}) ([a-zA-Z\u00C0-\u024F]+) (\d{4}) à (\d{2}):(\d{2}):(\d{2})/;function Ft(e){console.log("tokensToIso8601",e);const t=e.match(Et);if(!t)throw new Error("Invalid date format");const[,n,o,s,r,a,c]=t,u=(Ye.indexOf(o)+1).toString();if(!u)throw new Error("Invalid month name");return`${s}-${u.padStart(2,"0")}-${n.padStart(2,"0")}T${r}:${a}:${c}`}const Ye=["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"],Ot="_formGroup_b3g81_1",Ut={formGroup:Ot};function ee(e){return _("div",{className:Ut.formGroup,children:e.children})}const Mt="_rangeSlider_1trvf_1",Dt="_rangeSlider__values_1trvf_99",zt="_progress_1trvf_116",Ae={rangeSlider:Mt,rangeSlider__values:Dt,progress:zt};function ve(e){return _("div",{className:Ae.rangeSlider,style:`--min:${e.min}; --max:${e.max}; --step:${e.step}; --value:${e.value}; --text-value:"${e.value}";`,children:[_("input",{name:e.name,type:"range",min:e.min,max:e.max,step:e.step,value:e.value,onInput:t=>e.onChange(Number(t.target.value))}),_("output",{}),_("div",{className:Ae.progress})]})}function Gt(e){const t=me(()=>e.topics===null||e.topics.length<1?e.topics:e.topics.sort((n,o)=>n.posts.length<1||o.posts.length<1?0:o.posts[o.posts.length-1].date.localeCompare(n.posts[n.posts.length-1].date)),[e.topics]);return _("div",{children:[t===null?_(xt,{className:U.spinner}):_(Wt,{topics:t,setRoute:e.setRoute,latestGeneratedTopicId:e.latestGeneratedTopicId}),_("div",{children:[_("h2",{children:"Nouveau sujet"}),_("div",{className:U.generationSettings,children:_(ee,{children:[_("label",{for:"postCount",children:"Nombre de posts"}),_(ve,{name:"postCount",value:e.settings.postCount,onChange:n=>e.setSettings({...e.settings,postCount:n}),min:1,max:10,step:1})]})}),_(Y,{onClick:()=>e.generateTopic(e.settings.postCount),secondary:!0,loading:e.pendingGeneration,children:"Générer"})]}),_("hr",{})]})}function Wt(e){return _("ul",{className:U.list,children:[_("li",{className:U.head,children:[_("span",{children:"Sujet"}),_("span",{children:"Auteur"}),_("span",{children:"NB"}),_("span",{children:"Dernier msg"})]}),e.topics.length<1&&_("li",{children:[_("span",{children:"Aucun sujet"}),_("span",{}),_("span",{}),_("span",{})]}),e.topics.map(t=>_("li",{className:ne({[U.highlight]:t.id===e.latestGeneratedTopicId}),children:[_("span",{children:_("a",{href:"#",onClick:n=>{n.preventDefault(),e.setRoute(H.topic,0,t.id)},children:t.title})}),_("span",{children:t.posts[0].user}),_("span",{children:t.posts.length}),_("span",{children:ge(t.posts[t.posts.length-1].date)})]}))]})}const Bt="_post_uuidr_1",Vt="_postHeader_uuidr_12",Jt="_avatar_uuidr_23",Kt="_user_uuidr_31",Zt="_date_uuidr_39",Qt="_generationSettings_uuidr_46",E={post:Bt,postHeader:Vt,avatar:Jt,user:Kt,date:Zt,generationSettings:Qt},Xt="_wrapper_cfqzy_1",Yt={wrapper:Xt},en=[[":)","1"],[":snif:","20"],[":gba:","17"],[":g)","3"],[":-)","46"],[":snif2:","13"],[":bravo:","69"],[":d)","4"],[":hap:","18"],[":ouch:","22"],[":pacg:","9"],[":cd:","5"],[":-)))","23"],[":ouch2:","57"],[":pacd:","10"],[":cute:","nyu"],[":content:","24"],[":p)","7"],[":-p","31"],[":noel:","11"],[":oui:","37"],[":(","45"],[":peur:","47"],[":question:","2"],[":cool:","26"],[":-(","14"],[":coeur:","54"],[":mort:","21"],[":rire:","39"],[":-((","15"],[":fou:","50"],[":sleep:","27"],[":-D","40"],[":nonnon:","25"],[":fier:","53"],[":honte:","30"],[":rire2:","41"],[":non2:","33"],[":sarcastic:","43"],[":monoeil:","34"],[":o))","12"],[":nah:","19"],[":doute:","28"],[":rouge:","55"],[":ok:","36"],[":non:","35"],[":malade:","8"],[":fete:","66"],[":sournois:","67"],[":hum:","68"],[":ange:","60"],[":diable:","61"],[":gni:","62"],[":play:","play"],[":desole:","65"],[":spoiler:","63"],[":merci:","58"],[":svp:","59"],[":sors:","56"],[":salut:","42"],[":rechercher:","38"],[":hello:","29"],[":up:","44"],[":bye:","48"],[":gne:","51"],[":lol:","32"],[":dpdr:","49"],[":dehors:","52"],[":hs:","64"],[":banzai:","70"],[":bave:","71"],[":pf:","pf"],[":cimer:","cimer"],[":ddb:","ddb"],[":pave:","pave"],[":objection:","objection"],[":siffle:","siffle"]];function tn(e){const t=me(()=>{const n=rn(e.raw);return on(n).replace(/\n/g,"<br/>")},[e.raw]);return _("div",{className:Yt.wrapper,dangerouslySetInnerHTML:{__html:t}})}const nn=[[/(^| )https?:\/\/image\.noelshack\.com\/(?:fichiers|minis)(\S+)/gm,'$1<img width="68" height="51" alt="noelshak" src="https://image.noelshack.com/minis/$2"/>'],[/(^| )https:\/\/vocaroo.com\/(.+)/gm,'$1<div><iframe width="300" height="60" src="https://vocaroo.com/embed/$2?autoplay=0" frameborder="0" allow="autoplay"></iframe></div>'],[/^(?:>.*(?:\n>.*)*)/g,(e,t)=>{const n=e.exec(t);if(!n)return t;console.log(n);const o=n.index,s=n[0].length;return t.substring(0,o)+`<blockquote>${n[0].replace(/^>/gm,"")}</blockquote>`+t.substring(o+s)}],[/<spoil>(.*?)<\/spoil>/gm,(e,t)=>t.replace(e,(n,o)=>{const s=(Math.random()+1).toString(36).substring(2);return`<span class="bloc-spoil-jv"><input type="checkbox" id="${s}" class="open-spoil"><label class="barre-head" for="${s}"><span class="txt-spoil">Spoil</span></label><span class="contenu-spoil">${o}</span></span>`})],[/(^| )(https?:\/\/\S+)/gm,'$1<a href="$2" target="_blank">$2</a>'],...en.map(e=>[new RegExp("(?:(^| )"+e[0].replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+")","gm"),`$1<img src="https://image.jeuxvideo.com/smileys_img/${e[1]}.gif" alt="${e[0]}"/>`])];function on(e){do for(const[t,n]of nn)n instanceof Function?e=n(t,e):e=e.replace(t,n);while(!1);return e}function rn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function sn(e){return console.log(e.topic),_("div",{children:[e.topic.posts.map(t=>_(an,{post:t})),_("div",{children:[_("h2",{children:"Ajout de posts"}),_("div",{className:E.generationSettings,children:_(ee,{children:[_("label",{htmlFor:"postCount",children:"Nombre de posts"}),_(ve,{name:"postCount",value:e.settings.postCount,onChange:t=>e.setSettings({...e.settings,postCount:t}),min:1,max:10,step:1})]})}),_(Y,{onClick:()=>e.addPosts(e.topic.id,e.settings.postCount),secondary:!0,loading:e.pendingGeneration,children:"Générer"})]}),_("hr",{})]})}function an(e){return _("div",{className:E.post,children:[_("div",{className:E.postHeader,children:[_("img",{src:"https://image.jeuxvideo.com/avatar-sm/default.jpg",className:E.avatar,alt:"ahi"}),_("div",{className:E.user,children:e.post.user}),_("div",{className:E.date,children:ge(e.post.date)})]}),_(tn,{raw:e.post.content})]})}const _n="_wrapper_1dmrl_1",cn="_icon_1dmrl_6",ln="_input_1dmrl_14",se={wrapper:_n,icon:cn,input:ln},un=({type:e,icon:t,value:n,placeholder:o,onChange:s,className:r,disabled:a,id:c,name:u})=>{const[l,f]=q(!1),i=ne(se.input,"generic-input",r,{focused:l,disabled:a}),h=g=>{console.log("handleInputChange");const k=g.target;s(e==="number"?parseFloat(k.value)||0:k.value)},d=t;return _("div",{className:se.wrapper,children:[_(d,{className:se.icon,size:18}),_("input",{title:"Le pseudo doit avoir une longueur comprise entre 3 et 15 caractères.",type:e,id:c,name:u,value:n,placeholder:o,onInput:h,className:i,disabled:a,onFocus:()=>f(!0),onBlur:()=>f(!1)})]})},dn=e=>{const t=e.color||"currentColor",n=e.size||24;return delete e.color,delete e.size,R("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:t,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},e),R("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),R("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}))},fn=e=>{const t=e.color||"currentColor",n=e.size||24;return delete e.color,delete e.size,R("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:t,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},e),R("circle",{cx:"12",cy:"12",r:"3"}),R("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"}))};function hn(e){return _("div",{children:_("form",{children:[_(ee,{children:[_("label",{htmlFor:"api",children:"API"}),_(un,{type:"text",placeholder:"URl d'API ex: https://ouruq7zepnehg2-5000.proxy.runpod.net/",icon:dn,value:e.settings.apiURL,onChange:t=>e.setSettings({...e.settings,apiURL:t})})]}),_(ee,{children:[_("label",{for:"temperature",children:"Temperature"}),_(ve,{name:"temperature",value:e.settings.temperature,onChange:t=>e.setSettings({...e.settings,temperature:t}),min:.1,max:2,step:.1})]}),_("div",{children:_(Y,{onClick:()=>{e.resetApp()},secondary:!0,title:"Tout réinitialiser",children:"Réinitialiser"})}),_("br",{}),_("div",{children:_(Y,{onClick:()=>{history.go(-1)},children:"Retour"})})]})})}const pn="_breadcrumbs_145yl_1",mn="_actions_145yl_10",Ee={breadcrumbs:pn,actions:mn};function gn(e){return _("div",{children:[_("nav",{className:Ee.breadcrumbs,children:[e.breadcrumbs,_("div",{className:Ee.actions,children:_("a",{href:"#",title:"Paramètres",onClick:t=>{t.preventDefault(),e.setRoute(H.settings)},children:_(fn,{size:18})})})]}),_("h2",{children:e.title}),e.children]})}const ye="settings",Fe={apiURL:"http://localhost:5000",temperature:.9,postCount:3};function Oe(){const e=localStorage.getItem(ye);return e?{...Fe,...JSON.parse(e)}:Fe}function vn(e){localStorage.setItem(ye,JSON.stringify(e))}function yn(){localStorage.removeItem(ye)}function bn(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}const wn=/Sujet\s+:\s+"(.+?)"?<\|eot_id\|>/,$n=/<\|im_pseudo\|>([^<]+)<\|end_pseudo\|>/,kn=/<\|im_date\|>([^<]+)<\|end_date\|>/,Sn=/<\|begin_of_post\|>([\s\S]+)(?:<\|end_of_post\|>)?$/;function xn(e){const t={id:bn(),title:"",posts:[]};for(const n of e.split("<|end_of_post|>").slice(0,-1)){if(console.log("Post tokens:"),console.log(n),t.posts.length<1){const o=n.match(wn);console.log(`title: ${o[1]}`),t.title=o[1]}t.posts=t.posts.concat(et(n))}return t}function et(e){const t=[];for(const n of e.split("<|end_of_post|>")){if(n.length<1)continue;console.log("Post tokens:"),console.log(n);const o=n.match($n);console.log(`user: ${o[1]}`);const s=n.match(kn);console.log(`date: ${s[1]}`);const r=n.match(Sn);console.log(`content: ${r[1]}`),t.push({user:o[1],date:Ft(s[1]),content:r[1]})}return t}function Nn(e){if(e.posts.length===0)throw new Error("Topic must have at least one post");const t=e.posts.map(o=>Tn(o,e.posts[0].user)).flat().join("");return["<|start_header_id|><|sujet|><|end_header_id|>","",`Sujet : "${e.title}"`].join(`
|
6 |
`)+t}function Tn(e,t){return[`<|eot_id|><|start_header_id|><|${e.user===t?"autheur":"khey"}|>`,"<|end_header_id|>","",`<|im_pseudo|>${e.user}<|end_pseudo|>`,`<|im_date|>Le ${ge(e.date)}<|end_date|>`,"",`<|begin_of_post|>${e.content}<|end_of_post|>`].join(`
|
7 |
`)}async function Cn(e,t){console.log(e);const n=await tt(e,"<|start_header_id|>",t);return xn(n)}async function Pn(e,t,n){const o=await tt(e,Nn(n),t);return console.log("rawOutput"),console.log(o),et(o)}const In="<|end_of_post|>";async function tt(e,t,n){const o=new AbortController,s=await fetch(new URL("/v1/completions",e.apiURL),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:t,temperature:e.temperature,max_tokens:2e3,stream:!0,skip_special_tokens:!1}),signal:o.signal});if(!s.ok)throw new Error(`Failed to fetch API (${s.status} ${s.statusText}): ${await s.text()}`);console.log(`Fetching topic with ${n} posts...`);let r=0,a="",c=null;try{await s.body.pipeThrough(new TextDecoderStream("utf-8")).pipeTo(new WritableStream({write(u){for(const l of u.split(`
|
8 |
+
`)){if(!l.startsWith("data:"))continue;const f=JSON.parse(l.slice(6)),i=f.choices[0].text;if(console.log(i),a+=f.choices[0].text,i.includes(In)){if(r++,r>=n){c="custom_stop",o.abort();break}}else c=f.choices[0].finish_reason}}}))}catch(u){if(u.name!=="AbortError")throw u}return console.log("Done fetching data"),console.log(`Finish reason: ${c}`),console.log(`Tokens: ${a}`),a}function jn(){const[e,t]=q(H.home),[n,o]=q(0),[s,r]=q(null),[a,c]=q(mt),[u,l]=q(null),[f,i]=q(!1);W(()=>{console.log("save !"),gt(a)},[a]);const h=async y=>{i(!0);const x=await Cn(g,y);l(x.id),c(T=>[...T,x]),i(!1)},d=async(y,x)=>{i(!0);const T=await Pn(g,x,a.find(C=>C.id===y)),S=[...a],j=S.findIndex(C=>C.id===y);S[j].posts=S[j].posts.concat(T),c(S),i(!1)},[g,k]=q(Oe);W(()=>{vn(g)},[g]);const w=()=>{yn(),k(Oe),c([])},m=je(()=>{const y=new URL(window.location.href),x=y.searchParams.get("route");x&&x in H&&t(x);const T=y.searchParams.get("page");T&&o(parseInt(T));const S=y.searchParams.get("id");S&&r(S)},[]);W(()=>{m()},[]),W(()=>{function y(){m()}return window.addEventListener("popstate",y),()=>{window.removeEventListener("popstate",y)}},[]);const p=je((y,x,T)=>{const S=new URL(window.location.href);S.searchParams.set("route",y),t(y),x!==void 0?(S.searchParams.set("page",String(x)),o(x)):(S.searchParams.delete("page"),o(0)),T!==void 0?(S.searchParams.set("id",T),r(T)):(S.searchParams.delete("id"),r(null));const j=S.toString();j!==window.location.href&&window.history.pushState({},"",j)},[]);let P,N,I;switch(e){case H.home:P=_(Gt,{topics:a,setRoute:p,settings:g,setSettings:k,generateTopic:h,pendingGeneration:f,latestGeneratedTopicId:u}),N="accueil",I="Liste des sujets";break;case H.topic:if(s===null)P=_("div",{children:"Impossible d'afficher le sujet"}),N="accueil",I="Sujet";else if(a===null)P=_("div",{children:"Chargement..."}),N="accueil / sujet",I="Chargement...";else{const y=a.find(x=>x.id===s);P=_(sn,{topic:y,settings:g,setSettings:k,addPosts:d,pendingGeneration:f}),N=`accueil / ${y.title}`,I=`Sujet : ${y.title}`}break;case H.settings:P=_(hn,{settings:g,setSettings:k,resetApp:w}),N="accueil / paramètres",I="Paramètres";break}return _(z,{children:[_("header",{className:He.header,children:_(Le,{children:_("h1",{className:He.logo,children:_("a",{href:"#",onClick:y=>{y.preventDefault(),p(H.home)},children:"JVCGPT"})})})}),_("main",{children:_(Le,{children:_(gn,{breadcrumbs:N,title:I,setRoute:p,children:P})})})]})}at(R(jn,null),document.getElementById("app"));
|
dist/index.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
7 |
<meta name="color-scheme" content="dark"/>
|
8 |
<title>JVCGPT</title>
|
9 |
-
<script type="module" crossorigin src="./assets/index-
|
10 |
<link rel="stylesheet" crossorigin href="./assets/index-bikKewjx.css">
|
11 |
</head>
|
12 |
<body>
|
|
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
7 |
<meta name="color-scheme" content="dark"/>
|
8 |
<title>JVCGPT</title>
|
9 |
+
<script type="module" crossorigin src="./assets/index-Cjniv5yr.js"></script>
|
10 |
<link rel="stylesheet" crossorigin href="./assets/index-bikKewjx.css">
|
11 |
</head>
|
12 |
<body>
|