![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /proc/thread-self/cwd/wp-content/plugins/uicore-framework/assets/js/ |
uicoreJsonp([6],{182:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(i(460)),a=n(i(3));function n(e){return e&&e.__esModule?e:{default:e}}var r=i(4);t.default={components:{uibase:o.default,multiselect:a.default},data:function(){return{mode:"",abortController:null,writing:!1,tone:[],keywords:"",topic:"",length:500,active:!0,openaiApiKey:"",toneList:["Informative","Conversational","Persuasive","Educational","Humorous","Authoritative","Instructional","Personal","Thoughtful","Inspirational","Analytical","Entertaining","Professional","Narrative","Motivational","Controversial","Chatty","Casual","Opinionated","Helpful","Friendly","Sarcastic","Sincere","Relatable","Candid","Analytic","Emotional","Serious","Explanatory","Instructional","Encouraging","Critical","Honest","Engaging","Descriptive","Inspiring","Witty","Unbiased","Expository","Inquisitive","Factual","Informal","Analyzing","Comparative","Reflective","Argumentative","Compelling","Insightful","Practical","Inspired","Clear","Expressive"]}},beforeMount:function(){""==window.uicore_ai.key||void 0==window.uicore_ai.key?this.mode="":(this.openaiApiKey=window.uicore_ai.key,this.mode="write")},methods:{close:function(){document.querySelector(".ui-ai-writer .uicore-base_close").click()},start:function(){this.writing=!0,this.abortController=new AbortController,jQuery("#uicore-writing-assistant-trigger").hide()},stop:function(e){this.mode=e?"write":"done",this.writing=!1,this.abortController.abort(),this.convertToBlocks(),jQuery("#uicore-writing-assistant-trigger").show()},saveKey:async function(){if(await this.storeValidKey(this.openaiApiKey)){window.uicore_ai.key=this.openaiApiKey,this.mode="write";var e=uicore_ai.api;r.post(e,{aiKey:this.openaiApiKey})}else alert("Invalid Api Key")},storeValidKey:async function(e){var t={method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+e},body:JSON.stringify({model:"gpt-3.5-turbo",temperature:.02,max_tokens:1,messages:[{role:"user",content:"?"}]})};try{var i=await fetch("https://api.openai.com/v1/chat/completions",t),o=await i.json();if(i.ok)return!0;throw new Error("API key error: "+o.error)}catch(e){return console.error(e.message),!1}},generateResponse:async function(){var e=this;try{var t=!1,i=function(e){t||(wp.data.dispatch("core/block-editor").insertBlock(wp.blocks.createBlock("core/freeform",{content:""})),t=!0);var i=wp.data.select("core/block-editor").getSelectedBlockClientId(),o=wp.data.select("core/block-editor").getBlock(i);!function(e,t){wp.data.dispatch("core/block-editor").updateBlockAttributes(t,{content:e})}((o&&o.attributes?o.attributes.content:"")+e,i)};this.start();var o=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+this.openaiApiKey},body:JSON.stringify({model:"gpt-3.5-turbo",temperature:.03,stream:!0,stop:["[STOP]"],messages:[{role:"system",content:"You are a profesional blog content writer. You write the article in a gutenberg html format."},{role:"user",content:this.prompt()}]}),signal:this.abortController.signal});if(o.ok){!async function(t){for(;;){var o=await t.read(),a=o.done,n=o.value;if(a){document.querySelector(".interface-interface-skeleton__content").scrollTop=0,e.stop();break}var r=e.getStreamText(new TextDecoder("utf-8").decode(n));r&&i(r)}}(o.body.getReader())}else{if(401!==o.status)throw new Error("HTTP error! status: "+o.status);this.openaiApiKey="",this.mode="",this.writing=!1,this.abortController.abort(),jQuery("#uicore-writing-assistant-trigger").show(),alert("Invalid Api Key")}}catch(e){console.error(e),console.log("Error: ",e.message),"Unauthorized"===e.message&&alert("Invalid Api Key")}},getStreamText:function(e){var t=this,i=e.split("\n\n");if(i.length>1){var o="";return i.forEach(function(e){e.startsWith("data: ")&&(o+=t.getStreamText(e))}),o}var a=i[0].substring(6),n=null;try{n=JSON.parse(a)}catch(e){return""}return"stop"===n.choices[0].finish_reason?"":n.choices[0]&&void 0!==n.choices[0].delta.content?n.choices[0].delta.content:""},prompt:function(){return"Create a blog post about “"+this.topic+"”. Write it in a “"+this.tone.join(", ")+"” tone. \n Use transition words. Use active voice. Write aproximative "+this.length+" words. \n Include the following keywords: “"+this.keywords+"”.\n Start with a compelling headline and introduction.\n Use subheadings to break up the content and make it easy to scan.\n Use short paragraphs and sentences to improve readability.\n Use bullet points and numbered lists to highlight important information (using ul and li).\n Use a conversational tone and avoid jargon.\n End with a clear call-to-action or conclusion.\n\n When it comes to structure, a good format to follow is:\n Grab the reader's attention and introduce the topic.\n Develop your ideas and provide supporting evidence.\n Summarize your main points and provide a call-to-action or conclusion.\n\n Format the response as wysiwyg html.\n !!DO NOT INCLUDE OTHER HTML TAGS THAN THE ONES USED FOR TEXT FORMATING eg: <section>, <heade> <html> etc!!\n !!WRITE THE TEXT IN THE LANGUAGE OF THE TOPIC: \""+this.topic+'"!!\n '},convertToBlocks:function(){var e=wp.blocks.createBlock,t=wp.data.dispatch,i=wp.data.select("core/block-editor").getSelectedBlock(),o=i.attributes.content,a=wp.blocks.rawHandler({HTML:o,mode:"BLOCKS"});a.reverse(),a.forEach(function(o){var a=o.name,n=o.attributes,r=o.innerBlocks,s=e(a,n,r);t("core/block-editor").insertBlock(s,i.clientId)}),t("core/block-editor").removeBlock(i.clientId)}},computed:{getMainColor:function(){return"--uicore-primary:#532df5"}}}},183:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"uibase",props:["title","scroll"],methods:{close:function(){this.$emit("close")}}}},457:function(e,t,i){"use strict";var o=n(i(11)),a=n(i(458));function n(e){return e&&e.__esModule?e:{default:e}}!function(e,t){var i="uicore-writing-assistant-trigger",n=document.getElementById("editor");if(n)t.data.subscribe(function(){setTimeout(function(){if(/*!document.getElementById( link_id )*/void 0==document.getElementsByClassName("uicore-ai-assistant-btn")[0]){var e=n.querySelector(".edit-post-header-toolbar");e instanceof HTMLElement&&(e.insertAdjacentHTML("beforeend",'<a id="uicore-writing-assistant-trigger" type="button" class="button button-primary button-large uicore-ai-assistant-btn" href="#" >AI Writing Assistant</a>'),e.insertAdjacentHTML("beforeend",'<div id="uicore-assistant-wrapper"><div id="ui-ai-app"></div></div>'),document.getElementById(i).addEventListener("click",function(e){var t=new o.default({el:"#ui-ai-app",destroyed:function(){},render:function(e){return e(a.default)}});setTimeout(function(){jQuery(".ui-ai-writer .uicore-base_close").on("click",function(){t.$destroy(),document.getElementById("uicore-assistant-wrapper").innerHTML='<div id="ui-ai-app"></div>'})},400),e.preventDefault()}))}},1)})}(window,wp)},458:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=i(182),a=i.n(o);for(var n in o)"default"!==n&&function(e){i.d(t,e,function(){return o[e]})}(n);var r=i(463),s=!1;var c=function(e){s||i(459)},l=i(0)(a.a,r.a,!1,c,null,null);l.options.__file="assets/src/ai/app.vue",t.default=l.exports},459:function(e,t){},460:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=i(183),a=i.n(o);for(var n in o)"default"!==n&&function(e){i.d(t,e,function(){return o[e]})}(n);var r=i(462),s=!1;var c=function(e){s||i(461)},l=i(0)(a.a,r.a,!1,c,null,null);l.options.__file="assets/src/ai/popup-base.vue",t.default=l.exports},461:function(e,t){},462:function(e,t,i){"use strict";var o=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"uicore-base"},[i("div",{staticClass:"uicore-base_header"},[i("div",{staticClass:"uicore-base_title",domProps:{innerHTML:e._s(e.title)}}),e._v(" "),i("div",{staticClass:"uicore-base_close",on:{click:e.close}},[i("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none"}},[i("path",{attrs:{d:"M18 6L6 18",stroke:"#0F172A","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}}),e._v(" "),i("path",{attrs:{d:"M6 6L18 18",stroke:"#0F172A","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}})])])]),e._v(" "),i("div",{staticClass:"uicore-base_content"},[e.scroll?i("perfect-scrollbar",[e._t("default")],2):e._t("default")],2)])};o._withStripped=!0;var a={render:o,staticRenderFns:[]};t.a=a},463:function(e,t,i){"use strict";var o=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"ui-ai-writer"},[i("a",{directives:[{name:"show",rawName:"v-show",value:e.writing,expression:"writing"}],staticClass:"button button-primary button-large uicore-ai-assistant-working",attrs:{type:"button",href:"#none"},on:{click:function(t){return e.stop(!0)}}},[e._v("Stop")]),e._v(" "),i("uibase",{directives:[{name:"show",rawName:"v-show",value:!e.writing,expression:"!writing"}],style:e.getMainColor,attrs:{title:"AI Writing Assistant<span>BETA</span>",scroll:!1}},[""==e.mode?i("div",{staticClass:"uianim-content"},[i("p",{staticStyle:{padding:"0 20px","font-size":"14px",margin:"0"}},[e._v("\n We need to connect to your OpenAl account so you have full control and ownership of your data. You\n can find your Secret API key in your\n "),i("a",{attrs:{href:"https://beta.openai.com/account/api-keys",target:"_blank"}},[e._v("User settings")]),e._v("\n (inside your OpenAI Account).\n ")]),e._v(" "),i("div",{staticClass:"uicore-core-setting"},[i("label",{staticClass:"uicore_h2",attrs:{for:"openaiApiKey"}},[e._v("OpenAI Key")]),e._v(" "),i("input",{directives:[{name:"model",rawName:"v-model",value:e.openaiApiKey,expression:"openaiApiKey"}],staticStyle:{width:"100%","max-width":"100%"},attrs:{id:"openaiApiKey",type:"text",placeholder:"sk-<your key>"},domProps:{value:e.openaiApiKey},on:{input:function(t){t.target.composing||(e.openaiApiKey=t.target.value)}}})]),e._v(" "),i("div",{staticClass:"uicore-btn",on:{click:e.saveKey}},[e._v("Save OpenAI Key")])]):e._e(),e._v(" "),"done"==e.mode?i("div",{staticClass:"uianim-content"},[i("p",{staticStyle:{margin:"0 20px 15px","font-size":"16px"}},[e._v("\n Your article has been generated successfully. Please note that this is a "),i("b",[e._v("beta")]),e._v(" feature and we\n are constantly working on improving it. "),i("br"),e._v(" "),i("i",{staticStyle:{"font-size":"13px",opacity:"0.7","line-height":"19px","margin-top":"14px",display:"block"}},[e._v("Your feedback is important to us, so if you have any suggestions please don’t hesitate to let\n us know.")])]),e._v(" "),i("div",{staticClass:"ui-ai-feedback"},[i("a",{staticClass:"uicore-btn",staticStyle:{background:"#f1f5f9",color:"#0f172a"},attrs:{href:"https://feedback.uicore.co/",target:"_blank"},on:{click:e.close}},[e._v("Suggest an idea")]),e._v(" "),i("div",{staticClass:"uicore-btn",on:{click:e.close}},[e._v("Dismiss")])])]):e._e(),e._v(" "),"write"==e.mode?i("div",{staticClass:"uianim-content"},[i("div",{staticClass:"uicore-core-setting"},[i("label",{staticClass:"uicore_h2",attrs:{for:"ui-ai-topic"}},[e._v("Topic")]),e._v(" "),i("textarea",{directives:[{name:"model",rawName:"v-model",value:e.topic,expression:"topic"}],attrs:{id:"ui-ai-topic",type:"text",placeholder:"Write 1-2 sentences about what your article is about."},domProps:{value:e.topic},on:{input:function(t){t.target.composing||(e.topic=t.target.value)}}})]),e._v(" "),i("div",{staticClass:"uicore-core-setting"},[i("label",{staticClass:"uicore_h2",attrs:{for:"ui-ai-keywords"}},[e._v("Keywords to include")]),e._v(" "),i("textarea",{directives:[{name:"model",rawName:"v-model",value:e.keywords,expression:"keywords"}],attrs:{id:"ui-ai-keywords",type:"text",placeholder:"List of keywords separated by coma."},domProps:{value:e.keywords},on:{input:function(t){t.target.composing||(e.keywords=t.target.value)}}})]),e._v(" "),i("div",{staticClass:"uicore-core-setting"},[i("label",{staticClass:"uicore_h2"},[e._v("Tone Of Voice")]),e._v(" "),i("multiselect",{attrs:{options:e.toneList,"allow-empty":!1,"show-labels":!1,searchable:!0,"clear-on-select":!1,"preserve-search":!0,multiple:!0,placeholder:"Select One or More"},model:{value:e.tone,callback:function(t){e.tone=t},expression:"tone"}})],1),e._v(" "),i("div",{staticClass:"uicore-core-setting"},[i("label",{staticClass:"uicore_h2"},[e._v("Length")]),e._v(" "),i("input",{directives:[{name:"model",rawName:"v-model",value:e.length,expression:"length"}],attrs:{type:"range",min:"200",max:"1500"},domProps:{value:e.length},on:{__r:function(t){e.length=t.target.value}}}),e._v(" "),i("div",{staticClass:"data"},[e._v(e._s(e.length)+" Words")])]),e._v(" "),i("div",{staticClass:"uicore-btn",on:{click:e.generateResponse}},[e._v("Write Article")])]):e._e()])],1)};o._withStripped=!0;var a={render:o,staticRenderFns:[]};t.a=a}},[457]);