获取世界书
getLorebooks
获取世界书列表。
typescript
function getLorebooks(): string[];
返回值
- 世界书名称列表:
string[]
:::
getLorebookSettings
获取当前的世界书全局设置。
typescript
function getLorebookSettings(): LorebookSettings;
typescript
interface LorebookSettings {
selected_global_lorebooks: string[];
scan_depth: number;
context_percentage: number;
budget_cap: number; // 0 表示禁用
min_activations: number;
max_depth: number; // 0 表示无限制
max_recursion_steps: number;
include_names: boolean;
recursive: boolean;
case_sensitive: boolean;
match_whole_words: boolean;
use_group_scoring: boolean;
overflow_alert: boolean;
insertion_strategy: "evenly" | "character_first" | "global_first";
}
返回值
- selected_global_lorebooks:
string[]
- scan_depth:
number
- context_percentage:
number
- budget_cap:
number
- min_activations:
number
- max_depth:
number
- max_recursion_steps:
number
- include_names:
boolean
- recursive:
boolean
- case_sensitive:
boolean
- match_whole_words:
boolean
- use_group_scoring:
boolean
- overflow_alert:
boolean
- insertion_strategy:
"evenly" | "character_first" | "global_first"
示例
typescript
// 获取全局启用的世界书
const settings = getLorebookSettings();
alert(settings.selected_global_lorebooks);
getCharLorebooks
获取角色卡绑定的世界书。
typescript
function getCharLorebooks({ name, type }?: GetCharLorebooksOption): CharLorebooks;
typescript
interface CharLorebooks {
primary: string | null;
additional: string[];
}
typescript
interface GetCharLorebooksOption {
name?: string; // 要查询的角色卡名称;默认为当前角色卡
type?: "all" | "primary" | "additional"; // 按角色世界书的绑定类型筛选世界书;默认为 'all'
}
参数
name?
- 类型:
string
- 描述: 要查询的角色卡名称;默认为当前角色卡
type?
- 类型:
"all" | "primary" | "additional"
- 描述: 按角色世界书的绑定类型筛选世界书;默认为
"all"
返回值
- CharLorebooks 对象:
{ primary: string | null; additional: string[]; }
- 主要世界书名称和附加世界书名称列表
示例
typescript
const lorebooks = getCharLorebooks();
typescript
const lorebooks = getCharLorebooks({ type: "primary" });
console.log(lorebooks.primary);
getCurrentCharPrimaryLorebook
获取当前角色卡绑定的主要世界书。
typescript
function getCurrentCharPrimaryLorebook(): string | null;
返回值
- 主要世界书名称:
string | null
- 如果当前角色卡有绑定并使用世界书 (地球图标呈绿色), 返回该世界书的名称;否则返回null
getChatLorebook
获取当前聊天绑定的世界书。
typescript
async function getChatLorebook(): Promise<string | null>;
返回值
- 聊天世界书名称:
string | null
- 当前聊天绑定的世界书名称,或 null 表示没有绑定世界书
setChatLorebook
设置当前聊天绑定的世界书。
typescript
async function setChatLorebook(lorebook: string | null): Promise<void>;
参数
lorebook
- 类型:
string | null
- 描述: 世界书名称,或 null 表示移除世界书
getOrCreateChatLorebook
获取或创建当前聊天绑定的世界书。
typescript
async function getOrCreateChatLorebook(lorebook?: string): Promise<string>;
参数
lorebook?
- 类型:
string
- 描述: 可选参数,指定世界书名称;如果未指定,则根据聊天文件名自动生成一个世界书名称
返回值
- 聊天世界书名称:
string