获取世界书条目
getLorebookEntries
获取世界书中的条目信息。
typescript
function getLorebookEntries(lorebook: string): 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;
keys: string[];
logic: "and_any" | "and_all" | "not_all" | "not_any";
filters: 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
- 描述: 世界书名称
注意
注意:类型定义中 getLorebookEntries
不再接受 option
参数,为了保持兼容性,如果需要筛选,请获取所有条目后自行筛选。
示例
typescript
// 获取世界书中所有条目的所有信息
const entries = await getLorebookEntries("eramgt少女歌剧");
typescript
// 按内容筛选,content 中必须出现 `'神乐光'`
const entries = await getLorebookEntries("eramgt少女歌剧");
const filteredEntries = entries.filter(entry => entry.content.includes("神乐光"));