代码整理,ai相关配置转luban,聊天气泡缓存
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { AiCharacter } from "../../schema/schema";
|
||||
import ConfigManager from "../manager/ConfigManager";
|
||||
|
||||
/**
|
||||
* 角色配置映射
|
||||
* 将角色ID映射到对应的System Instruction
|
||||
*/
|
||||
export class RoleConfigLoader {
|
||||
/**
|
||||
* 根据角色ID获取对应的System Instruction
|
||||
* @param roleId 角色ID
|
||||
* @returns System Instruction字符串,如果未找到则返回默认Role_1
|
||||
*/
|
||||
public static getRoleInstruction(roleId: number): string {
|
||||
const AiCharacter = ConfigManager.tables.TbAiCharacters.get(roleId);
|
||||
|
||||
return AiCharacter
|
||||
? AiCharacter.systemInstruction
|
||||
: ConfigManager.tables.TbAiCharacters.get(10001).systemInstruction;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查角色是否存在配置
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
public static hasRole(roleId: number): boolean {
|
||||
return ConfigManager.tables.TbAiCharacters.get(roleId) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有配置的角色ID
|
||||
*/
|
||||
public static getAllRoles(): AiCharacter[] {
|
||||
return ConfigManager.tables.TbAiCharacters.getDataList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user