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:
2025-09-21 20:51:31 +08:00
75 changed files with 1094 additions and 899 deletions
+13 -12
View File
@@ -10,6 +10,7 @@ import { ConfigManager } from "../manager/ConfigManager";
import LanguageUtils, { LanguageType } from "../../Main/Common/LanguageUtils";
import Utils from "../../Main/Common/Utils";
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
/**
* AI情绪分析服务类
@@ -24,7 +25,7 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
* ```typescript
* const emotionService = EmotionAIService.Instance;
* const emotion = await emotionService.analyzeEmotionalState(10001);
* console.log(VideoEmotion[emotion]); // "calm_down"
* logger.log(VideoEmotion[emotion]); // "calm_down"
* ```
*
* @author AI Chat System
@@ -86,7 +87,7 @@ export class EmotionAIService {
});
this.emotionChatInstances.set(roleId, chat);
console.log(`Created new emotion chat instance for role ${roleId}`);
logger.log(`Created new emotion chat instance for role ${roleId}`);
// 异步分析历史情绪状态
this.initializeEmotionAnalysis(roleId);
@@ -106,7 +107,7 @@ export class EmotionAIService {
let emotionalState: VideoEmotion;
if (messageCount > 0) {
console.log(
logger.log(
`Analyzing emotional state for role ${roleId} based on ${messageCount} messages`
);
@@ -115,11 +116,11 @@ export class EmotionAIService {
if (emotionalState == null) {
emotionalState = VideoEmotion.calm_down;
}
console.log(
logger.log(
`Initial emotional state for role ${roleId}: ${VideoEmotion[emotionalState]}`
);
} else {
console.log(
logger.log(
`No history found for role ${roleId}, using default emotion: calm_down`
);
emotionalState = VideoEmotion.calm_down;
@@ -131,11 +132,11 @@ export class EmotionAIService {
emotion: emotionalState,
});
console.log(
logger.log(
`Emotion initialization completed for role ${roleId}: ${VideoEmotion[emotionalState]}`
);
} catch (error) {
console.error(
logger.error(
`Failed to initialize emotion analysis for role ${roleId}:`,
error
);
@@ -209,7 +210,7 @@ export class EmotionAIService {
});
if (response && response.text) {
console.log(`Emotion analysis from role ${roleId}:`, response.text);
logger.log(`Emotion analysis from role ${roleId}:`, response.text);
return this.parseEmotionResponse(response.text);
} else {
const warningMsg = `情绪AI返回了空响应 (角色ID: ${roleId})`;
@@ -297,7 +298,7 @@ export class EmotionAIService {
if (this.emotionChatInstances.has(roleId)) {
this.emotionChatInstances.delete(roleId);
}
console.log(`Cleared emotion chat history for role ${roleId}`);
logger.log(`Cleared emotion chat history for role ${roleId}`);
}
/**
@@ -305,7 +306,7 @@ export class EmotionAIService {
*/
public clearAllEmotionHistory(): void {
this.emotionChatInstances.clear();
console.log("Cleared all emotion chat histories");
logger.log("Cleared all emotion chat histories");
}
/**
@@ -331,7 +332,7 @@ export class EmotionAIService {
*/
private setCurrentEmotion(roleId: number, emotion: VideoEmotion): void {
this.currentEmotions.set(roleId, emotion);
console.log(`Updated emotion for role ${roleId}: ${VideoEmotion[emotion]}`);
logger.log(`Updated emotion for role ${roleId}: ${VideoEmotion[emotion]}`);
}
/**
@@ -353,7 +354,7 @@ export class EmotionAIService {
}
}
} catch (error) {
console.warn(`Failed to get role name for ${roleId}:`, error);
logger.warn(`Failed to get role name for ${roleId}:`, error);
}
return "AI";
}