78 lines
2.0 KiB
Python
78 lines
2.0 KiB
Python
"""世谱 API schema。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class LorebookEntryBody(BaseModel):
|
|
keys: list[str] = Field(default_factory=list)
|
|
content: str = ""
|
|
secondary_keys: list[str] = Field(default_factory=list)
|
|
constant: bool = False
|
|
selective: bool = False
|
|
enabled: bool = True
|
|
case_sensitive: bool = False
|
|
use_regex: bool = False
|
|
position: str = "after_char"
|
|
insertion_order: int = 100
|
|
priority: int = 10
|
|
comment: str = ""
|
|
bound_entity_id: str | None = None
|
|
|
|
|
|
class LorebookEntryCreateRequest(LorebookEntryBody):
|
|
pass
|
|
|
|
|
|
class LorebookEntryUpdateRequest(BaseModel):
|
|
keys: list[str] | None = None
|
|
content: str | None = None
|
|
secondary_keys: list[str] | None = None
|
|
constant: bool | None = None
|
|
selective: bool | None = None
|
|
enabled: bool | None = None
|
|
case_sensitive: bool | None = None
|
|
use_regex: bool | None = None
|
|
position: str | None = None
|
|
insertion_order: int | None = None
|
|
priority: int | None = None
|
|
comment: str | None = None
|
|
bound_entity_id: str | None = None
|
|
|
|
|
|
class LorebookEntryResponse(LorebookEntryBody):
|
|
id: str
|
|
lorebook_id: str
|
|
|
|
|
|
class LorebookCreateRequest(BaseModel):
|
|
name: str = ""
|
|
description: str = ""
|
|
character_id: str | None = None # None + scope=global 表示全局世谱
|
|
scope: str = "character"
|
|
scan_depth: int | None = None
|
|
token_budget: int | None = None
|
|
recursive_scanning: bool = False
|
|
|
|
|
|
class LorebookUpdateRequest(BaseModel):
|
|
name: str | None = None
|
|
description: str | None = None
|
|
scan_depth: int | None = None
|
|
token_budget: int | None = None
|
|
recursive_scanning: bool | None = None
|
|
|
|
|
|
class LorebookResponse(BaseModel):
|
|
id: str
|
|
character_id: str | None
|
|
name: str
|
|
description: str
|
|
scope: str
|
|
scan_depth: int | None
|
|
token_budget: int | None
|
|
recursive_scanning: bool
|
|
status: str
|
|
entries: list[LorebookEntryResponse] = Field(default_factory=list)
|