novelai_api.StoryHandler

class NovelAIStory[source]

Bases: object

TEXT_GENERATION_SETTINGS_VERSION = 2
DEFAULT_MODEL = 'euterpe-v2'
keystore: novelai_api.Keystore.Keystore
banlists: List[novelai_api.BanList.BanList]
biases: List[novelai_api.BiasGroup.BiasGroup]
model: novelai_api.Preset.Model
preset: novelai_api.Preset.Preset
prefix: str
__init__(api: novelai_api.NovelAI_API.NovelAIAPI, keystore: novelai_api.Keystore.Keystore, meta: str, global_settings: novelai_api.GlobalSettings.GlobalSettings, story: Dict[str, Any], storycontent: Dict[str, Any])[source]
api: novelai_api.NovelAI_API.NovelAIAPI
key: bytes
story: Dict[str, Any]
storycontent: Dict[str, Any]
tree: List[int]
global_settings: novelai_api.GlobalSettings.GlobalSettings
context_size: int
build_context() List[int][source]
async generate()[source]
async edit(start: int, end: int, replace: str)[source]
async undo()[source]
async redo()[source]
async save(upload: bool = False) bool[source]
async choose(index: int)[source]
async flatten()[source]
async delete()[source]
async get_current_tree() List[Dict[str, Any]][source]
class NovelAIStoryStorage[source]

Bases: object

General storage for the NovelAIStory objects. Instances of this class should be loaded or created from here.

__init__(api: novelai_api.NovelAI_API.NovelAIAPI, keystore: novelai_api.Keystore.Keystore, global_settings: novelai_api.GlobalSettings.GlobalSettings | None = None)[source]
api: novelai_api.NovelAI_API.NovelAIAPI
keystore: novelai_api.Keystore.Keystore
idstore: novelai_api.Idstore.Idstore
global_settings: novelai_api.GlobalSettings.GlobalSettings
load(story: Dict[str, Any], storycontent: Dict[str, Any]) novelai_api.StoryHandler.NovelAIStory[source]

Load a story proxy from a story and storycontent object

loads(stories: Dict[str, Dict[str, Any]], storycontents: Dict[str, Dict[str, Any]]) List[novelai_api.StoryHandler.NovelAIStory][source]
async load_from_remote() List[novelai_api.StoryHandler.NovelAIStory][source]
create() novelai_api.StoryHandler.NovelAIStory[source]
select(story_id: str) novelai_api.StoryHandler.NovelAIStory | None[source]

Select a story proxy from the previously created/loaded ones

Parameters:

story_id – Id of the selected story

Returns:

Story or None if the story does’t exist in the handler

unload(story_id: str)[source]

Unload a previously created/loaded story, free’ing the NovelAI_StoryProxy object