zhangxiao
2024-08-05 8742aa1ca9a96e75c18d4f9e3c52bddd8e190898
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
<template>
  <a-button type="text" @click="handleClick" size="small">
    <template #icon>
      <icon-tool />
    </template>
  </a-button>
  <a-modal
    v-model:visible="visible"
    title=" "
    @before-open="handleOpened"
    @cancel="handleCancel"
    :footer="false"
    title-align="start"
    width="900px"
  >
    <a-tabs default-active-key="1">
      <a-tab-pane key="1">
        <template #title> <icon-calendar /> 解析方法 </template>
        <div style="width: 100%">
          <div style="display: flex; align-items: center">
            <div> 解析方法: </div>
            <div style="margin-left: 10px">
              <a-select v-model="form.parser_id" placeholder="请选择">
                <a-option
                  v-for="item in parser_ids"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                ></a-option>
              </a-select>
            </div>
          </div>
          <div class="parser">
            <a-form
              ref="formRef"
              :rules="rules"
              :model="form"
              auto-label-width
              @submit="handleSubmit"
            >
              <a-divider style="margin-top: 10px" />
              <a-form-item
                field="slider"
                label="块token数"
                :rules="[
                  { type: 'number', min: 1, message: 'slider is min than 1' },
                ]"
              >
                <a-slider
                  v-model="form.chunk_token_num"
                  :max="1000"
                  show-input
                />
              </a-form-item>
              <a-divider style="margin-top: 10px" />
              <a-form-item field="raptor" label="使用召回增强RAPTOR策略">
                <a-space direction="vertical" size="large">
                  <a-switch
                    v-model="form.use_raptor"
                    @change="onChangeRAPTOR"
                  />
                </a-space>
              </a-form-item>
              <div v-if="form.use_raptor">
                <a-form-item field="prompt" label="提示词">
                  <a-textarea
                    v-model="form.prompt"
                    style="
                      height: 10rem;
                      border: 1px solid var(--color-fill-3);
                      border-radius: 4px;
                    "
                    placeholder="请填写提示词"
                  />
                </a-form-item>
                <a-form-item
                  field="slider"
                  label="最大token数"
                  :rules="[
                    { type: 'number', min: 5, message: 'slider is min than 5' },
                  ]"
                >
                  <a-slider
                    v-model="form.max_token"
                    :min="1"
                    :max="1000"
                    show-input
                  />
                </a-form-item>
                <a-form-item
                  field="slider"
                  label="阈值"
                  :rules="[
                    { type: 'number', min: 5, message: 'slider is min than 5' },
                  ]"
                >
                  <a-slider v-model="form.threshold" show-tooltip show-input />
                </a-form-item>
                <a-form-item
                  field="slider"
                  label="最大聚类数"
                  :rules="[
                    { type: 'number', min: 5, message: 'slider is min than 5' },
                  ]"
                >
                  <a-slider v-model="form.max_cluster" :max="1000" show-input />
                </a-form-item>
                <a-form-item
                  field="slider"
                  label="随机种子"
                  v-model="form.random_seed"
                  :rules="[
                    { type: 'number', min: 5, message: 'slider is min than 5' },
                  ]"
                >
                  <a-input-number
                    v-model="form.random_seed"
                    :style="{
                      width: '300px',
                      marginRight: '1rem',
                      borderRadius: '4px',
                    }"
                    placeholder="请输入"
                    class="input-demo"
                    :min="10"
                    :max="100"
                  />
                  <a-button type="primary" @click="randomNumber">
                    <icon-plus />
                  </a-button>
                </a-form-item>
              </div>
              <a-form-item>
                <div style="width: 100%; text-align: right">
                  <a-button @click="visible = false">取消</a-button>
                  <a-button
                    style="margin-left: 10px"
                    type="primary"
                    html-type="submit"
                    >确定</a-button
                  >
                </div>
              </a-form-item>
            </a-form>
          </div>
        </div>
      </a-tab-pane>
      <a-tab-pane key="2">
        <template #title> <icon-clock-circle /> 创建解析块 </template>
        <div class="details">
          <div class="details-header">
            <div
              style="
                display: flex;
                align-items: center;
                justify-content: flex-end;
              "
            >
              <a-radio-group
                v-model="radio"
                type="button"
                style="margin-right: 10px"
                @change="onRadioChange"
              >
                <a-radio value="1">全文</a-radio>
                <a-radio value="2">省略</a-radio>
              </a-radio-group>
              <a-popover position="bottom">
                <a-button
                  type="outline"
                  class="button"
                  style="margin-right: 10px"
                  >批量<icon-down style="margin-left: 4px"
                /></a-button>
                <template #content>
                  <a-space direction="vertical">
                    <a-checkbox
                      :model-value="checkedAll"
                      :indeterminate="indeterminate"
                      @change="handleChangeAll"
                      style="margin-left: 10px"
                    >
                      选择所有
                    </a-checkbox>
                  </a-space>
                  <a-divider style="margin: 10px 0" />
                  <p>
                    <a-button type="text" class="button" style="color: #2a2a2b">
                      <template #icon>
                        <icon-check-circle />
                      </template>
                      启用选定的
                    </a-button>
                  </p>
                  <p>
                    <a-button type="text" class="button" style="color: #2a2a2b">
                      <template #icon>
                        <icon-close-circle />
                      </template>
                      禁用选定的
                    </a-button>
                  </p>
                  <a-divider style="margin: 10px 0" />
                  <p>
                    <a-button type="text" class="button" style="color: #2a2a2b">
                      <template #icon>
                        <icon-delete />
                      </template>
                      删除选定的
                    </a-button>
                  </p>
                </template>
              </a-popover>
              <a-button
                type="outline"
                class="button"
                style="margin-right: 10px"
              >
                <template #icon>
                  <icon-search />
                </template>
              </a-button>
              <a-popover position="bottom">
                <a-button
                  type="outline"
                  class="button"
                  style="margin-right: 10px"
                  ><icon-sort
                /></a-button>
                <template #content>
                  <a-radio-group
                    v-model="available_int"
                    direction="vertical"
                    size="large"
                    @change="onChangeavailable"
                  >
                    <a-radio value="">所有</a-radio>
                    <a-radio value="1">启用</a-radio>
                    <a-radio value="0">禁用</a-radio>
                  </a-radio-group>
                </template>
              </a-popover>
              <addDetails :item="item"></addDetails>
            </div>
          </div>
          <a-divider style="margin-top: 10px" />
          <div class="groupMain">
            <a-checkbox-group v-model="data" @change="handleChange">
              <div
                class="groupList"
                :style="{ background: keyBg == '1' ? '#eff8ff' : 'white' }"
              >
                <a-checkbox value="1"></a-checkbox>
                <div
                  class="groupList-content"
                  @click="groupListContentClick('1')"
                  @dblclick="contentClick(1)"
                >
                  而 stable version 是最新稳定版,经过充分测试和验证,bug 较少,
                  适合用于生产环境。其版本号通常为双数,如 1.26。legacy versions
                  则是之前发布的稳定版,对于需要
                  特定旧版本的兼容性或安全性支持的用户有用,但一般不
                  推荐用于新项目,除非有特殊需求。在实际使用中,如果追求最新功能
                  且愿意面对可能存在的一些不稳定因素,可以尝试使用主线版本进行测试和研究;如果是用于生产环境
                </div>
                <div class="groupList-right">
                  <a-switch
                    v-model="switchType"
                    checked-value="1"
                    unchecked-value="0"
                    @change="handleChangeStatus()"
                  />
                </div>
              </div>
            </div>
            <a-divider style="margin-top: 10px" />
            <div class="groupMain">
              <a-checkbox-group v-model="data" @change="handleChange" >
                <div class="groupList">
                  <a-checkbox  value="1"></a-checkbox>
                  <div class="groupList-content" @click="groupListContentClick('1')" @dblclick="contentClick(1)">
                    而 stable version 是最新稳定版,经过充分测试和验证,bug 较少,
                    适合用于生产环境。其版本号通常为双数,如 1.26。legacy versions
                    则是之前发布的稳定版,对于需要
                    特定旧版本的兼容性或安全性支持的用户有用,但一般不
                    推荐用于新项目,除非有特殊需求。在实际使用中,如果追求最新功能
                    且愿意面对可能存在的一些不稳定因素,可以尝试使用主线版本进行测试和研究;如果是用于生产环境
                  </div>
                  <div class="groupList-right">
                    <a-switch v-model="switchType"  checked-value="1" unchecked-value="0" @change="handleChangeStatus()"/>
                  </div>
                </div>
 
                <div class="groupList">
                  <a-checkbox  value="1"></a-checkbox>
                  <div class="groupList-content" @click="groupListContentClick('2')" @dblclick="contentClick(1)">
                    而 stable version 是最新稳定版,经过充分测试和验证,bug 较少,
                    适合用于生产环境。其版本号通常为双数,如 1.26。legacy versions
                    则是之前发布的稳定版,对于需要
                  </div>
                  <div class="groupList-right">
                    <a-switch v-model="switchType"  checked-value="1" unchecked-value="0" @change="handleChangeStatus()"/>
                  </div>
                </div>
                <div class="groupList-right">
                  <a-switch
                    v-model="switchType"
                    checked-value="1"
                    unchecked-value="0"
                    @change="handleChangeStatus()"
                  />
                </div>
              </div>
            </a-checkbox-group>
          </div>
        </div>
        <eidtDetails ref="eidtDil"></eidtDetails>
      </a-tab-pane>
    </a-tabs>
  </a-modal>
