Prompt Constructor
A standalone prompt editor for AI chat.
© 2024 NKMR AppWorks
English / Japanese
Download (Free):
This application is released under the MIT License. Please use it in accordance with the terms of the license.
This tool is developed to reduce the effort of inputting prompts when using AI chat and similar applications.
To alleviate the hassle of repeatedly entering similar phrases, it allows you to register frequently used syntax and words.
You can then select these items sequentially to complete your prompt using this editor.
The following must be installed in your environment.
Python 3.12.x or later
Cerberus 1.3.5 or later (Required for v1.0.22 and later.)
Clone the git repository to a suitable location (or download and extract the zip file), then run 'prompt_constructor_launcher.pyw'.
You can also run 'prompt_constructor.py' normally to use the application, but an unnecessary black window will appear.
Running via 'prompt_constructor_launcher.pyw' can suppress this black window.
Alternatively, you can rename 'prompt_constructor.py' to 'prompt_constructor.pyw' and run it directly to suppress the black window.
(In this case, the launcher will not work without modification, but this isn't an issue as changing the main file's extension eliminates the need for the launcher.)
Note that the black window doesn't affect the application's functionality; it's just visually distracting.
Python must be installed in your execution environment. The expected version is Python 3.12.x or higher.
Some files and folders will be automatically created on the first run. Works entirely locally.
As it don't use the registry, simply deleting the folder completes the uninstallation.
Make sure to back up any necessary files beforehand.
The following explains each feature based on the numbered items in the screenshot above.
Tree View Operation Functions
"Add Parent" Button:
Adds a parent item to the currently displayed tab. When adding a parent item, three child items are automatically added.
"Add Child" Button:
Adds a child item to the currently displayed tab. This function only works when a parent or child item is selected. The child item is added under the parent item of the selected item.
"+" Button:
Expands all items under each parent item in the tree.
"-" Button:
Collapses all items under each parent item in the tree.
Delete Button:
Deletes the selected item in the tree. If "Auto Save dicts." is enabled (checked), dictionary files are automatically updated. This function doesn't work if nothing is selected. Note that parent items in the "Favorites" tab cannot be deleted.
Tree View Tabs
Chunks Tab:
Typically used to register longer syntax containing multiple words, but single words can also be registered.
Parent items are used as category names. Child items contain the actual content you want to add to your prompt.
Double-clicking a child item on a child item will append the content to the "Prompt Area". A comma and space are appended automatically. Allow a slight pause between clicks, or the content won't be added to the "Prompt Area".
Both parent and child items can be selected by right-clicking to display a menu. The parent item has “Copy text to clipboard” and “Delete” options, while the child item has “Clone this item” and “Add to favorites” options. "Clone this item” creates the same item under the selected child item. If the item is added to Favorites, it will be added under “Fav:Chunks” in the "Favorites" tab.
You can change the order of items by drag-and-drop.
Words Tab:
Typically used to register short phrases or single words, but spaces, commas, and longer sentences can also be registered.
All operations are the same as the "Chunks" tab, except that "Favorites" are added under "Fav:Words" in the "Favorites" tab.
Favorites Tab:
Displays items marked as "Favorites" from the "Chunks" and "Words" tabs.
Favorited items are managed separately from the original items. Modifying or deleting the original item doesn't affect the favorited item. They are copied to other dictionary and exist as independent items after copying.
Parent items in the "Favorites" tab cannot be deleted. But, v1.0.18 and later, it is now possible to modify each parent item in the "Favorites" tab, but you cannot swap the parent items' location. Recommend that you give those items easy-to-understand names.
Tree View
Displays the contents of dictionary files. The displayed content varies by tab, and the "Tree View Operation Functions" apply to the currently displayed tab.
Parent items correspond to categories. Parent items in the "Chunks" and "Words" tabs can be deleted or renamed. Child items contain the actual text to be added to the "Prompt Area".
Refer to the previous tab descriptions for more details.
"Saving Dictionaries" Related Functions
"Auto Save dicts." Checkbox:
When checked it, dictionary files are updated each time changes are made to the item in the tree. If you don't want frequent writes, leave this unchecked. However, in that case, you'll need to manually save using the "Save dicts." button.
If you try to exit the app without this checkbox checked, a warning dialog will appear. This warning appears even if you've just saved using the "Save dicts." button.
"Save dicts." Button:
Save dictionary datas displayed in the three Tree View tabs to JSON files. They are saved in separate files. You can't save them individually, all are overwritten at once.
Function to Update Item Values
Update Button:
Updates the content of the currently edited item. If "Auto Save dicts." is enabled, dictionary files are immediately overwritten. Otherwise, only the data in the Tree View is updated. Refer also to the section "Text Area for Displaying and Editing the Content of the Selected Item".
Copy Button:
Copies the current content of the item textbox to the clipboard. You can also copy by selecting a range in the item textbox and using CTRL+C.
"Prompt Area" Related Functions
List Button:
If there are files in the "prompt" folder with the format "prompt_saved_~.txt", their contents are listed.
Selecting displayed content adds it to the "Prompt Area". If there are no files, nothing can be listed.
Load Button:
Loads a text file and displays its content in the "Prompt Area".
Save Button:
Saves the content of the "Prompt Area" to a text file. To use the "List" button function, make sure to save the file with the naming convention "prompt_saved_~.txt". Note that files not displayed in the list can still be loaded with the "Load" button if they are text files.
Copy Button:
Copies the current content of the "Prompt Area" to the clipboard. You can also copy by selecting a range in the "Prompt Area" and using CTRL+C.
Shuffle Button:
Randomly reorders the content of the "Prompt Area" by comma-separated units. Areas enclosed in "()" are treated as a single unit even if they contain commas.
Lock Checkbox:
When checked it, editing of the "Prompt Area" is disabled. This is useful for preventing accidental edits or operations. Note that copying is still possible even when editing is disabled.
Clear Button:
Empties the "Prompt Area". This cannot be used when the "Lock" checkbox is checked.
Text Area for Displaying and Editing the Content of the Selected Item (Item Area)
This text area displays the content of the item selected in the Tree View on the left. You can modify the displayed text and press the "Update" button to update the content of the selected item.
The comment feature in the item text is supported. From the sentence beginning with ‘#’ to the end of that line is ignored when the item is clicked on to add it to the "Prompt Area". This means that you can make memo-like statements that do not affect the prompt. You can add multiple lines anywhere on the item.
v1.0.29: Scrollbars were added next to Textboxes (screenshots are still from the old version).
Prompt Area
This text area displays the prompt being edited. It's empty by default, but if there's a file named "prompt_tmp_~.txt" in the "prompt" folder, it's automatically loaded and displayed when the app starts. When the app is closed, the content is automatically saved to a "prompt_tmp_~.txt" file in the "prompt" folder.
v1.0.29: Scrollbars were added next to Textboxes (screenshots are still from the old version).
Search Box:
Searches for the string you entered. If there is a match in the "Prompt Area" and "Item Area"(v1.0.20 or later), they will be highlighted. If you do not want to highlight strings, leave this field blank.
When you press the Enter key after entering text, the first part of the string that matches the search is displayed in red.
Settings
このボタンを押すと、別途画面が開き、設定ファイルの設定を変更することができます。「Default」ボタンを押すと初期設定に戻り、「Apply」ボタンで変更を確定します。「Cancel」ボタンで設定変更をキャンセルし画面を閉じます。「Close」ボタンも画面を閉じる機能です。
重要な点は「Apply」ボタンを押したタイミングでiniファイルが上書きされるということです。
This button opens a another screen where you can change the settings in the configuration file. The “Default” button returns to the default settings, and the “Apply” button confirms the changes. The “Cancel” button cancels the change and closes the screen. The “Close” button also closes the screen.
The important point is that the ini file is overwritten when the “Apply” button is pressed. And, just pressing the “Default” button does not yet overwrite the ini file. To confirm the settings restored with the “Default” button, press the “Apply” button afterwards.
CTRL+A: Selects all text in a text area.
CTRL+C: Copies the selected text to the clipboard.
CTRL+X: Cuts the selected text and copies it to the clipboard.
CTRL+Z: Undo.
CTRL+Y: Redo.
CTRL+F: Focus to the search box, and if there is already a search text in the search box, it becomes selected all.
CTRL+Up/Down Arrow: When text is selected, this operation encloses the selected range in "()" and adds a weighting value like ":1.05". The increment unit is 0.1 or 0.05, set by the "increment_unit" value in the ini file.
SHIFT+Rotating Mouse Wheel: Changes the font size. The left and right sides of the screen have separate font size settings, so the size changes depending on which side the mouse cursor is positioned.
SHIFT+Clicking Mouse Wheel:: Reset the font size to the setting in the ini file (=font size at app startup).
ESC: Exits the application.
You can resize the app window by dragging its edges. You can also change the display ratio by dragging the boundary line between panes. The initial window size can be set in the ini file using the "window_width" and "window_height" values.
You can change the app's behavior by modifying the settings in the "settings.ini" file.
This file needs to be in the same directory as the main application file. If it doesn't exist, it will be created automatically.
On first launch, the file won't exist, so run the application once. A "settings.ini" file should be created along with dictionary files and folders. You can edit this file with a text editor.
If the settings become incorrect or you want to reset to the initial state, delete this file and it will be automatically recreated the next time you launch the app.
The following settings are available (as of v1.0.10):
lang:
GUI language setting. "en" or "ja" can be selected (default is "en").
increment_unit:
Unit for text weighting when using shortcuts. "0.05" or "0.1" can be selected (default is "0.05").
window_width:
Width setting for the app window (default is "1000").
window_height:
Height setting for the app window (default is "600").
itemarea_displines:
The number of lines to be displayed in the "Item Area". Specify the number of lines in units of rows. It is possible to change the display size by dragging the border separately after startup (default value is “5”).
messages:
Sets whether operation completion messages are displayed. "enable" displays them, "disable" suppresses them. Question-type messages are always displayed regardless of this setting (default is "enable").
autosave_json:
Sets whether dictionary files are automatically saved. "enable" checks the "Auto Save dicts." checkbox, and files are overwritten whenever the content or order of Tree View items changes. "disable" unchecks the "Auto Save dicts." checkbox, and automatic overwriting is not performed. This ini file item is automatically changed when you operate the "Auto Save dicts." checkbox in the app (default is "disable").
Note that regardless of this setting, you can always save dictionary files using the "Save dicts." button.
backup_json:
Sets whether to automatically backup dictionary files when the app starts. "enable" renames and copies each dictionary file to the "bk" folder, keeping only one generation. If backup files already exist, they are deleted before new backups are made. "disable" prevents this process (default is "enable").
textfont:
Changes the font for the Tree View and text areas (default is "TkDefaultFont"). "TkDefaultFont" uses the default font specified in tkinter. v1.0.18 and later, the font name can be selected from the drop-down menu.
fontsize_treeview:
Font size for the Tree View (default is "12").
fontsize_textbox:
Font size for text areas (default is "12").
datetime_format:
Specifies the format for adding date and time information to the end of filenames when saving (default is "%%Y%%m%%d_%%H%%M%%S", for example, which would add "20240830_210559" for August 30, 2024, at 21:05:59).
Note that this determines the default naming convention when saving files, but it can be manually modified after saving files.
multiple_boot:
Enables or disables multiple startup. (The default is “disable”).
When this setting is “disable”, an empty file called "app.lock" is created at startup and deleted at exit. The presence or absence of this file is used to check if the application has already been started. Note that this file may remain without being deleted when the application fails to terminate normally due to an unforeseen accident. In this case, delete "app.lock" file manually and then launch the application.
In each text box, characters disappear when you type in single-byte brackets “()” or hyphens “-” with the IME's conversion function.
Solution: Input text without using the IME's conversion function. This may be a problem with the library used in development (as a similar phenomenon has been observed elsewhere). There is a stable workaround for this problem, so there are no plans to address this issue in software at this time.
When moving the cursor with the cursor keys in a text box, the software's behavior may become choppy depending on the amount of text.
In v1.0.31, The application processing has been lightened. If the operation is still slow, please try changing the "Power Options" of Windows (change to "Balanced" or "High performance").