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