日志控制
This commit is contained in:
@@ -12,6 +12,7 @@ import { GirlData } from "../data/GirlData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import { TipsPanel } from "../ui/panels/TipsPanel";
|
||||
import LanguageUtils from "../../Main/Common/LanguageUtils";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
/**
|
||||
* AI聊天服务类
|
||||
@@ -130,7 +131,7 @@ export class ChatAIService {
|
||||
},
|
||||
history: savedHistory,
|
||||
});
|
||||
console.log(
|
||||
logger.log(
|
||||
`Loaded ${savedHistory.length} history messages for role ${roleId}`
|
||||
);
|
||||
} else {
|
||||
@@ -164,7 +165,7 @@ export class ChatAIService {
|
||||
],
|
||||
},
|
||||
});
|
||||
console.log(`Created new chat instance for role ${roleId}`);
|
||||
logger.log(`Created new chat instance for role ${roleId}`);
|
||||
}
|
||||
|
||||
this.chatInstances.set(roleId, chat);
|
||||
@@ -201,7 +202,7 @@ export class ChatAIService {
|
||||
* @example
|
||||
* ```typescript
|
||||
* const response = await chatService.sendMessage(10001, "你好");
|
||||
* console.log(response); // AI的回复
|
||||
* logger.log(response); // AI的回复
|
||||
* ```
|
||||
*/
|
||||
public async sendMessage(roleId: number, message: string): Promise<string> {
|
||||
@@ -231,7 +232,7 @@ export class ChatAIService {
|
||||
});
|
||||
|
||||
if (response && response.text) {
|
||||
console.log(`Response from role ${roleId}:`, response.text);
|
||||
logger.log(`Response from role ${roleId}:`, response.text);
|
||||
|
||||
try {
|
||||
// 保存用户消息
|
||||
@@ -318,7 +319,7 @@ export class ChatAIService {
|
||||
EmotionAIService.Instance.clearEmotionHistory(roleId);
|
||||
// 清除本地存储的历史
|
||||
ChatHistoryManager.Instance.clearHistory(roleId);
|
||||
console.log(`Cleared chat history for role ${roleId}`);
|
||||
logger.log(`Cleared chat history for role ${roleId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,7 +331,7 @@ export class ChatAIService {
|
||||
EmotionAIService.Instance.clearAllEmotionHistory();
|
||||
// 清除本地存储的所有历史
|
||||
ChatHistoryManager.Instance.clearAllHistory();
|
||||
console.log("Cleared all chat histories");
|
||||
logger.log("Cleared all chat histories");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,7 +346,7 @@ export class ChatAIService {
|
||||
* @deprecated 请使用sendMessage方法,此方法将在下个版本中移除
|
||||
*/
|
||||
public async Post(data: GPTRequest): Promise<string> {
|
||||
console.warn("Post方法已废弃,请使用sendMessage方法");
|
||||
logger.warn("Post方法已废弃,请使用sendMessage方法");
|
||||
const roleId = this.currentRoleId || 10001; // 默认使用第一个角色
|
||||
const message = data.messages[0]?.content || "";
|
||||
return this.sendMessage(roleId, message);
|
||||
@@ -360,9 +361,9 @@ export class ChatAIService {
|
||||
girlId,
|
||||
msgs: msgList,
|
||||
};
|
||||
console.log("请求上报聊天数据的请求数据:", reqData);
|
||||
logger.log("请求上报聊天数据的请求数据:", reqData);
|
||||
let res = await ChatService.I.reqChatMsg(reqData);
|
||||
console.log("请求上报聊天数据的响应数据:", res);
|
||||
logger.log("请求上报聊天数据的响应数据:", res);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
const resData = res.data;
|
||||
// 保存数据
|
||||
@@ -391,9 +392,9 @@ export class ChatAIService {
|
||||
page,
|
||||
limit,
|
||||
};
|
||||
console.log("获取聊天数据的请求数据:", reqData);
|
||||
logger.log("获取聊天数据的请求数据:", reqData);
|
||||
let res = await ChatService.I.reqGetChatMsg(reqData);
|
||||
console.log("获取聊天数据的响应数据:", res);
|
||||
logger.log("获取聊天数据的响应数据:", res);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
const resData = res.data;
|
||||
// 保存数据
|
||||
|
||||
Reference in New Issue
Block a user