12 |
- /*! third party licenses: dist/vendor.LICENSE.txt */
- import{G as p,ai as d,af as g,F as l,a7 as u,b_ as o,bR as v,bZ as _,aV as c}from"./core-common.mjs";import{d as h}from"./chunks/vuedraggable.umd-CKAHk2gO.mjs";import{n as f,G as y,H as m,J as x}from"./chunks/icons-TElqpmA8.mjs";import"./chunks/sortable.esm-D5slCXxa.mjs";const k={name:"AdminAI",components:{NcCheckboxRadioSwitch:p,NcSettingsSection:d,NcSelect:g,draggable:h,DragVerticalIcon:y,ArrowDownIcon:m,ArrowUpIcon:x,NcButton:l,NcNoteCard:u},data(){return{loading:!1,dirty:!1,groups:[],loadingGroups:!1,sttProviders:o("settings","ai-stt-providers"),translationProviders:o("settings","ai-translation-providers"),textProcessingProviders:o("settings","ai-text-processing-providers"),textProcessingTaskTypes:o("settings","ai-text-processing-task-types"),text2imageProviders:o("settings","ai-text2image-providers"),settings:o("settings","ai-settings")}},computed:{hasStt(){return this.sttProviders.length>0},hasTextProcessing(){return Object.keys(this.settings["ai.textprocessing_provider_preferences"]).length>0&&Array.isArray(this.textProcessingTaskTypes)},tpTaskTypes(){return Object.keys(this.settings["ai.textprocessing_provider_preferences"]).filter(e=>!!this.getTaskType(e))},hasText2ImageProviders(){return this.text2imageProviders.length>0}},methods:{moveUp(e){this.settings["ai.translation_provider_preferences"].splice(Math.min(e-1,0),0,...this.settings["ai.translation_provider_preferences"].splice(e,1)),this.saveChanges()},moveDown(e){this.settings["ai.translation_provider_preferences"].splice(e+1,0,...this.settings["ai.translation_provider_preferences"].splice(e,1)),this.saveChanges()},async saveChanges(){this.loading=!0;const e={settings:this.settings};try{await v.put(_("/settings/api/admin/ai"),e)}catch(s){console.error("could not save changes",s)}this.loading=!1},getTaskType(e){return Array.isArray(this.textProcessingTaskTypes)?this.textProcessingTaskTypes.find(s=>s.class===e):null}}};var T=function(){var e=this,s=e._self._c;return s("div",[s("NcSettingsSection",{attrs:{name:e.t("settings","Machine translation"),description:e.t("settings","Machine translation can be implemented by different apps. Here you can define the precedence of the machine translation apps you have installed at the moment.")}},[s("draggable",{on:{change:e.saveChanges},model:{value:e.settings["ai.translation_provider_preferences"],callback:function(n){e.$set(e.settings,"ai.translation_provider_preferences",n)},expression:"settings['ai.translation_provider_preferences']"}},e._l(e.settings["ai.translation_provider_preferences"],function(n,i){var r;return s("div",{key:n,staticClass:"draggable__item"},[s("DragVerticalIcon"),e._v(" "),s("span",{staticClass:"draggable__number"},[e._v(e._s(i+1))]),e._v(" "+e._s((r=e.translationProviders.find(a=>a.class===n))==null?void 0:r.name)+" "),s("NcButton",{attrs:{"aria-label":"Move up",type:"tertiary"},on:{click:function(a){return e.moveUp(i)}},scopedSlots:e._u([{key:"icon",fn:function(){return[s("ArrowUpIcon")]},proxy:!0}],null,!0)}),s("NcButton",{attrs:{"aria-label":"Move down",type:"tertiary"},on:{click:function(a){return e.moveDown(i)}},scopedSlots:e._u([{key:"icon",fn:function(){return[s("ArrowDownIcon")]},proxy:!0}],null,!0)})],1)}),0)],1),s("NcSettingsSection",{attrs:{name:e.t("settings","Speech-To-Text"),description:e.t("settings","Speech-To-Text can be implemented by different apps. Here you can set which app should be used.")}},[e._l(e.sttProviders,function(n){return[s("NcCheckboxRadioSwitch",{key:n.class,attrs:{checked:e.settings["ai.stt_provider"],value:n.class,name:"stt_provider",type:"radio"},on:{"update:checked":[function(i){return e.$set(e.settings,"ai.stt_provider",i)},e.saveChanges]}},[e._v(" "+e._s(n.name)+" ")])]}),e.hasStt?e._e():[s("NcNoteCard",{attrs:{type:"info"}},[e._v(" "+e._s(e.t("settings","None of your currently installed apps provide Speech-To-Text functionality"))+" ")])]],2),s("NcSettingsSection",{attrs:{name:e.t("settings","Image generation"),description:e.t("settings","Image generation can be implemented by different apps. Here you can set which app should be used.")}},[e._l(e.text2imageProviders,function(n){return[s("NcCheckboxRadioSwitch",{key:n.id,attrs:{checked:e.settings["ai.text2image_provider"],value:n.id,name:"text2image_provider",type:"radio"},on:{"update:checked":[function(i){return e.$set(e.settings,"ai.text2image_provider",i)},e.saveChanges]}},[e._v(" "+e._s(n.name)+" ")])]}),e.hasText2ImageProviders?e._e():[s("NcNoteCard",{attrs:{type:"info"}},[e._v(" "+e._s(e.t("settings","None of your currently installed apps provide image generation functionality"))+" ")])]],2),s("NcSettingsSection",{attrs:{name:e.t("settings","Text processing"),description:e.t("settings","Text processing tasks can be implemented by different apps. Here you can set which app should be used for which task.")}},[e._l(e.tpTaskTypes,function(n){return[s("div",{key:n},[s("h3",[e._v(e._s(e.t("settings","Task:"))+" "+e._s(e.getTaskType(n).name))]),s("p",[e._v(e._s(e.getTaskType(n).description))]),s("p",[e._v(" ")]),s("NcSelect",{attrs:{clearable:!1,options:e.textProcessingProviders.filter(i=>i.taskType===n).map(i=>i.class)},on:{input:e.saveChanges},scopedSlots:e._u([{key:"option",fn:function({label:i}){var r;return[e._v(" "+e._s((r=e.textProcessingProviders.find(a=>a.class===i))==null?void 0:r.name)+" ")]}},{key:"selected-option",fn:function({label:i}){var r;return[e._v(" "+e._s((r=e.textProcessingProviders.find(a=>a.class===i))==null?void 0:r.name)+" ")]}}],null,!0),model:{value:e.settings["ai.textprocessing_provider_preferences"][n],callback:function(i){e.$set(e.settings["ai.textprocessing_provider_preferences"],n,i)},expression:"settings['ai.textprocessing_provider_preferences'][type]"}}),s("p",[e._v(" ")])],1)]}),e.hasTextProcessing?e._e():[s("NcNoteCard",{attrs:{type:"info"}},[e._v(" "+e._s(e.t("settings","None of your currently installed apps provide Text processing functionality"))+" ")])]],2)],1)},b=[],w=f(k,T,b,!1,null,"c72854a3");const S=w.exports;c.prototype.t=t,window.OC=window.OC||{},window.OC.Settings=window.OC.Settings||{};const N=c.extend(S);new N().$mount("#ai-settings");
|