zhengnaiwen_citu 1 hónapja
szülő
commit
959dc2bc41

+ 82 - 12
src/views/modelSystem/modelHistory/index.vue

@@ -141,7 +141,13 @@
                 height="150"
               >
                 <div class="d-flex align-center justify-center flex-column" style="height: 100%;">
-                  <div class="text-h3" :class="`${elevation.textColor}--text`">{{ checkpointData[elevation.value] }}</div>
+                  <div
+                    class="text-h3"
+                    :class="`${elevation.textColor}--text ${elevation.onClick ? 'cursor-pointer' : ''}`"
+                    @click="elevation.onClick && elevation.onClick(elevation, checkpointData)"
+                  >
+                    {{ checkpointData[elevation.value] }}
+                  </div>
                   <div>{{ elevation.text }}</div>
                 </div>
               </v-card>
@@ -152,13 +158,39 @@
     </div>
     <MDialog :visible.sync="show" title="设置保留checkpoint数量" @submit="handleSubmit" widthType="2">
       <v-text-field
-        v-model="keepCount"
+        v-model="checkpointParam.keep_count"
         dense
         label="checkpoint数量"
         placeholder="请输入每个线程保留的checkpoint数量"
         outlined
       ></v-text-field>
     </MDialog>
+    <ModelDetails ref="userRefs" title="用户列表">
+      <template #actions="{ item }">
+        <v-btn
+          text
+          color="primary"
+          @click="onClearCheckpoint({
+            keep_count: 10,
+            user_id: item.user_id,
+            thread_id: undefined
+          })"
+        >清理Checkpoint</v-btn>
+      </template>
+    </ModelDetails>
+    <ModelDetails ref="threadRefs" title="线程列表">
+      <template #actions="{ item }">
+        <v-btn
+          text
+          color="primary"
+          @click="onClearCheckpoint({
+            keep_count: 10,
+            user_id: undefined,
+            thread_id: item.thread_id
+          })"
+        >清理Checkpoint</v-btn>
+      </template>
+    </ModelDetails>
   </div>
 </template>
 
@@ -172,14 +204,16 @@ import {
   clearCheckpoint
 } from '@/api/dataChart'
 import MDialog from '@/components/Dialog'
+import ModelDetails from './modelDetails'
 export default {
   name: 'modelHistory',
   components: {
-    MDialog
+    MDialog,
+    ModelDetails
   },
   data () {
     return {
-      keepCount: 10,
+      showUser: false,
       show: false,
       loading: false,
       embLoading: false,
@@ -196,12 +230,17 @@ export default {
         { value: 'total_count', text: '总数', textColor: 'primary' }
       ],
       checkpointElevations: [
-        { value: 'total_users', text: '用户数量', textColor: 'primary' },
-        { value: 'total_threads', text: '线程总数', textColor: 'primary' },
-        { value: 'total_checkpoints', text: 'total_checkpoints总数', textColor: 'primary' }
+        { value: 'total_users', text: '用户数量', textColor: 'primary', onClick: this.onClickUser },
+        { value: 'total_threads', text: '线程总数', textColor: 'primary', onClick: this.onClickThread },
+        { value: 'total_checkpoints', text: 'checkpoints总数', textColor: 'primary' }
       ],
       embeddingData: {},
-      checkpointData: {}
+      checkpointData: {},
+      checkpointParam: {
+        keep_count: 10,
+        user_id: undefined,
+        thread_id: undefined
+      }
     }
   },
   created () {
@@ -210,6 +249,27 @@ export default {
     this.getCheckpoint()
   },
   methods: {
+    onClickUser (item, itemData) {
+      this.$refs.userRefs.open([
+        { text: '用户ID', value: 'user_id' },
+        { text: '线程总数', value: 'thread_count' },
+        { text: 'checkpoints数', value: 'total_checkpoints' },
+        { text: '操作', value: 'actions' }
+      ], itemData.users)
+    },
+    onClickThread (item, itemData) {
+      this.$refs.threadRefs.open([
+        { text: '线程ID', value: 'thread_id' },
+        { text: 'checkpoints数', value: 'checkpoint_count' },
+        { text: '用户ID', value: 'user_id' },
+        { text: '操作', value: 'actions' }
+      ], itemData.users.reduce((acc, cur) => {
+        acc.push(...cur.threads.map(e => {
+          return { ...e, user_id: cur.user_id }
+        }))
+        return acc
+      }, []))
+    },
     async getConversationsStatus () {
       this.loading = true
       try {
@@ -271,20 +331,27 @@ export default {
         }
       })
     },
-    onClearCheckpoint () {
+    onClearCheckpoint (param = {
+      keep_count: 10,
+      user_id: undefined,
+      thread_id: undefined
+    }) {
       this.show = true
-      this.keepCount = 10
+      this.checkpointParam = param
     },
     async handleSubmit () {
-      if (!this.keepCount) {
+      if (!this.checkpointParam.keep_count) {
         this.$snackbar.error('请输入保留的checkpoint数量')
         return
       }
       try {
-        const { data } = await clearCheckpoint({ keep_count: Number(this.keepCount) })
+        this.checkpointParam.keep_count = Number(this.checkpointParam.keep_count)
+        const { data } = await clearCheckpoint(this.checkpointParam)
         this.$snackbar.success(data.response)
         this.show = false
         this.getCheckpoint()
+        this.$refs.userRefs.close()
+        this.$refs.threadRefs.close()
       } catch (error) {
         this.$snackbar.error(error)
       }
@@ -297,4 +364,7 @@ export default {
 .content {
   font-size: 16px;
 }
+.cursor-pointer {
+  cursor: pointer;
+}
 </style>

+ 49 - 0
src/views/modelSystem/modelHistory/modelDetails.vue

@@ -0,0 +1,49 @@
+<template>
+  <MDialog :visible.sync="show" v-bind="$attrs" :footer="false">
+    <MTable
+      :headers="headers"
+      :items="items"
+      :show-select="false"
+      :is-tools="false"
+      :loading="false"
+      elevation="0"
+    >
+      <template #actions="{ item }">
+        <slot name="actions" :item="item"></slot>
+      </template>
+    </MTable>
+  </MDialog>
+</template>
+
+<script>
+import MDialog from '@/components/Dialog'
+import MTable from '@/components/List/table'
+export default {
+  name: 'modelDetails',
+  components: {
+    MDialog,
+    MTable
+  },
+  data () {
+    return {
+      show: false,
+      headers: [],
+      items: []
+    }
+  },
+  methods: {
+    open (header, items) {
+      this.headers = header
+      this.items = items
+      this.show = true
+    },
+    close () {
+      this.show = false
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>