update
This commit is contained in:
@@ -22,6 +22,7 @@ export class GirlConfig extends BaseConfig {
|
||||
* 获取所有配置
|
||||
*/
|
||||
protected getAllConfig(): any | null {
|
||||
|
||||
return ConfigManager.tables.TbGirls;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { AiCharacters } from "../../schema/schema";
|
||||
import { ConfigManager } from "../manager/ConfigManager";
|
||||
import { AiCharacterConfig } from "../config/AiCharacterConfig";
|
||||
import { DataId, DataManager } from "../data/DataManager";
|
||||
import { GlobalData } from "../data/GlobalData";
|
||||
import { ConfigId, ConfigManager } from "../manager/ConfigManager";
|
||||
|
||||
/**
|
||||
* 角色配置映射
|
||||
@@ -12,17 +15,18 @@ export class RoleConfigLoader {
|
||||
* @returns System Instruction字符串,如果未找到则返回默认Role_1
|
||||
*/
|
||||
public static getRoleInstruction(roleId: number): string {
|
||||
const AiCharacter = ConfigManager.tables.TbAiCharacters.get(roleId);
|
||||
const globalPrompt = ConfigManager.tables.TbGlobalConfig.girlBasePrompt;
|
||||
const prompt =
|
||||
globalPrompt +
|
||||
"\n" +
|
||||
AiCharacter.basePrompt +
|
||||
"\n" +
|
||||
AiCharacter.additionPrompt;
|
||||
const aiCharacter = ConfigManager.I.getDataById<AiCharacterConfig>(
|
||||
ConfigId.AiCharacter
|
||||
);
|
||||
const globalConfig = DataManager.I.getDataById<GlobalData>(DataId.Global);
|
||||
|
||||
console.log(AiCharacter.basePrompt);
|
||||
console.log(AiCharacter.additionPrompt);
|
||||
const basePrompt = aiCharacter.getBasePromptById(roleId);
|
||||
const additionPrompt = aiCharacter.getAdditionPromptById(roleId);
|
||||
const globalPrompt = globalConfig.getGirlBasePrompt();
|
||||
const prompt = globalPrompt + "\n" + basePrompt + "\n" + additionPrompt;
|
||||
|
||||
console.log(basePrompt);
|
||||
console.log(additionPrompt);
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@@ -32,9 +36,15 @@ export class RoleConfigLoader {
|
||||
* @returns System Instruction字符串,如果未找到则返回默认Role_1
|
||||
*/
|
||||
public static getEmotionInstruction(roleId: number): string {
|
||||
const AiCharacter = ConfigManager.tables.TbAiCharacters.get(roleId);
|
||||
const globalPrompt = ConfigManager.tables.TbGlobalConfig.EmotionBasePrompt;
|
||||
const prompt = globalPrompt + "\n" + AiCharacter.basePrompt;
|
||||
const aiCharacter = ConfigManager.I.getDataById<AiCharacterConfig>(
|
||||
ConfigId.AiCharacter
|
||||
);
|
||||
const globalConfig = DataManager.I.getDataById<GlobalData>(DataId.Global);
|
||||
const basePrompt = aiCharacter.getBasePromptById(roleId);
|
||||
|
||||
////globalConfig没有emotionBasePrompt数据 请补充并替换下行
|
||||
const globalPrompt = globalConfig.getEmotionBasePrompt();
|
||||
const prompt = globalPrompt + "\n" + basePrompt;
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@@ -43,13 +53,19 @@ export class RoleConfigLoader {
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
public static hasRole(roleId: number): boolean {
|
||||
return ConfigManager.tables.TbAiCharacters.get(roleId) != null;
|
||||
const aiCharacter = ConfigManager.I.getDataById<AiCharacterConfig>(
|
||||
ConfigId.AiCharacter
|
||||
);
|
||||
return aiCharacter.getBasePromptById(roleId) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有配置的角色ID
|
||||
*/
|
||||
public static getAllRoles(): AiCharacters[] {
|
||||
return ConfigManager.tables.TbAiCharacters.getDataList();
|
||||
const aiCharacter = ConfigManager.I.getDataById<AiCharacterConfig>(
|
||||
ConfigId.AiCharacter
|
||||
);
|
||||
return aiCharacter.getAllId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 全局数据
|
||||
*/
|
||||
import { BaseData } from "./BaseData";
|
||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
|
||||
export class GlobalData extends BaseData {
|
||||
// api键
|
||||
@@ -29,6 +29,8 @@ export class GlobalData extends BaseData {
|
||||
private _emotionRating: string = "";
|
||||
// ai机器人基础规则
|
||||
private _girlBasePrompt: string = "";
|
||||
// emotion基础规则
|
||||
private _emotionBasePrompt: string = "";
|
||||
|
||||
public reset(): void {
|
||||
this._apiKey = "";
|
||||
@@ -43,6 +45,7 @@ export class GlobalData extends BaseData {
|
||||
this._gameName = "";
|
||||
this._emotionRating = "";
|
||||
this._girlBasePrompt = "";
|
||||
this._emotionBasePrompt = "";
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
@@ -58,6 +61,7 @@ export class GlobalData extends BaseData {
|
||||
this._gameName = "";
|
||||
this._emotionRating = "";
|
||||
this._girlBasePrompt = "";
|
||||
this._emotionBasePrompt = "";
|
||||
}
|
||||
|
||||
public destroy(): void {
|
||||
@@ -74,6 +78,7 @@ export class GlobalData extends BaseData {
|
||||
this._gameName = null;
|
||||
this._emotionRating = null;
|
||||
this._girlBasePrompt = null;
|
||||
this._emotionBasePrompt = null;
|
||||
}
|
||||
|
||||
/** 设置全局数据 */
|
||||
@@ -93,6 +98,7 @@ export class GlobalData extends BaseData {
|
||||
this._gameName = obj.GameName;
|
||||
this._emotionRating = obj.EmotionRating;
|
||||
this._girlBasePrompt = obj.girlBasePrompt;
|
||||
this._emotionBasePrompt = obj.EmotionBasePrompt;
|
||||
console.log("设置全局数据: ", this._gameName);
|
||||
}
|
||||
}
|
||||
@@ -156,4 +162,7 @@ export class GlobalData extends BaseData {
|
||||
public getGirlBasePrompt(): string {
|
||||
return this._girlBasePrompt;
|
||||
}
|
||||
public getEmotionBasePrompt(): string {
|
||||
return this._emotionBasePrompt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user