Commit Graph
100 Commits
Author SHA1 Message Date
105b436a66 fix #3199: firefox using cached images instead of new images. (#4743)
* Fixed: https://github.com/SillyTavern/SillyTavern/issues/3199#issue-2745917391

* Wrap header set in isFirefox

* Only invalidate Firefox caches. Also invalidate thumbnail caches.

* Skip `mime.lookup` on non-Firefox browsers.

* Improve param comments

---------

Co-authored-by: user <user@exmaple.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-11-06 20:11:21 +02:00
bmen25124 a728d30c99 Refactor flattenSchema to simplify JSON schema for Google Generative … (#4711)
* Refactor flattenSchema to simplify JSON schema for Google Generative AI API compatibility

* Added unit test and github action

* Add unit tests workflow and update test script in package.json

* Downgrade eslint-plugin-jest to make min node version 18
2025-11-06 00:08:58 +02:00
docfailandCohee dd758161bd Add Full Support for BYAF Archives (#4701)
* + Fix discarding all scenarios aside from the first one, which would cause all chats other than the first one to be lost.
+ Accumulate alternative starting messages from all scenarios, as different scenarios are how Backyard handles having alternative greetings. A scenario with multiple messages in its "firstMessages" array is invalid as per BYAF spec.
+ Return scenarios so that they can be used to populate chats, scenario overrides, and in the future, the other character settings overrides as well.

* + Added support for importing chats (including swipes) from BYAF. This brings the core functionality of BYAF imports mostly in-line with the standard, without the inclusion of any features that are currently missing from ST.
> The only supported feature not yet implemented is scenario overrides per-chat. This will be the the goal of the next commit.

* + Implemented scenario overrides, fully bringing ST's BYAF import as in-line with the BYAF standard as possible without adding new feature functionality to ST.
+ Also added some new chat metadata fields in preparation for example message and system prompt overrides.

* + Added support for pulling alternate icons from the BYAF archive. They are not used yet, but they are safely stored.
+ Added support for pulling backgrounds from the BYAF archive. They are not used yet but they are stored and linked to the chats they originally belonged to.
+ Saved every remaining field that was previously discarded from BYAF that a user actually needs in a way that could be used in the future, and can be accessed by the user if needed after import. Any fields that are not preserved at this point are specfic to either Backyard AI's desktop application, or to the BYAF manifest itself, and therefore have no relevance to a user.
> With this, BYAF import should be fully supported and in-line with the official spec.

* + Updated comments and method names to reflect changes appropriately. First round of touch ups.

* + More comment updates.

* - Removed commented code, that is no longer needed for reference.

* > No longer sanitize for filenames in the character card, as there's no need. The sanitization now happens when generating the filename, which is subsequently used for file operations.
+ Added replacement function for sanitizing filenames which uses visually similar but valid for filenames replacement characters instead of deleting the characters for better data parity.

* + Preserve isNSFW flag as a tag, so it's not lost on import.

* + preserve labels on character alt avatars

* + Deduplicate first messages, so that 5 chats with the same first message don't create 5 identical first messages.

* + Adjusted icon naming logic to produce more sensible results.

* > User path.basename and path.extname for getting the base name and extension of files, respectively.

* > Should use camelCase for local function names.

* > Use a set for greetings instead of explicitly checking for duplicates.

* > Missed a snake case local function name.

* > Updated background import logic to integrate with existing per-chat background system.

* + Updated logic to skip import of chats and backgrounds when a character is being updated/replaced.

* + Added copy of getUniqueName helper function from frontend utils to backend utils.
+ Refactored duplicated logic for getting unique filenames for backgrounds and character alt icons to use the newly available function.

* > fixed adding an extra dot to the filenames for icons after switching to path.extname for getting the extension

* > Updated metadata settings generation in byaf chat so that it doesn't overwrite valid yet 'falsy' values with defaults. Oops

* > Remove variable for configuration that will likely never need to exist.

* > custom_background should be an empty string if chat_background is falsy

* > Make an array empty if chat_background is falsy.

* > Prefer camelCase for local variable names.

* + Added definitions for ByafParseResult and ByafChatBackground.
> Updated overused and unweildy anonymous types to the newly defined types.

* + When importing a character with chats, the character will now no longer open to a new empty chat, but instead will pick the first of the imported chats to open up to.

* Rename prev_paths => paths

* Prettify logs display

* Set fallback chat name if scenario is untitled

* card.data.name => card.name

* Optimize first scenario message access

* + Moved custom replacement function from importFromByaf into util.js as sanitizeSafeCharacterReplacements() so that the replacement logic may be reused anywhere for consistency.

* > Missed a couple. Updated for consistency

* + Preserve character full/display name without it needing to be safe as a filename.
> Change logic for naming the folder the alt images live in to match the logic the sprites endpoint uses to get character sprites for consistency

* > Only add full_name extension if displayName exists.

* full_name => display_name

* - No longer use safe lookalike replacements for filename sanitization to be consistent with how web browsers sanitize invalid characters in filenames before saving to disk.

* Tiny formatting fix

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-10-29 20:06:53 +02:00
bmen25124andCohee cd176039ef Added structured output for common APIs (#4272)
* Added structured output for common APIs

* eslint

* Added frontend impl

* Type name change

* Unprefix json_schema, apply review suggestions

* Add schema to generateQuietPrompt, add comments

* Prettify diff

* Extract JSON from Claude response

* Add structured gen for Mistral

* Hack to support schema for DeepSeek

* Hack JSON schema for AI21

* Add Groq structured gen

* Add JSON mode for pollinations

* Add JSON schema for perplexity

* Add JSON schema for AIML

* Using extractJsonFromData in custom-request, added google rules for flattenSchema

* Fix response parsing

* Fix Google

* Fixed json parse

* Expose generateRaw to getContext

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
2025-07-15 21:54:36 +03:00
Cohee 8d2b9d2dab Secrets manager (#4131)
* Secret manager (now for real)

* Refactor secret manager dialog

* Add error handling to secrets migration

* Adjust default value

* Add secret-id slash command

* Add secret management slash commands

* Improve type definitions

* Improve compatibility of UUID generator

* Add copy buttons to manager view

* Improve compatibility with Vertex AI service account
- Changed to input since textarea can't be used with datalist
- Unblock regular key placeholder
- Save email as a key label
- Interrupt validation if the input is a UUID (autocompleted)

* Add optional label input for secret values in key manager dialog

* Update masking rules

* /secret-id: make the arg "required" (it's not)
2025-06-11 21:26:19 +03:00
InterestingDarkness 358bbf8622 Replace url.origin with trimTrailingSlash (#4118)
* Replace url.origin with trimV1

* Replace url.origin with trimTrailingSlash
2025-06-08 19:09:15 +03:00
Cohee 3ec9b1a099 Implement data clean-up dialog (#4072)
* [wip] Add user data cleanup service

* Add clean-up report viewer

* Fix review comments

* Add function comments

* Implement item actions

* Fix UI styles

* Add placeholder for empty results, update category description view

* Add displayEmptyPlaceholder method to show message when results list is empty

* Adjust menu buttons row

* Delete char-scoped data bank attachments on character deletion

* Data Bank: Handle character attachments on rename

* Remove line breaks in description strings

* Drop the category when the last item is deleted

* Skip invalid hashes instead of bailing
2025-06-01 13:56:34 +03:00
Cohee c218c1baea ZIP extraction error handling (#4002)
* Improve error handling in extractFileFromZipBuffer function

* Add warning logging to NovelAI image upscaling
2025-05-16 19:57:33 +03:00
Cohee 62b02bec3f Merge pull request #3940 from wickedcode01/bug-fixed
Fix the issue where deleting files on Windows may cause the application to crash.
2025-05-01 17:00:11 +03:00
wickedcode d3bb625efe fix: recommend to use unlinkSync instead of rmSync, which has a better compatibility handling non-English characters 2025-05-01 03:09:25 -04:00
Cohee 31cc05ae46 Move setPermissionsSync to util 2025-04-27 18:23:57 +03:00
Cohee 005a495e96 Move config migration from post-install to src 2025-04-25 22:22:44 +03:00
Cohee d97aa0a270 CONFIG_FILE => CONFIG_PATH 2025-04-23 20:46:36 +03:00
wrvsrx 26a520af10 Support specifing config.yaml in cli 2025-04-23 11:18:30 +08:00
wrvsrx bf97686dfc Allow read-only installation
Fix #3453.

Thanks to #3499, #3500 and #3521, most of the obstacles to read-only installation have been resolved. This PR addresses the final piece, ensuring that SillyTavern no longer changes directories to `serverDirectory` and outputs files there. Instead, it outputs or copies necessary files to the directory where it is being run. Now, `serverDirectory` is read-only for SillyTavern (i.e., SillyTavern will not attempt to modify `serverDirectory`). Additionally, this PR sets the permissions for copied `default-user` files to be writable, so even if SillyTavern is installed as read-only, the copied `default-user` folder can still be modified.
2025-04-16 09:52:08 +08:00
Cohee 76c59cbc52 Unset chat field on import/export
Closes #3781
2025-04-02 22:08:20 +03:00
Cohee 28bad6479c Use human-readable memory cache capacity in config 2025-03-05 00:45:34 +02:00
Cohee 868e97804a Use chalk lib for console colorization 2025-03-01 00:56:50 +02:00
Cohee 02ab882e63 Fix deno startup 2025-02-26 20:53:17 +02:00
Cohee 68eecc77bb Refactor IP interface query 2025-02-26 15:44:39 +00:00
Cohee e7fcd0072b Refactor server startup 2025-02-26 14:46:54 +00:00
Cohee acd8b817f4 Improve number type conversion in getConfigValue to handle NaN cases 2025-02-26 00:08:04 +02:00
Cohee 0776f65193 Allow JSON array and objects in env.var configs 2025-02-25 22:20:17 +02:00
Cohee a73dfa7586 Merge branch 'staging' into immutable-config 2025-02-22 20:15:13 +02:00
Cohee a2ecb81378 Move minLogLevel to logging section 2025-02-22 13:58:08 +02:00
Cohee 73784642d2 Save setConfigValue export 2025-02-20 22:31:23 +02:00
Cohee 2b28065c9f Fix setting protocols with env 2025-02-20 22:28:30 +02:00
Cohee 3f03936125 Add config value type converters for numbers and booleans 2025-02-20 21:53:48 +02:00
Cohee f6fe5fea77 Allow overriding config.yaml values with env vars
Closes #3520
2025-02-20 20:29:42 +02:00
Cohee 7ea2c5f8cf Move cookie secret to data root. Make config.yaml immutable 2025-02-20 20:16:44 +02:00
Cohee 363d8a4121 Merge branch 'staging' into ipv6_auto 2025-02-04 22:45:46 +02:00
Cohee 0c8a11e28b Further loglevel updates
1. Fix missed endpoints
2. Exclude console.log from loglevel
2025-02-02 15:40:37 +02:00
Eradev 055a6527fc PR fixes 2025-02-02 03:10:32 -05:00
Eradev 552a418bae Merge branch 'staging' into staging-3071-v2 2025-01-28 10:49:53 -05:00
Spappz 6099ffece1 No exceptions on missing error webpages
- Create a `safeReadFileSync()` function in `src/utils.js` to wrap around `fs.readFileSync()`
- Migrate error-webpage loads to use `safeReadFileSync()`, with default values of an empty string
- Move the 404 error middleware to explicitly only be called *after* extensions are registered
2025-01-25 20:29:31 +00:00
Eradev 1f9fa74786 Rewritten minLogLevel feature 2025-01-15 10:02:32 -05:00
BPplays f372e1a69d more jsdoc stuff 2025-01-09 19:09:55 -08:00
BPplays b43ac187ec formatting changes 2025-01-09 18:27:21 -08:00
BPplays adc5940d15 formatting changes 2025-01-09 18:17:02 -08:00
Cohee 9db9c5c9ca Reorganize backup configs 2025-01-05 16:03:52 +02:00
Cohee 0e3ff1699a Merge pull request #3226 from BPplays/ipv6_auto
Automatically detect what IP versions are available and use them
2025-01-04 16:22:53 +02:00
Cohee 97f6dcace0 Fix types for extractFileFromZipBuffer 2025-01-03 00:16:14 +02:00
BPplays f27b3361e5 lint 2024-12-30 03:01:04 -08:00
BPplays f67abf9e03 improved urlHostnameToIPv6 2024-12-30 02:59:41 -08:00
BPplays 7744be3319 commited util 2024-12-29 04:20:59 -08:00
BPplays 07cff878e5 commited util 2024-12-29 04:20:39 -08:00
Cohee 5c82ccf435 Refactor endpoints/chats.js
1. Move formatBytes utility to util.js
2. Fix type error related to dates sorting
3. Add type to backupFunctions map
2024-12-12 14:07:37 +02:00
Cohee 3849908fe1 Add maxTotalChatBackups config.yaml value 2024-12-07 15:37:57 +02:00
Cohee 373a0ad321 Add config.yaml value for cards cache capacity. 2024-12-05 12:59:03 +00:00
Cohee 095d19cda7 Rename LimitedMap => MemoryLimitedMap 2024-11-29 12:33:48 +00:00