EasyNovelAssistant

repository·main·Indexed 42 days ago

https://github.com/zuntan03/easynovelassistant

A lightweight, uncensored local novel generation assistant for Japanese users. It utilizes the LightChatAssistant-TypeB GGUF model and integrates with KoboldCpp and Style-Bert-VITS2 to provide continuous text generation and text-to-speech capabilities.

Tokens
8.2K
Snippets
15
Records
36
Agent score
52%

What's inside EasyNovelAssistant

  1. Overview of EasyNovelAssistant

    main

    EasyNovelAssistant is a lightweight novel generation assistant that uses the local Japanese LLM LightChatAssistant-TypeB (a GGUF model). It features:

    • Generate forever: A local privilege for continuous generation.
    • Text-to-Speech (TTS): Supports audio reading of generated text.
    • Integration: It utilizes KoboldCpp and Style-Bert-VITS2 internally. You can also use it alongside EasySdxlWebUi to generate images while writing.
  2. Optimize GPU usage by adjusting GPU Layers

    main

    When using models with large context sizes, you may need to adjust the number of GPU layers to balance speed and VRAM usage.

    If you encounter errors due to high VRAM consumption when increasing the コンテキストサイズ上限 (Context Size Limit), decrease the model's GPU layer count (e.g., reducing from L33 to a lower value).

  3. Use Intro Prompts for chapter-based writing

    main

    EasyNovelAssistant supports a hierarchical prompt system using 'Intro Prompts'. This allows you to maintain world-building, character settings, or plot summaries across different tabs or files.

    1. Set an Intro Prompt: Right-click a tab and select イントロプロンプト (Intro Prompt) to designate it.
    2. Automatic Injection: When generating text in a different tab, the content of the designated Intro Prompt is automatically prepended to the generation request.
    3. Manual Trigger: If a tab's input field starts with // intro\n, it is treated as an Intro Prompt.
  4. Update KoboldCpp for better performance

    main

    To improve performance, especially on recent NVIDIA GPUs, you can update KoboldCpp using the provided batch scripts.

    • Update-KoboldCpp.bat: Standard update.
    • Update-KoboldCpp_CUDA12.bat: Updates to the CUDA 12 version of KoboldCpp, which is optimized for newer NVIDIA hardware.
  5. Run and Update EasyNovelAssistant

    main

    After installation, use the following batch files to manage the application:

    • To start the application: Run Run-EasyNovelAssistant.bat.
    • To update the application: Run Update-EasyNovelAssistant.bat.
    # Start the application
    Run-EasyNovelAssistant.bat
    
    # Update the application
    Update-EasyNovelAssistant.bat
  6. Install EasyNovelAssistant on Windows

    main

    To install EasyNovelAssistant, use the provided batch script. Ensure your installation directory uses an alphanumeric path that contains no spaces or Japanese characters.

    1. Download Install-EasyNovelAssistant.bat by right-clicking it and selecting Save as... into your target folder.
    2. Run the downloaded .bat file.
    3. If Windows displays a warning saying Windows protected your PC, click More info and then Run.
    4. When prompted to download related files from the source, type y to proceed.
    5. If Windows Security asks for network access permission, select Allow.

    Once the installation is complete, the application will launch automatically.

    # Download and run the installer
    # Note: Ensure the path is alphanumeric and contains no spaces or Japanese characters
    Install-EasyNovelAssistant.bat
  7. Configure UI colors via config.json

    main

    While font and theme settings can be adjusted via the Settings menu, you can perform fine-grained color customization by editing the config.json file with the following keys:

    {
    	"foreground_color": "#CCCCCC",
    	"select_foreground_color": "#FFFFFF",
    	"background_color": "#222222",
    	"select_background_color": "#555555"
    }
  8. Understand the SampleMenu data structure

    main

    The SampleMenu class uses a list of description dictionaries (descs) to define how sample content is loaded into the application's menu. Each dictionary defines the behavior for a specific category of sample data.

    Key fields in a description dictionary include:

    • label: The text displayed in the application's menu bar.
    • mode: The action taken when an item is selected. Supported modes are set (replaces current text), insert (appends text), and open (opens a URL).
    • path: The filename of the JSON file containing the sample data (located in the application's sample directory).
    • change_mode: A mapping used to override the default mode for specific items based on substrings in their names.
    • splitter_names: A list of names that, when encountered, trigger a menu separator to be drawn.
  9. Access Recent Files and Directories

    main

    The File menu dynamically populates two cascade menus based on your recent activity:

    • Recent Files (最近使ったファイル): A list of recently opened files. Clicking an item opens that file.
    • Recent Directories (最近開いたフォルダ): A list of recently opened directories. Clicking an item opens the directory and loads its .txt files.

    Note: If a file or directory in the recent list no longer exists on the filesystem, it is automatically removed from the list.

  10. Manage application state and window geometry via the context (ctx) object

    main

    The Form class uses a ctx object (passed during initialization) to persist window state and UI dimensions across sessions.

    Key state management functions include:

    • update_config(): Captures the current window dimensions (win_width, win_height), position (win_x, win_y), and component sizes (input_area_width, pane_v_width, gen_area_height) into the ctx object.
    • update_title(): Dynamically updates the window title based on the current model name, generation status, and the currently loaded file path.

    When the window is closed, self.ctx.finalize is called via the WM_DELETE_WINDOW protocol to ensure state is saved.

  11. How SampleMenu modes work

    main

    When a user selects an item from the SampleMenu, the on_menu_select method handles the action based on the item's mode:

    set and insert modes

    These modes interact with the application's text input area:

    1. URL Handling: If the item starts with http, the application attempts to download the content. If the download fails, it opens the URL in a web browser.
    2. Variable Substitution: The application performs string formatting on the content, replacing {char_name} and {user_name} with values from the current context (self.ctx).
    3. Text Injection:
      • set: Replaces the text in self.ctx.form.input_area with the processed item.
      • insert: Appends the processed item to the existing text in self.ctx.form.input_area.

    open mode

    This mode is used for external links:

    • If the item starts with http, it opens the URL in the default web browser.
    • If the item is not a URL, it logs an error.
  12. Install or launch the Style-Bert-VITS2 server

    main

    The StyleBertVits2 class includes helper methods to manage the underlying server process.

    • install(): On Windows, runs a setup batch file. On non-Windows platforms, it instructs the user to manually install Style-Bert-VITS2 and copy the configuration file from EasyNovelAssistant/setup/res/config.yml to the installation directory.
    • launch_server(): Starts the Style-Bert-VITS2 reading server. On Windows, this uses a batch file; on other platforms, it attempts to run server_fastapi.py using a virtual environment located in the Style-Bert-VITS2 directory.