</template>
 
<script lang="ts" setup>
  import { onMounted, onBeforeMount, reactive, ref, computed } from 'vue';
  import { Message } from '@arco-design/web-vue';
  import { kbdocumentchangeparser } from '@/api/kbList';
  import addDetails from '@/views/dmx/knowledgeLib/addDetails.vue';
  import eidtDetails from '@/views/dmx/knowledgeLib/eidtDetails.vue';
  const visible = ref(false);
  const loading = ref(false);
  const radio = ref('1');
  const keyBg = ref('');
  const eidtDil = ref();
 
  const props = defineProps(['kbtenantInfo', 'item', 'kbdetail']);
  // const emit =  defineEmits(['upTabdateItem'])
 
  let threshold = computed(() => {
    return form.threshold / 100;
  });
 
  const kbtenantInfo = props.kbtenantInfo;
 
  let parser_ids = kbtenantInfo.parser_ids.split(',').map((item) => {
    const [value1, value2] = item.split(':');
    return {
      name: value2,
      value: value1,
    };
  });
 
  const form = reactive({
    parser_id: props.item.parser_id,
    doc_id: props.item.id,
    max_token: 698,
    threshold: 30,
    max_cluster: 233,
    random_seed: 1500,
    chunk_token_num: 128,
    use_raptor: false,
    pages: {},
    prompt:
      '请总结以下段落。 小心数字,不要编造。 段落如下:\n' +
      '      {cluster_content}\n' +
      '以上就是你需要总结的内容。',
  });
  const formRef = ref(null);
  const rules = {
    prompt: [
      {
        required: true,
        message: '提示词不允许为空',
      },
    ],
  };
  const formatter = (value) => {
    return value / 100;
  };
  function randomNumber() {
    // 生成一个介于min和max之间的随机整数(包含min和max)
    const min = 1; // 最小值
    const max = 10000; // 最大值
    form.random_seed = Math.floor(Math.random() * (max - min + 1)) + min;
  }
 
  const handleSubmit = async ({ values, errors }) => {
    if (!errors) {
      let data = await kbdocumentchangeparser({
        parser_id: form.parser_id,
        doc_id: form.doc_id,
        parser_config: {
          raptor: {
            use_raptor: form.use_raptor,
            prompt: form.prompt,
            max_token: form.max_token,
            threshold: form.threshold,
            max_cluster: form.max_cluster,
            random_seed: form.random_seed,
          },
          chunk_token_num: form.chunk_token_num,
          pages: [],
        },
      });
      if (data.code == 0) {
        Message.success('配置成功');
      } else {
        Message.error('配置失败');
      }
      visible.value = false;
    }
  };
 
  const handleClick = () => {
    visible.value = true;
  };
  const handleCancel = () => {
    visible.value = false;
  };
 
  const contentClick = (done) => {
    eidtDil.value.handleClick();
  };
  const handleOpened = (el) => {
    // console.log('props',props.kbtenantInfo);
    // console.log('props',props.item);
    // console.log('props',props.kbdetail);
    console.log(parser_ids, 'parser_ids');
    // Object.assign(form,{
    //   name: '',// 用户名
    //   nameJoin: '',// 昵称
    //   post: '',// 岗位
    //   txt: '',// 备注
    // });
    // formRef.value.resetFields();
    console.log(props.item.id);
  };
 
  const onChangeRAPTOR = () => {};
 
  const indeterminate = ref(false);
  const checkedAll = ref(false);
  const data = ref([]);
  const switchType = ref(false);
  const available_int = ref('');
  const onRadioChange = () => {
    console.log(radio.value);
  };
  const handleChangeAll = (value) => {
    indeterminate.value = false;
    if (value) {
      checkedAll.value = true;
      data.value = ['1', '2', '3'];
    } else {
      checkedAll.value = false;
      data.value = [];
    }
  };
 
  const handleChange = (values) => {
    if (values.length === 3) {
      checkedAll.value = true;
      indeterminate.value = false;
    } else if (values.length === 0) {
      checkedAll.value = false;
      indeterminate.value = false;
    } else {
      checkedAll.value = false;
      indeterminate.value = true;
    }
  };
 
  const groupListContentClick = (value) => {
    keyBg.value = value;
  };
 
  const onChangeavailable = () => {
    console.log(available_int.value);
  };
 
  const handleChangeStatus = () => {
    console.log(switchType.value);
  };
 
  onBeforeMount(() => {});
  onMounted(() => {});
