chore(ai): 增加调试日志输出
This commit is contained in:
@@ -32,7 +32,15 @@ export default {
|
|||||||
*/
|
*/
|
||||||
async sendMessage(message, options = {}) {
|
async sendMessage(message, options = {}) {
|
||||||
try {
|
try {
|
||||||
|
// 调试:打印关键状态
|
||||||
|
console.log('[AI Service] sendMessage 开始执行');
|
||||||
|
console.log('[AI Service] store.state.memberInfo:', store.state.memberInfo);
|
||||||
|
console.log('[AI Service] store.state.uniacid:', store.state.uniacid);
|
||||||
|
console.log('[AI Service] currentConversationId:', this.getConversationId());
|
||||||
|
|
||||||
const aiConfig = store.getters.globalAIKefuConfig;
|
const aiConfig = store.getters.globalAIKefuConfig;
|
||||||
|
console.log('[AI Service] aiConfig:', aiConfig);
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
url: '/api/kefu/chat',
|
url: '/api/kefu/chat',
|
||||||
data: {
|
data: {
|
||||||
@@ -50,21 +58,30 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('Sending blocking request to:', params.url);
|
console.log('[AI Service] 发送请求到:', params.url);
|
||||||
console.log('Request data:', params.data);
|
console.log('[AI Service] 请求参数:', JSON.stringify(params.data, null, 2));
|
||||||
|
|
||||||
const response = await http.sendRequest({
|
const response = await http.sendRequest({
|
||||||
...params,
|
...params,
|
||||||
async: false
|
async: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('[AI Service] 收到响应:', response);
|
||||||
|
|
||||||
const result = this.handleResponse(response);
|
const result = this.handleResponse(response);
|
||||||
if (result.conversationId) {
|
if (result.conversationId) {
|
||||||
this.setConversationId(result.conversationId);
|
this.setConversationId(result.conversationId);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Dify API请求失败:', error);
|
console.error('[AI Service] Dify API请求失败,详细错误:', error);
|
||||||
|
console.error('[AI Service] 错误堆栈:', error.stack);
|
||||||
|
// 打印更多信息帮助调试
|
||||||
|
console.error('[AI Service] store 状态:', {
|
||||||
|
memberInfo: store.state.memberInfo,
|
||||||
|
uniacid: store.state.uniacid,
|
||||||
|
token: store.state.token
|
||||||
|
});
|
||||||
throw new Error('AI服务暂时不可用,请稍后重试');
|
throw new Error('AI服务暂时不可用,请稍后重试');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -361,6 +378,7 @@ export default {
|
|||||||
async: false,
|
async: false,
|
||||||
data: {}
|
data: {}
|
||||||
});
|
});
|
||||||
|
console.log('/api/kefu/health response', response);
|
||||||
const available = [response?.data?.status, response?.data?.components?.ai_service_config?.status]
|
const available = [response?.data?.status, response?.data?.components?.ai_service_config?.status]
|
||||||
.filter(item => item === 'healthy').length > 0;
|
.filter(item => item === 'healthy').length > 0;
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1146,11 +1146,8 @@ async loadChatHistoryIfExist() {
|
|||||||
|
|
||||||
// 格式化时间
|
// 格式化时间
|
||||||
formatTime(timestamp) {
|
formatTime(timestamp) {
|
||||||
console.log('【调试】formatTime 接收到的时间戳:', timestamp, typeof timestamp);
|
|
||||||
|
|
||||||
// 如果没有时间戳,就不显示时间
|
// 如果没有时间戳,就不显示时间
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
console.warn('【调试】没有时间戳');
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1183,21 +1180,15 @@ async loadChatHistoryIfExist() {
|
|||||||
date = new Date(timeValue);
|
date = new Date(timeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('【调试】最终 Date 对象:', date);
|
|
||||||
console.log('【调试】本地时间:', date.toLocaleString());
|
|
||||||
console.log('【调试】小时:', date.getHours());
|
|
||||||
console.log('【调试】分钟:', date.getMinutes());
|
|
||||||
|
|
||||||
// 如果时间无效,就不显示时间
|
// 如果时间无效,就不显示时间
|
||||||
if (isNaN(date.getTime())) {
|
if (isNaN(date.getTime())) {
|
||||||
console.warn('【调试】时间无效:', timestamp);
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const hours = date.getHours().toString().padStart(2, '0');
|
const hours = date.getHours().toString().padStart(2, '0');
|
||||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||||
const result = hours + ':' + minutes;
|
const result = hours + ':' + minutes;
|
||||||
console.log('【调试】最终显示时间:', result);
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user