浏览代码

应用编排

CzRger 4 天之前
父节点
当前提交
10c53fe602

+ 5 - 1
src/components/czr-ui/czr-form-link/input.vue

@@ -73,4 +73,8 @@ defineExpose({
 })
 </script>
 
-<style scoped lang="scss"></style>
+<style scoped lang="scss">
+:deep(textarea) {
+  resize: none;
+}
+</style>

+ 153 - 17
src/views/manage/app/make/index.vue

@@ -27,7 +27,7 @@
               <SvgIcon name="czr_tip" color="#FF5454" class="mr-1" />
               有未发布的修改
             </div>
-            <CzrButton type="primary" title="发布" />
+            <CzrButton type="primary" title="发布" @click="onPublish" />
             <el-popover
               :show-arrow="false"
               :width="180"
@@ -63,7 +63,7 @@
               </div>
             </el-popover>
           </div>
-          <CzrForm class="form">
+          <CzrForm class="form" ref="ref_form">
             <div class="grid h-full flex-1 grid-cols-2 gap-4">
               <div class="col-span-1 flex flex-col rounded-lg bg-[#ffffff]">
                 <div
@@ -96,6 +96,7 @@
                     placeholder="点击选择模型"
                     readonly
                     @click="onModel"
+                    default-error-msg="请选择模型"
                   />
                 </div>
                 <div class="__czr-title_2 mt-4">
@@ -172,6 +173,7 @@
                     v-model:param="state.form.prologue"
                     link="rich"
                     :height="300"
+                    default-error-msg="请输入开场白"
                   />
                 </div>
                 <div class="__czr-title_2 mt-4">
@@ -318,14 +320,14 @@
                   问题建议
                   <div class="ml-auto">
                     <el-checkbox-group
-                      v-model="state.form.adviseType"
+                      v-model="state.form.advise.types"
                       size="small"
                     >
                       <el-checkbox-button value="open">
                         开启
                       </el-checkbox-button>
-                      <template v-if="state.form.adviseType.includes('open')">
-                        <el-checkbox-button value="cus">
+                      <template v-if="state.form.advise.types.includes('open')">
+                        <el-checkbox-button value="tips">
                           自定义提示词
                         </el-checkbox-button>
                         <el-checkbox-button value="knowledge">
@@ -335,17 +337,100 @@
                     </el-checkbox-group>
                   </div>
                 </div>