</script>
 
<style scoped lang="less">
.parser{
  width: 100%;
  ::v-deep .arco-btn-outline:hover, .arco-btn-outline, .arco-btn-outline[type='button']{
    color: #2a2a2b;
    border: 1px solid #2a2a2b;
  }
  .button{
    //color: #2a2a2b!important;
  }
}
.groupMain{
  width: 100%;
  height: 500px;
  overflow: auto;
  display: flex;
  justify-content: center;
  .groupList{
    display: flex;
    padding: 24px;
    border-radius: 8px;
    //background: #eff8ff;
    border: 1px solid var(--color-neutral-3);
    margin-bottom: 20px;
    overflow: auto;
    .groupList-content{
      width: 700px;
      //height: 100px;
      overflow: auto;
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      color: var(--color-text-1);
      font-size: 14px;
      font-family: Inter;
      position: relative;
 
 
    }
  }
  .groupMain {
    width: 100%;
    height: 500px;
    overflow: auto;
    display: flex;
    justify-content: center;
    .groupList {
      display: flex;
      padding: 24px;
      border-radius: 8px;
      //background: #eff8ff;
      border: 1px solid #f0f0f0;
      margin-bottom: 20px;
      overflow: auto;
      .groupList-content {
        width: 700px;
        //height: 100px;
        overflow: auto;
        box-sizing: border-box;
        margin: 0;
        padding: 0;
        color: rgba(0, 0, 0, 0.88);
        font-size: 14px;
        font-family: Inter;
        position: relative;
      }
    }
  }
</style>