feat: add token usage and top questions statistics retrieval
parent
719ba08c6e
commit
74b1bce315
|
|
@ -192,6 +192,26 @@ const getStatistics: (
|
|||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return get(`${prefix.value}/${application_id}/application_stats`, data, loading)
|
||||
}
|
||||
/**
|
||||
* 统计token消耗
|
||||
*/
|
||||
const getTokenUsage: (
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return get(`${prefix.value}/${application_id}/application_token_usage`, data, loading)
|
||||
}
|
||||
/**
|
||||
* 统计提问次数
|
||||
*/
|
||||
const topQuestions: (
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return get(`${prefix.value}/${application_id}/top_questions`, data, loading)
|
||||
}
|
||||
/**
|
||||
* 打开调试对话id
|
||||
* @param application_id 应用id
|
||||
|
|
@ -408,5 +428,7 @@ export default {
|
|||
speechToText,
|
||||
getMcpTools,
|
||||
postUploadFile,
|
||||
generate_prompt
|
||||
generate_prompt,
|
||||
getTokenUsage,
|
||||
topQuestions
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,23 @@ const getStatistics: (
|
|||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return get(`${prefix}/${application_id}/application_stats`, data, loading)
|
||||
}
|
||||
/**
|
||||
* 统计token消耗
|
||||
*/
|
||||
const getTokenUsage: (
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return get(`${prefix}/${application_id}/application_token_usage`, data, loading)
|
||||
}
|
||||
const topQuestions: (
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return get(`${prefix}/${application_id}/top_questions`, data, loading)
|
||||
}
|
||||
/**
|
||||
* 打开调试对话id
|
||||
* @param application_id 应用id
|
||||
|
|
@ -174,7 +191,7 @@ const playDemoText: (application_id: string, data: any, loading?: Ref<boolean>)
|
|||
* 文本转语音
|
||||
*/
|
||||
const postTextToSpeech: (
|
||||
application_id: String,
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
|
|
@ -184,7 +201,7 @@ const postTextToSpeech: (
|
|||
* 语音转文本
|
||||
*/
|
||||
const speechToText: (
|
||||
application_id: String,
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
|
|
@ -289,7 +306,7 @@ const updatePlatformConfig: (
|
|||
/**
|
||||
* mcp 节点
|
||||
*/
|
||||
const getMcpTools: (application_id: String, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
const getMcpTools: (application_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
application_id,
|
||||
loading,
|
||||
) => {
|
||||
|
|
@ -320,5 +337,7 @@ export default {
|
|||
speechToText,
|
||||
getMcpTools,
|
||||
putXpackAccessToken,
|
||||
generate_prompt
|
||||
generate_prompt,
|
||||
getTokenUsage,
|
||||
topQuestions
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,11 +59,20 @@ import AppCharts from '@/components/app-charts/index.vue'
|
|||
import {getAttrsArray, getSum} from '@/utils/array'
|
||||
import {numberFormat} from '@/utils/common'
|
||||
import {t} from '@/locales'
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
tokenUsage: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
topQuestions: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
}
|
||||
})
|
||||
const statisticsType = computed(() => [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -173,7 +173,8 @@
|
|||
/>
|
||||
</div>
|
||||
<div v-loading="statisticsLoading">
|
||||
<StatisticsCharts :data="statisticsData" />
|
||||
<StatisticsCharts :data="statisticsData" :token-usage="tokenUsage"
|
||||
:top-questions="topQuestions"/>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
|
@ -287,6 +288,8 @@ const daterange = ref({
|
|||
|
||||
const statisticsLoading = ref(false)
|
||||
const statisticsData = ref([])
|
||||
const tokenUsage = ref([])
|
||||
const topQuestions = ref([])
|
||||
|
||||
const apiInputParams = ref([])
|
||||
|
||||
|
|
@ -356,6 +359,16 @@ function getAppStatistics() {
|
|||
.then((res: any) => {
|
||||
statisticsData.value = res.data
|
||||
})
|
||||
loadSharedApi({type: 'application', systemType: apiType.value})
|
||||
.getTokenUsage(id, daterange.value, statisticsLoading)
|
||||
.then((res: any) => {
|
||||
tokenUsage.value = res.data
|
||||
})
|
||||
loadSharedApi({type: 'application', systemType: apiType.value})
|
||||
.topQuestions(id, daterange.value, statisticsLoading)
|
||||
.then((res: any) => {
|
||||
topQuestions.value = res.data
|
||||
})
|
||||
}
|
||||
|
||||
function refreshAccessToken() {
|
||||
|
|
@ -374,7 +387,8 @@ function refreshAccessToken() {
|
|||
const str = t('views.applicationOverview.appInfo.refreshToken.refreshSuccess')
|
||||
updateAccessToken(obj, str)
|
||||
})
|
||||
.catch(() => {})
|
||||
.catch(() => {
|
||||
})
|
||||
}
|
||||
|
||||
async function changeState(bool: boolean) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue