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键
|
||||
@@ -28,7 +28,9 @@ export class GlobalData extends BaseData {
|
||||
// 情绪评分机器人system_prompt,需拼接角色prompt
|
||||
private _emotionRating: string = "";
|
||||
// ai机器人基础规则
|
||||
private _girlBasePrompt: string = "";
|
||||
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,14 +98,15 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取api键 */
|
||||
public getApiKey(): string {
|
||||
return this._apiKey;
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取情绪判断机器人api */
|
||||
public getEmotionApiKey(): string {
|
||||
@@ -110,50 +116,53 @@ export class GlobalData extends BaseData {
|
||||
/** 获取ai模型 */
|
||||
public getModel(): string {
|
||||
return this._model;
|
||||
}
|
||||
}
|
||||
|
||||
/** Temperature */
|
||||
public getTemperature(): number {
|
||||
return this._temperature;
|
||||
}
|
||||
}
|
||||
|
||||
/** 单次聊天最大token */
|
||||
public getMaxTokens(): number {
|
||||
return this._maxTokens;
|
||||
}
|
||||
}
|
||||
|
||||
/** 超时时间(微秒) */
|
||||
public getTimeout(): number {
|
||||
return this._timeout;
|
||||
}
|
||||
}
|
||||
|
||||
/** 单个角色免费聊天次数 */
|
||||
public getFreeChatTimes(): number {
|
||||
return this._freeChatTimes;
|
||||
}
|
||||
}
|
||||
|
||||
/** 单次对话增长好感度 */
|
||||
public getOnceChatAddScore(): number {
|
||||
return this._onceChatAddScore;
|
||||
}
|
||||
}
|
||||
|
||||
/** 好感度等级兑换比例 */
|
||||
public getScoreExchangeStarLevel(): number {
|
||||
return this._scoreExchangeStarLevel;
|
||||
}
|
||||
}
|
||||
|
||||
/** 游戏名 */
|
||||
public getGameName(): string {
|
||||
return this._gameName;
|
||||
}
|
||||
}
|
||||
|
||||
/** 情绪评分机器人system_prompt,需拼接角色prompt */
|
||||
public getEmotionRating(): string {
|
||||
return this._emotionRating;
|
||||
}
|
||||
}
|
||||
|
||||
/** ai机器人基础规则 */
|
||||
public getGirlBasePrompt(): string {
|
||||
return this._girlBasePrompt;
|
||||
}
|
||||
}
|
||||
public getEmotionBasePrompt(): string {
|
||||
return this._emotionBasePrompt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user