diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index c703307d..8c65afdf 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -937,25 +937,27 @@ async function clickAnalysis(id?: number) { function getRecordUsage(recordId: any) { console.debug('getRecordUsage id: ', recordId) - nextTick(() => { - chatApi - .get_chart_usage(recordId) - .then((res) => { - const logHistory = chatApi.toChatLogHistory(res) - if (logHistory) { - currentChat.value.records.forEach((record) => { - if (record.id === recordId) { - record.duration = logHistory.duration - record.finish_time = logHistory.finish_time - record.total_tokens = logHistory.total_tokens - } - }) - } - }) - .catch((e) => { - console.error(e) - }) - }) + if (recordId) { + nextTick(() => { + chatApi + .get_chart_usage(recordId) + .then((res) => { + const logHistory = chatApi.toChatLogHistory(res) + if (logHistory) { + currentChat.value.records.forEach((record) => { + if (record.id === recordId) { + record.duration = logHistory.duration + record.finish_time = logHistory.finish_time + record.total_tokens = logHistory.total_tokens + } + }) + } + }) + .catch((e) => { + console.error(e) + }) + }) + } } const predictAnswerRef = ref()