Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
# Conflicts: # assets/Scripts/chat18x/core/ChatAIService.ts # assets/Scripts/chat18x/utils/ErrorHandler.ts # xchat_cfg
This commit is contained in:
@@ -17,6 +17,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聊天服务类
|
||||
@@ -143,8 +144,10 @@ export class ChatAIService {
|
||||
},
|
||||
history: savedHistory,
|
||||
});
|
||||
console.log(chat);
|
||||
console.log(
|
||||
|
||||
logger.log(chat);
|
||||
|
||||
logger.log(
|
||||
`Loaded ${savedHistory.length} history messages for role ${roleId}`
|
||||
);
|
||||
} else {
|
||||
@@ -178,9 +181,9 @@ export class ChatAIService {
|
||||
],
|
||||
},
|
||||
});
|
||||
console.log(chat);
|
||||
logger.log(chat);
|
||||
|
||||
console.log(`Created new chat instance for role ${roleId}`);
|
||||
logger.log(`Created new chat instance for role ${roleId}`);
|
||||
}
|
||||
|
||||
this.chatInstances.set(roleId, chat);
|
||||
@@ -217,7 +220,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> {
|
||||
@@ -248,7 +251,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 {
|
||||
// 保存用户消息
|
||||
@@ -285,7 +288,7 @@ export class ChatAIService {
|
||||
message,
|
||||
response.text
|
||||
).catch((emotionError) => {
|
||||
console.warn(
|
||||
logger.warn(
|
||||
`Failed to update emotion for role ${roleId}:`,
|
||||
emotionError
|
||||
);
|
||||
@@ -335,7 +338,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}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,7 +350,7 @@ export class ChatAIService {
|
||||
EmotionAIService.Instance.clearAllEmotionHistory();
|
||||
// 清除本地存储的所有历史
|
||||
ChatHistoryManager.Instance.clearAllHistory();
|
||||
console.log("Cleared all chat histories");
|
||||
logger.log("Cleared all chat histories");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,7 +365,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);
|
||||
@@ -377,9 +380,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;
|
||||
// 保存数据
|
||||
@@ -408,9 +411,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