From e1b647303d8d6cb96490a85146bf6c88db77c349 Mon Sep 17 00:00:00 2001 From: carolsi Date: Fri, 15 Dec 2023 09:34:06 +0800 Subject: [PATCH] feat: add inference applicationModel compare page --- package.json | 2 + .../en-US/views/InferenceApplication.json | 8 + .../zh-CN/views/InferenceApplication.json | 8 + src/plugins/axios/index.ts | 11 +- src/router/index.ts | 6 + .../InferenceApplicationList.vue | 16 +- .../InferenceApplicationModelCompare.vue | 185 ++++++++++++++++++ .../components/comparison-chat-item.vue | 97 +++++++++ .../components/comparison-chat-markdown.vue | 23 +++ .../components/comparison-chat-textarea.vue | 86 ++++++++ 10 files changed, 440 insertions(+), 2 deletions(-) create mode 100644 src/views/inference-application/InferenceApplicationModelCompare.vue create mode 100644 src/views/inference-application/components/comparison-chat-item.vue create mode 100644 src/views/inference-application/components/comparison-chat-markdown.vue create mode 100644 src/views/inference-application/components/comparison-chat-textarea.vue diff --git a/package.json b/package.json index 7bb99ff..55bb5a1 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@antv/g2": "^5.1.10", "@dao-style/core": "1.9.0", "@dao-style/extend": "1.7.2-beta.3", + "@types/showdown": "^2.0.6", "@vueuse/core": "^8.5.0", "@vueuse/shared": "^8.5.0", "axios": "^1.6.2", @@ -30,6 +31,7 @@ "lodash": "^4.17.21", "normalize.css": "^8.0.1", "pinia": "^2.1.7", + "showdown": "^2.1.0", "vee-validate": "^4.12.0", "vue": "^3.3.8", "vue-i18n": "9.7.1", diff --git a/src/locales/en-US/views/InferenceApplication.json b/src/locales/en-US/views/InferenceApplication.json index 2aa0d45..039287b 100644 --- a/src/locales/en-US/views/InferenceApplication.json +++ b/src/locales/en-US/views/InferenceApplication.json @@ -44,5 +44,13 @@ "llmCheckpoint": "Model", "createSuccess": "Inference application created successfully", "createFailed": "Failed to create inference application" + }, + + "compare": { + "header": "Multi-model Comparison", + "elapsedTime": "Elapsed Time(s)", + "tokensTotalQuantity": "Tokens Total Quantity", + "perSecond": "tokens/s", + "send": "Send" } } diff --git a/src/locales/zh-CN/views/InferenceApplication.json b/src/locales/zh-CN/views/InferenceApplication.json index 64d6dfc..7662d73 100644 --- a/src/locales/zh-CN/views/InferenceApplication.json +++ b/src/locales/zh-CN/views/InferenceApplication.json @@ -43,5 +43,13 @@ "llmCheckpoint": "模型", "createSuccess": "推理应用创建成功", "createFailed": "推理应用创建失败" + }, + + "compare": { + "header": "多模型对比", + "elapsedTime": "用时(s)", + "tokensTotalQuantity": "tokens总数", + "perSecond": "tokens/每秒", + "send": "发送" } } diff --git a/src/plugins/axios/index.ts b/src/plugins/axios/index.ts index fcc46a5..746a08f 100644 --- a/src/plugins/axios/index.ts +++ b/src/plugins/axios/index.ts @@ -37,7 +37,16 @@ httpClient.interceptors.request.use( httpClient.interceptors.response.use( (response) => response, - (error) => Promise.reject(error.response?.data), + (error) => { + const { response = {} } = error; + + if (response?.status === 401 || response?.status === 403) { + localStorage.removeItem(TOKEN); + window.location.reload(); + } + + return Promise.reject(error.response?.data); + }, ); export default httpClient; diff --git a/src/router/index.ts b/src/router/index.ts index c647b77..fb7998b 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -24,6 +24,7 @@ import FinetuneExperimentJobDetail from '@/views/finetune-experiment-job/Finetun import ModelRegistryList from '@/views/model-registry/ModelRegistryList.vue'; import InferenceApplicationList from '@/views/inference-application/InferenceApplicationList.vue'; +import InferenceApplicationModelCompare from '@/views/inference-application/InferenceApplicationModelCompare.vue'; const routes: Array = [ { @@ -137,6 +138,11 @@ const routes: Array = [ name: 'InferenceApplicationList', component: InferenceApplicationList, }, + { + path: 'inference-application-model-compare', + name: 'InferenceApplicationModelCompare', + component: InferenceApplicationModelCompare, + }, ], }, diff --git a/src/views/inference-application/InferenceApplicationList.vue b/src/views/inference-application/InferenceApplicationList.vue index f136644..107b529 100644 --- a/src/views/inference-application/InferenceApplicationList.vue +++ b/src/views/inference-application/InferenceApplicationList.vue @@ -12,6 +12,7 @@ import { useDeleteInferenceApplication } from './composition/inference-applicati const { namespace } = storeToRefs(useNamespaceStore()); const { t } = useI18n(); +const router = useRouter(); const columns = defineColumns([ { @@ -70,6 +71,16 @@ const selectable = (row: RayService) => { return false; }; + +const onCompare = () => { + const queryList = selectedRows.value?.map(({ metadata }) => metadata?.name); + + router.push({ + name: 'InferenceApplicationModelCompare', + query: { servicename: queryList }, + }); +}; + diff --git a/src/views/inference-application/InferenceApplicationModelCompare.vue b/src/views/inference-application/InferenceApplicationModelCompare.vue new file mode 100644 index 0000000..5395b07 --- /dev/null +++ b/src/views/inference-application/InferenceApplicationModelCompare.vue @@ -0,0 +1,185 @@ + + + + diff --git a/src/views/inference-application/components/comparison-chat-item.vue b/src/views/inference-application/components/comparison-chat-item.vue new file mode 100644 index 0000000..0a695f4 --- /dev/null +++ b/src/views/inference-application/components/comparison-chat-item.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/src/views/inference-application/components/comparison-chat-markdown.vue b/src/views/inference-application/components/comparison-chat-markdown.vue new file mode 100644 index 0000000..ea4d708 --- /dev/null +++ b/src/views/inference-application/components/comparison-chat-markdown.vue @@ -0,0 +1,23 @@ + + + + diff --git a/src/views/inference-application/components/comparison-chat-textarea.vue b/src/views/inference-application/components/comparison-chat-textarea.vue new file mode 100644 index 0000000..25b0c7a --- /dev/null +++ b/src/views/inference-application/components/comparison-chat-textarea.vue @@ -0,0 +1,86 @@ + + +