zhengnaiwen_citu il y a 1 semaine
Parent
commit
e993110f95

+ 20 - 0
src/api/dataChart.js

@@ -55,3 +55,23 @@ export function getConversations (data) {
 export function getConversationsById (id) {
   return http.get(`/vanna/v0/conversation/${id}/messages`)
 }
+
+// 统计Redis中的全部的对话信息
+export function getConversationsStatus () {
+  return http.get('/vanna/v0/conversation_stats')
+}
+
+// 手工删除Redis中全部对话缓存
+export function clearConversation () {
+  return http.post('/vanna/v0/conversation_cleanup')
+}
+
+// 统计Redis中question embedding缓存
+export function getEmbeddingStats () {
+  return http.get('/vanna/v0/embedding_cache_stats')
+}
+
+// 清理Redis中的question embedding 缓存
+export function clearEmbeddingCache () {
+  return http.post('/vanna/v0/embedding_cache_cleanup')
+}

+ 3 - 3
src/router/routes.js

@@ -2435,20 +2435,20 @@ export default {
           hidden: 0,
           icon: '',
           type: 1,
-          title: '历史对话记录',
+          title: '内存管理',
           path: '/model-system/model-history',
           children: [],
           enName: 'model-history',
           redirect: '',
           active: '',
-          label: '历史对话记录',
+          label: '内存管理',
           sort: 0,
           component: 'modelSystem/modelHistory',
           meta: {
             roles: [],
             enName: 'model-history',
             icon: '',
-            title: '历史对话记录',
+            title: '内存管理',
             fullScreen: false
           },
           name: 'model-history',

+ 163 - 3
src/views/modelSystem/modelHistory/index.vue

@@ -1,15 +1,175 @@
 <template>
-  <div>
+  <div class="white content">
+    <div v-loading="loading">
+      <v-banner class="mb-3">
+        Redis
+        <template v-slot:actions>
+          <v-btn
+            text
+            color="primary"
+            @click="getConversationsStatus"
+          >
+            刷新
+          </v-btn>
+          <v-btn
+            text
+            color="deep-purple accent-4"
+            @click="onClearRedisCache"
+          >
+            清除对话缓存
+          </v-btn>
+        </template>
+      </v-banner>
+      <v-container>
+        <v-row >
+          <v-col
+            v-for="elevation in elevations"
+            :key="elevation.value"
+            cols="3"
+          >
+            <v-card
+              class="pa-2"
+              tile
+              height="200"
+            >
+              <div class="d-flex align-center justify-center flex-column" style="height: 100%;">
+                <div class="text-h3" :class="`${elevation.textColor}--text`">{{ itemData[elevation.value] }}</div>
+                <div>{{ elevation.text }}</div>
+              </div>
+            </v-card>
+          </v-col>
+        </v-row>
+      </v-container>
+      <!-- <v-divider></v-divider> -->
 
+      <v-banner class="mb-3">
+        embedding
+        <template v-slot:actions>
+          <v-btn
+            text
+            color="primary"
+            @click="getEmbeddingStats"
+          >
+            刷新
+          </v-btn>
+          <v-btn
+            text
+            color="deep-purple accent-4"
+            @click="onClearEmbeddingCache"
+          >
+            清除对话缓存
+          </v-btn>
+        </template>
+      </v-banner>
+      <v-container>
+        <v-row >
+          <v-col
+            v-for="elevation in embeddingElevations"
+            :key="elevation.value"
+            cols="3"
+          >
+            <v-card
+              class="pa-2"
+              tile
+              height="200"
+            >
+              <div class="d-flex align-center justify-center flex-column" style="height: 100%;">
+                <div class="text-h3" :class="`${elevation.textColor}--text`">{{ embeddingData[elevation.value] }}</div>
+                <div>{{ elevation.text }}</div>
+              </div>
+            </v-card>
+          </v-col>
+        </v-row>
+      </v-container>
+    </div>
   </div>
 </template>
 
 <script>
+import {
+  getConversationsStatus,
+  clearConversation,
+  getEmbeddingStats,
+  clearEmbeddingCache
+} from '@/api/dataChart'
 export default {
-  name: 'modelHistory'
+  name: 'modelHistory',
+  data () {
+    return {
+      loading: false,
+      elevations: [
+        { value: 'connected_clients', text: '客户端连接数', textColor: 'primary' },
+        { value: 'memory_usage_mb', text: 'redis占用内存(M)', textColor: 'primary' },
+        { value: 'total_conversations', text: '会话总数', textColor: 'primary' },
+        { value: 'total_users', text: '用户数', textColor: 'primary' }
+      ],
+      itemData: {},
+      embeddingElevations: [
+        { value: 'memory_usage_mb', text: 'embedding占用内存(M)', textColor: 'primary' },
+        { value: 'total_count', text: '总数', textColor: 'primary' }
+      ],
+      embeddingData: {}
+    }
+  },
+  created () {
+    this.getConversationsStatus()
+    this.getEmbeddingStats()
+  },
+  methods: {
+    async getConversationsStatus () {
+      this.loading = true
+      try {
+        const { data } = await getConversationsStatus()
+        this.itemData = { ...data, ...data.redis_info }
+      } catch (error) {
+        this.$snackbar.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    async getEmbeddingStats () {
+      this.loading = true
+      try {
+        const { data } = await getEmbeddingStats()
+        this.embeddingData = data
+      } catch (error) {
+        this.$snackbar.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    onClearRedisCache () {
+      this.$confirm('提示', '确定清除对话缓存吗?').then(async () => {
+        this.loading = true
+        try {
+          await clearConversation()
+          this.$snackbar.success('清除成功')
+        } catch (error) {
+          this.$snackbar.error(error)
+        } finally {
+          this.loading = false
+        }
+      })
+    },
+    onClearEmbeddingCache () {
+      this.$confirm('提示', '确定清除embedding缓存吗?').then(async () => {
+        this.loading = true
+        try {
+          await clearEmbeddingCache()
+          this.$snackbar.success('清除成功')
+        } catch (error) {
+          this.$snackbar.error(error)
+        } finally {
+          this.loading = false
+        }
+      })
+    }
+  }
 }
 </script>
 
 <style lang="scss" scoped>
-
+.content {
+  font-size: 16px;
+}
 </style>

+ 3 - 3
src/views/modelSystem/modelStatistics/index.vue

@@ -38,8 +38,8 @@ export default {
         { text: '负向反馈数', value: 'negative_feedback', textColor: 'error' },
         { text: '已训练反馈数', value: 'trained_feedback', textColor: 'indigo' },
         { text: '未训练反馈数', value: 'untrained_feedback', textColor: 'warning' },
-        { text: '正向反馈率', value: 'positive_rate', textColor: 'primary' },
-        { text: '训练覆盖率', value: 'training_rate', textColor: 'primary' }
+        { text: '正向反馈率(%)', value: 'positive_rate', textColor: 'primary' },
+        { text: '训练覆盖率(%)', value: 'training_rate', textColor: 'primary' }
       ],
       itemData: {}
     }
@@ -62,6 +62,6 @@ export default {
 
 <style lang="scss" scoped>
 .content {
-  font-size: 14px;
+  font-size: 16px;
 }
 </style>