代码整理,ai相关配置转luban,聊天气泡缓存
This commit is contained in:
@@ -61,6 +61,32 @@ export enum PriceType {
|
||||
|
||||
|
||||
|
||||
export class AiCharacter {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this.id = _buf_.readInt()
|
||||
this.systemInstruction = _buf_.readString()
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
readonly id: number
|
||||
/**
|
||||
* 系统指令
|
||||
*/
|
||||
readonly systemInstruction: string
|
||||
|
||||
resolve(tables:Tables) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class Girl {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
@@ -155,6 +181,47 @@ export class GirlDetail {
|
||||
|
||||
|
||||
|
||||
export class GlobalConfig {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this.ApiKey = _buf_.readString()
|
||||
this.Model = _buf_.readString()
|
||||
this.Temperature = _buf_.readFloat()
|
||||
this.MaxTokens = _buf_.readInt()
|
||||
this.Timeout = _buf_.readInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* api键
|
||||
*/
|
||||
readonly ApiKey: string
|
||||
/**
|
||||
* ai模型
|
||||
*/
|
||||
readonly Model: string
|
||||
readonly Temperature: number
|
||||
/**
|
||||
* 单次聊天最大token
|
||||
*/
|
||||
readonly MaxTokens: number
|
||||
/**
|
||||
* 超时时间(微秒)
|
||||
*/
|
||||
readonly Timeout: number
|
||||
|
||||
resolve(tables:Tables) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class Language {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
@@ -451,6 +518,76 @@ export class TbThemes {
|
||||
|
||||
|
||||
|
||||
export class TbAiCharacters {
|
||||
private _dataMap: Map<number, AiCharacter>
|
||||
private _dataList: AiCharacter[]
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this._dataMap = new Map<number, AiCharacter>()
|
||||
this._dataList = []
|
||||
for(let n = _buf_.readInt(); n > 0; n--) {
|
||||
let _v: AiCharacter
|
||||
_v = new AiCharacter(_buf_)
|
||||
this._dataList.push(_v)
|
||||
this._dataMap.set(_v.id, _v)
|
||||
}
|
||||
}
|
||||
|
||||
getDataMap(): Map<number, AiCharacter> { return this._dataMap; }
|
||||
getDataList(): AiCharacter[] { return this._dataList; }
|
||||
|
||||
get(key: number): AiCharacter | undefined {
|
||||
return this._dataMap.get(key);
|
||||
}
|
||||
|
||||
resolve(tables:Tables) {
|
||||
for(let data of this._dataList)
|
||||
{
|
||||
data.resolve(tables)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export class TbGlobalConfig {
|
||||
|
||||
private _data: GlobalConfig
|
||||
constructor(_buf_: ByteBuf) {
|
||||
if (_buf_.readInt() != 1) throw new Error('table mode=one, but size != 1')
|
||||
this._data = new GlobalConfig(_buf_)
|
||||
}
|
||||
|
||||
getData(): GlobalConfig { return this._data; }
|
||||
|
||||
/**
|
||||
* api键
|
||||
*/
|
||||
get ApiKey(): string { return this._data.ApiKey; }
|
||||
/**
|
||||
* ai模型
|
||||
*/
|
||||
get Model(): string { return this._data.Model; }
|
||||
get Temperature(): number { return this._data.Temperature; }
|
||||
/**
|
||||
* 单次聊天最大token
|
||||
*/
|
||||
get MaxTokens(): number { return this._data.MaxTokens; }
|
||||
/**
|
||||
* 超时时间(微秒)
|
||||
*/
|
||||
get Timeout(): number { return this._data.Timeout; }
|
||||
|
||||
resolve(tables:Tables) {
|
||||
this._data.resolve(tables)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
type ByteBufLoader = (file: string) => ByteBuf
|
||||
|
||||
export class Tables {
|
||||
@@ -462,6 +599,10 @@ export class Tables {
|
||||
get TbGirlsDetail(): TbGirlsDetail { return this._TbGirlsDetail;}
|
||||
private _TbThemes: TbThemes
|
||||
get TbThemes(): TbThemes { return this._TbThemes;}
|
||||
private _TbAiCharacters: TbAiCharacters
|
||||
get TbAiCharacters(): TbAiCharacters { return this._TbAiCharacters;}
|
||||
private _TbGlobalConfig: TbGlobalConfig
|
||||
get TbGlobalConfig(): TbGlobalConfig { return this._TbGlobalConfig;}
|
||||
|
||||
static getTableNames(): string[] {
|
||||
let names: string[] = [];
|
||||
@@ -469,6 +610,8 @@ export class Tables {
|
||||
names.push('tbgirls');
|
||||
names.push('tbgirlsdetail');
|
||||
names.push('tbthemes');
|
||||
names.push('tbaicharacters');
|
||||
names.push('tbglobalconfig');
|
||||
return names;
|
||||
}
|
||||
|
||||
@@ -477,11 +620,15 @@ export class Tables {
|
||||
this._TbGirls = new TbGirls(loader('tbgirls'))
|
||||
this._TbGirlsDetail = new TbGirlsDetail(loader('tbgirlsdetail'))
|
||||
this._TbThemes = new TbThemes(loader('tbthemes'))
|
||||
this._TbAiCharacters = new TbAiCharacters(loader('tbaicharacters'))
|
||||
this._TbGlobalConfig = new TbGlobalConfig(loader('tbglobalconfig'))
|
||||
|
||||
this._TbLanguage.resolve(this)
|
||||
this._TbGirls.resolve(this)
|
||||
this._TbGirlsDetail.resolve(this)
|
||||
this._TbThemes.resolve(this)
|
||||
this._TbAiCharacters.resolve(this)
|
||||
this._TbGlobalConfig.resolve(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user