获取世界书 
getLorebooks 
获取世界书列表。
typescript
async function getLorebooks(): Promise<string[]>;返回值 
- 世界书名称列表: 
string[] 
getLorebookEntries 
获取世界书中的条目信息。
typescript
async function getLorebookEntries(
  lorebook: string,
  option: GetLorebookEntriesOption = {}
): Promise<LorebookEntry[]>;typescript
interface GetLorebookEntriesOption {
  filter?: "none" | Partial<LorebookEntry>; // 按照指定字段值筛选条目
}typescript
interface LorebookEntry {
  uid: number; // uid 是相对于世界书内部的,不要跨世界书使用
  display_index: number; // 酒馆中将排序设置为 "自定义" 时的显示顺序
  comment: string;
  enabled: boolean;
  type: "constant" | "selective" | "vectorized";
  position:
    | "before_character_definition" // 角色定义之前
    | "after_character_definition" // 角色定义之后
    | "before_example_messages" // 示例消息之前
    | "after_example_messages" // 示例消息之后
    | "before_author_note" // 作者注释之前
    | "after_author_note" // 作者注释之后
    | "at_depth_as_system" // @D⚙
    | "at_depth_as_assistant" // @D👤
    | "at_depth_as_user"; // @D🤖
  depth: number | null; // 仅对于 `position === 'at_depth_as_???'` 有意义;其他情况为 null
  order: number;
  probability: number;
  key: string[];
  logic: "and_any" | "and_all" | "not_all" | "not_any";
  filter: string[];
  scan_depth: "same_as_global" | number;
  case_sensitive: "same_as_global" | boolean;
  match_whole_words: "same_as_global" | boolean;
  use_group_scoring: "same_as_global" | boolean;
  automation_id: string | null;
  exclude_recursion: boolean;
  prevent_recursion: boolean;
  delay_until_recursion: boolean | number; // 启用则是 true, 如果设置了具体的 Recursion Level 则是数字
  content: string;
  group: string;
  group_prioritized: boolean;
  group_weight: number;
  sticky: number | null;
  cooldown: number | null;
  delay: number | null;
}参数 
lorebook 
- 类型: 
string - 描述: 世界书名称
 
filter? 
- 类型: 
"none" | Partial<LorebookEntry> - 描述: 按照指定字段值筛选条目,要求对应字段值包含制定的内容;默认为不进行筛选.如 
{content: '神乐光'}表示内容中必须有'神乐光',{type: 'selective'}表示仅获取绿灯条目."none": 不筛选Partial<LorebookEntry>: 按照指定字段值筛选条目,详见LorebookEntry
 
注意
由于实现限制,只能做到简单筛选;如果需要更复杂的筛选,请获取所有条目然后自己筛选。
示例 
typescript
// 获取世界书中所有条目的所有信息
const entries = await getLorebookEntries("eramgt少女歌剧");typescript
// 按内容筛选,content 中必须出现 `'神乐光'`
const entries = await getLorebookEntries("eramgt少女歌剧", {
  filter: { content: "神乐光" },
});getLorebookSettings 
获取当前的世界书全局设置。
typescript
async function getLorebookSettings(): Promise<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 = await getLorebookSettings();
alert(settings.selected_global_lorebooks);getCharLorebooks 
获取角色卡绑定的世界书。
typescript
async function getCharLorebooks(
  option: GetCharLorebooksOption = {}
): Promise<CharLorebook[]>;typescript
interface CharLorebook {
  name: string;
  type: "primary" | "additional";
}typescript
interface GetCharLorebooksOption {
  name?: string; // 要查询的角色卡名称;默认为当前角色卡
  type?: "all" | "primary" | "additional"; // 按角色世界书的绑定类型筛选世界书;默认为 'all'
}参数 
name? 
- 类型: 
string - 描述: 要查询的角色卡名称;默认为当前角色卡
 
type? 
- 类型: 
"all" | "primary" | "additional" - 描述: 按角色世界书的绑定类型筛选世界书;默认为 
"all" 
返回值 
- CharLorebook 数组: 
CharLorebook[] 
示例 
typescript
const lorebooks = await getCharLorebooks();typescript
const primaryLorebook = await getCharLorebooks({ type: "primary" });getCurrentCharPrimaryLorebook 
获取当前角色卡绑定的主要世界书。
typescript
async function getCurrentCharPrimaryLorebook(): Promise<string | null>;返回值 
- 主要世界书名称: 
string | null- 如果当前角色卡有绑定并使用世界书 (地球图标呈绿色), 返回该世界书的名称;否则返回null 
getOrCreateChatLorebook 
获取或创建当前聊天绑定的世界书。
typescript
async function getOrCreateChatLorebook(): Promise<string>;返回值 
- 聊天世界书名称: 
string