-                <div class="mt-4">
-                  <CzrFormColumn
-                    class="__czr-table-form-column"
-                    required
-                    label="模型选择"
-                    :span="24"
-                    v-model:param="state.form.adviseModel"
-                    link="select"
-                    :options="[]"
-                  />
-                </div>
+                <template v-if="state.form.advise.types.includes('open')">
+                  <div class="mt-4">
+                    <CzrFormColumn
+                      class="__czr-table-form-column"
+                      required
+                      label="模型选择"
+                      :span="24"
+                      v-model:param="state.form.advise.model.name"
+                      placeholder="点击选择模型"
+                      readonly
+                      @click="onAdviseModel"
+                      default-error-msg="请选择问题建议模型"
+                    />
+                    <div
+                      class="mt-2 flex h-10 items-center gap-1 rounded-sm bg-[#FFFAEA] px-3.5 text-sm text-[#6F7889]"
+                    >
+                      <SvgIcon
+                        name="czr_tip"
+                        color="var(--czr-warning-color)"
+                      />
+                      应用每次回复后,根据对话内容提出最多3条问题建议
+                    </div>
+                    <template v-if="state.form.advise.types.includes('tips')">
+                      <div class="mt-2">
+                        <CzrFormColumn
+                          class="__czr-table-form-column"
+                          label-width="0px"
+                          :span="24"
+                          v-model:param="state.form.advise.tips"
+                          type="textarea"
+                          :rows="4"
+                          placeholder="问题应该与你最后一轮的回复紧密相关,可以引发进一步的讨论。&#10;问题不要与上文已经提问或者回答过的内容重复。&#10;每句话只包含一个问题,但也可以不是问句而是一句指令。&#10;推荐你有能力回答的问题。"
+                        />
+                      </div>
+                    </template>
+                  </div>
+                  <template
+                    v-if="state.form.advise.types.includes('knowledge')"
+                  >
+                    <div class="__czr-title_2 mt-4">
+                      问题建议知识库
+                      <template v-if="state.form.advise.knowledges.length > 0">
+                        ({{ state.form.advise.knowledges.length }})
+                      </template>
+                      <CzrButton
+                        type="normal"
+                        title="新增"
+                        class="ml-auto"
+                        @click="onAddAdviseKnowledge"
+                      />
+                    </div>
+                    <template v-if="state.form.advise.knowledges.length > 0">
+                      <div
+                        class="mt-2 flex max-h-42 flex-col gap-2 overflow-y-auto pr-2"
+                      >
+                        <template
+                          v-for="(item, index) in state.form.advise.knowledges"
+                        >
+                          <div class="flex items-center gap-1.5">
+                            <div
+                              class="flex h-10 flex-1 items-center overflow-hidden rounded-sm bg-[#F6F8FC] px-2.5"
+                            >
+                              <img
+                                src="@/assets/images/knowledge/knowledge-item-icon-2.png"
+                                class="mr-4 h-6 w-6"
+                              />
+                              <div
+                                class="flex-1 text-sm font-bold text-[#2E3238]"
+                                v-title
+                              >
+                                {{ item.name }}
+                              </div>
+                            </div>
+                            <SvgIcon
+                              class="__hover"
+                              name="czr_del"
+                              color="var(--czr-error-color)"
+                              @click="
+                                state.form.advise.knowledges.splice(index, 1)
+                              "
+                            />
+                          </div>
+                        </template>
+                      </div>
+                    </template>
+                    <template v-else>
+                      <div
+                        class="mt-2 flex h-8 items-center justify-center rounded-sm bg-[#F6F8FC] text-xs text-[#A7ADB9]"
+                      >
+                        暂未添加问题建议知识库
+                      </div>
+                    </template>
+                  </template>
+                </template>
               </div>
             </div>
           </CzrForm>
@@ -385,6 +470,7 @@ import knowledgeSelect from './knowledge-select.vue'
 import modelSelect from './model-select.vue'
 import { isValue } from '@/utils/czr-util'
 import Sortable from 'sortablejs'
+import CzrForm from '@/components/czr-ui/CzrForm.vue'
 
 const DictionaryStore = useDictionaryStore()
 const route = useRoute()
