index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!--
  2. - Copyright (c) 2024 LangChat. TyCoding All Rights Reserved.
  3. -
  4. - Licensed under the GNU Affero General Public License, Version 3 (the "License");
  5. - you may not use this file except in compliance with the License.
  6. - You may obtain a copy of the License at
  7. -
  8. - https://www.gnu.org/licenses/agpl-3.0.html
  9. -
  10. - Unless required by applicable law or agreed to in writing, software
  11. - distributed under the License is distributed on an "AS IS" BASIS,
  12. - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. - See the License for the specific language governing permissions and
  14. - limitations under the License.
  15. -->
  16. <script lang="ts" setup>
  17. import SvgIcon from '@/components/SvgIcon/index.vue';
  18. import KnowledgeList from './KnowledgeList.vue';
  19. import ModelSelect from '@/views/common/ModelSelect.vue';
  20. import { ref } from 'vue';
  21. import { useAppStore } from '@/views/app/store';
  22. const emit = defineEmits(['update']);
  23. const appStore = useAppStore();
  24. const knowledgeRef = ref();
  25. async function onSaveModel(val) {
  26. appStore.modelId = val.id;
  27. emit('update');
  28. }
  29. function onShowKbPane() {
  30. knowledgeRef.value.show();
  31. }
  32. function onRemove(item) {
  33. appStore.removeKnowledge(item);
  34. }
  35. </script>
  36. <template>
  37. <div class="p-2 py-4 flex flex-col gap-3">
  38. <n-collapse :default-expanded-names="['0', '1']">
  39. <n-collapse-item name="0" title="基础配置">
  40. <div class="flex items-center">
  41. <div class="w-24">对话模型:</div>
  42. <ModelSelect :id="appStore.modelId" class="" @update="onSaveModel" />
  43. </div>
  44. </n-collapse-item>
  45. <n-collapse-item name="1" title="知识库">
  46. <template #header-extra>
  47. <n-button text @click.stop="onShowKbPane">
  48. <SvgIcon class="text-lg" icon="ic:round-plus" />
  49. </n-button>
  50. </template>
  51. <div v-if="appStore.knowledges">
  52. <n-list clickable hoverable>
  53. <n-list-item
  54. v-for="item in appStore.knowledges"
  55. :key="item.id"
  56. class="w-full bg-white overflow-hidden !rounded-lg hover:bg-gray-100"
  57. >
  58. <div class="flex items-center justify-between">
  59. <div class="flex gap-1 items-center">
  60. <SvgIcon class="text-3xl" icon="flat-color-icons:document" />
  61. <div>{{ item.name }}</div>
  62. </div>
  63. <n-button text @click="onRemove(item)">
  64. <SvgIcon icon="gg:remove" />
  65. </n-button>
  66. </div>
  67. </n-list-item>
  68. </n-list>
  69. <div v-if="appStore.knowledges.length == 0" class="text-gray-400 text-md">
  70. 将文档、URL、三方数据源上传为文本知识库后,用户发送消息时,Bot
  71. 能够引用文本知识中的内容回答用户问题。
  72. </div>
  73. </div>
  74. </n-collapse-item>
  75. <n-collapse-item name="2" title="插件">
  76. <n-empty description="正在开发中..." />
  77. </n-collapse-item>
  78. </n-collapse>
  79. <KnowledgeList ref="knowledgeRef" />
  80. </div>
  81. </template>
  82. <style lang="less" scoped>
  83. ::v-deep(.n-collapse-item__header-main) {
  84. font-weight: 600 !important;
  85. color: #060709cc;
  86. }
  87. ::v-deep(.n-list) {
  88. background: transparent !important;
  89. }
  90. </style>