@@ -394,6 +480,7 @@ const props = defineProps({})
 const { proxy }: any = getCurrentInstance()
 const state: any = reactive({
   ID: route.params.id,
+  autoSave: '',
   form: {
     tips: '',
     model: {},
@@ -410,7 +497,12 @@ const state: any = reactive({
     prologueType: 'three',
     method: 1,
     voicePackage: '',
-    adviseType: [],
+    advise: {
+      types: ['open', 'tips', 'knowledge'],
+      model: {},
+      tips: '',
+      knowledges: [],
+    },
   },
   knowledgeSelect: {
     show: false,
@@ -425,6 +517,7 @@ const state: any = reactive({
   },
   dragRefresh: true,
 })
+const ref_form = ref()
 const ref_prologue = ref()
 const ref_prologueBody = ref()
 const initDetail = () => {
@@ -476,6 +569,13 @@ const onAddKnowledge = () => {
   }
   state.knowledgeSelect.show = true
 }
+const onAddAdviseKnowledge = () => {
+  state.knowledgeSelect.transfer = {
+    ids: state.form.advise.knowledges.map((v) => v.id),
+    type: 'advise',
+  }
+  state.knowledgeSelect.show = true
+}
 const onPrologue = (row) => {
   if (row) {
     row.__value = row.value + ''
@@ -512,6 +612,11 @@ const getKnowledge = (arr) => {
         state.form.knowledges.push(...arr)
       }
       break
+    case 'advise':
+      {
+        state.form.advise.knowledges.push(...arr)
+      }
+      break
   }
 }
 const getModel = (val) => {
@@ -521,6 +626,11 @@ const getModel = (val) => {
         state.form.model = val
       }
       break
+    case 'advise':
+      {
+        state.form.advise.model = val
+      }
+      break
   }
 }
 const onModel = () => {
@@ -530,6 +640,32 @@ const onModel = () => {
   }
   state.modelSelect.show = true
 }
+const onAdviseModel = () => {
+  state.modelSelect.transfer = {
+    type: 'advise',
+    id: state.form.advise.model.id,
+  }
+  state.modelSelect.show = true
+}
+const onPublish = () => {
+  ref_form.value
+    .submit()
+    .then(() => {
+      if (state.form.advise.types.includes('knowledge')) {
+        if (state.form.advise.knowledges.length === 0) {
+          ElMessage.warning('请添加问题建议知识库!')
+          return
+        }
+      }
+    })
+    .catch((e) => {
+      ElMessage({
+        message: e[0].message,
+        grouping: true,
+        type: 'warning',
+      })
+    })
+}
 onMounted(() => {
   initDictionary()
   initDetail()

+ 18 - 2
src/views/manage/app/make/model-select.vue

@@ -107,7 +107,7 @@
             >
               <div
                 class="__hover ml-auto text-xs text-[var(--czr-main-color)]"
-                @click.capture.stop="onSwitch(row)"
+                @click.capture.stop="onView(row)"
               >
                 查看详情
               </div>
@@ -144,6 +144,10 @@
         </CzrForm>
       </div>
     </CzrDialog>
+    <detailCom
+      v-model:show="state.detail.show"
+      :transfer="state.detail.transfer"
+    />
   </CzrDialog>
 </template>
 
@@ -164,7 +168,7 @@ import { Search } from '@element-plus/icons-vue'
 import { pluginGetInstanceList } from '@/api/modules/model'
 import { YMDHms } from '@/utils/czr-util'
 import { ElMessage, ElMessageBox } from 'element-plus'
-import CzrDialog from '@/components/czr-ui/CzrDialog.vue'
+import detailCom from '@/views/manage/model/detail.vue'
 
 const DialogStore = useDialogStore()
 const DictionaryStore = useDictionaryStore()
@@ -195,6 +199,10 @@ const state: any = reactive({
     show: false,
     text: '',
   },
+  detail: {
+    show: false,
+    transfer: {},
+  },
 })
 const ref_apply = ref()
 watch(
@@ -298,6 +306,14 @@ const onApply = () => {
       })
     })
 }
+const onView = (row) => {
+  state.detail.transfer = {
+    mode: 'view',
+    id: row.id,
+  }
+  state.detail.show = true
+}
+
 onMounted(() => {
   initDictionary()
 })

+ 0 - 1
src/views/manage/knowledge/documents/setting/index.vue

@@ -165,7 +165,6 @@ const initDictionary = () => {
           width: 100%;
           height: 100%;
           padding: 0.75rem;
-          resize: none;
           border-top-left-radius: 0;
           border-top-right-radius: 0;
         }

+ 0 - 1
src/views/manage/knowledge/documents/test/index.vue

@@ -284,7 +284,6 @@ onMounted(() => {
           width: 100%;
           height: 100%;
           padding: 0.75rem;
-          resize: none;
           border-top-left-radius: 0;
           border-top-right-radius: 0;
         }

+ 10 - 0
src/views/manage/model/detail.vue

@@ -172,6 +172,16 @@ const initData = () => {
   pluginDetail(props.transfer.id)
     .then(({ data }: any) => {
       state.form = data
+      const obj = DictionaryStore.modelProvides.objMap.get(
+        state.form.pluginClass,
+      )
+      state.baseForms = obj.basicConfigAttr
+        ? Object.values(obj.basicConfigAttr)
+        : []
+      state.paramForms = obj.paramConfigAttr
+        ? Object.values(obj.paramConfigAttr)
+        : []
+      state.bizForms = obj.bizConfigAttr ? Object.values(obj.bizConfigAttr) : []
     })
     .catch(() => {})
     .finally(() => {