Commit Graph

3600 Commits

Author SHA1 Message Date
kwaroran
aef8a75f76 Add nai cfg_rescale, noise_schedule options settings (#835)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions? -
I've checked web version only.
- [x] Have you added type definitions?

# Description

Added the ability to configure the `cfg_rescale` and `noise_schedule`
properties in the NovelAI settings.

# Example


![image](https://github.com/user-attachments/assets/437984aa-7612-4a38-9d34-311faf20ced4)
2025-04-28 15:43:41 +09:00
kwaroran
02b9050666 feat: add option to show Hypa modal button in chat menu (#823)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Preview

![preview1](https://github.com/user-attachments/assets/daaafcb2-a533-4bf1-b38f-e9b9b54f6769)


![preview2](https://github.com/user-attachments/assets/a632a66d-fc74-4d92-909a-88d450cd41fb)

# Description
This PR introduces following:
- feat: add accessibility setting to control visibility of Hypa V2/V3
modal button in chat menu
- feat: add summarization condition tip to HypaV3 modal
2025-04-28 15:43:06 +09:00
kwaroran
9fc92e50ae Fix: Avoid flatMap crash when output.images is undefined (#827)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Description
In some ComfyUI workflows, output.images is often undefined when
intermediate outputs from text-based nodes are included and cannot be
suppressed in the response.
2025-04-28 15:42:54 +09:00
kwaroran
2c3ddd64e0 feat: module lorebook sort, import, export (#822)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [x] Have you added type definitions?

# Description
This PR adds sorting, import, and export functionality to the Module
Lorebook list.

I focused on preserving the existing code structure as much as possible
while implementing these changes.

Thank you for your time and review!
2025-04-28 15:42:40 +09:00
kwaroran
eb690750a7 Add: Caching tokenize (#826)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Description
Previous PR #805 had a bug due to incorrect flow of if statements. I
apologize for this.
In this PR, I have improved the flow of if statement additionally from
the modification I made before.
Please refer [Fix: Correct tokenize flow in tokenizer encode
function](09228f3f86)
To see the how I changed the flow.

The biggest change of this commit is that it resolves the issue of
duplicate tokenization that was occurring
By add a `Line 122: if (result === undefined) {`
I think this change corrected the error even if people didn't turn on
the caching option.

And there is an error in the tikJS function, independent of this wrong
flow.
https://github.com/dqbd/tiktoken/issues/35
2025-04-28 15:42:19 +09:00
kwaroran
83b8e6b28e feat: add persona sort (#821)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [x] Have you added type definitions?

# Description
This PR introduces the persona sorting feature.

**Changes:**

1. Uses the `sortable` library, consistent with other sorting
functionalities.
2. To prevent desynchronization between the selected persona and the UI
value during sorting:
    *   `OnStart`: Saves the currently selected persona.
* `OnEnd`: Switches selection to the first persona without saving the
initial selection.

I believe I've tested this sufficiently, but please feel free to point
out any potential issues or edge cases I might have missed.

Thank you for your time and review!
2025-04-28 15:41:53 +09:00
kwaroran
42ea3abcfd Fix: Resolve account login issues in Node.js hosted version (#820)
# PR Checklist
-  Have you checked if it works normally in all models? *Ignore this if
it doesn't use models.*
   - Not applicable
-  Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
   - Done
-  Have you added type definitions?
   - Not applicable

# Description

In the previous commit, a new proxy endpoint was added to the backend to
resolve CORS errors that occurred when the frontend directly fetched
data from Risu Realm.

However, 403 errors were occurring because the POST requests sent from
the loadRisuAccountData() function in the frontend were not being
properly processed.
Additionally, the backend was inefficiently handling complex body
processing.

The updated backend code now provides a more efficient and stable
solution by directly piping the original request.

Furthermore, an issue where UserSettings.svelte couldn't handle tokens
received through the backend proxy after successfully logging into a
Risu account has also been fixed.
2025-04-28 15:41:26 +09:00
kwaroran
d86320d1bb Fix: Issue with Lorebook prompt prefix/suffix affecting matching (#819)
# PR Checklist
- [x] Have you added type definitions?

# Description
This PR aims to address the following issues:

* Fixed problems where prefixes and suffixes in the Lorebook prompt were
affecting keyword matching logic.
1. In full word matching, the first and last words of the body text
would consistently fail to match.
2. In general matching, using a persona name as a keyword would always
result in a match, regardless of context.
* I tried to preserve the original code structure as much as possible
while implementing these fixes. Please feel free to suggest changes to
the approach if you see a better way.

Thank you for your time and review.
2025-04-28 15:40:11 +09:00
niceandneat
a899a02d30 Add nai cfg_rescale, noise_schedule options settings 2025-04-28 01:21:10 +09:00
shirosaki-hana
a9e5e98603 Merge branch 'kwaroran:main' into DebugHubProxy 2025-04-24 13:07:16 +09:00
kwaroran
39048dd142 Add dice CBS 2025-04-23 12:44:32 +09:00
kwaroran
89257b2ed4 Accept cbr,cnl,cnewline without params 2025-04-23 12:41:48 +09:00
kwaroran
59fdcc20b3 Add randint and cbr, cnl, cnewline 2025-04-23 12:40:38 +09:00
kwaroran
2ca28aff78 Add u escape 2025-04-23 12:37:40 +09:00
kwaroran
e443eadb12 Add code cbs 2025-04-23 12:36:34 +09:00
kwaroran
e029456f01 Fix comment 2025-04-23 12:29:45 +09:00
kwaroran
91e3a352a3 Change download to blob 2025-04-23 12:26:27 +09:00
shirosaki-hana
6bce5cb456 Merge branch 'kwaroran:main' into DebugHubProxy 2025-04-23 08:58:23 +09:00
TiamaTiramisu
0f70c5404a fix: avoid flatMap crash when output.images is undefined 2025-04-21 17:57:46 +09:00
sub-hub
2a36743cb6 Fix: Potential problem in tikJS function 2025-04-21 14:57:19 +09:00
sub-hub
09228f3f86 Fix: Correct tokenize flow in tokenizer encode function 2025-04-21 13:34:01 +09:00
sub-hub
33d8ed4568 restore tokenizer caching with old-bug version 2025-04-21 13:27:43 +09:00
Bo26fhmC5M
acd0692029 Merge branch 'main' into patch-7 2025-04-21 11:47:38 +09:00
kwaroran
22a50904f8 Revert #805 due to tokenizing error 2025-04-21 05:27:05 +09:00
kwaroran
51798704e1 Revert "Revert "refactor: regex caching"" (#825)
Reverts kwaroran/RisuAI#824
2025-04-21 05:24:55 +09:00
kwaroran
8ef2a991fc Revert "Revert "refactor: regex caching"" 2025-04-21 05:24:46 +09:00
kwaroran
ee8ece5c42 Revert "refactor: regex caching" (#824)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Description
2025-04-21 05:24:11 +09:00
kwaroran
5120c14154 Bump version to 159.0.0 in configuration and related files 2025-04-21 02:02:52 +09:00
Bo26fhmC5M
4703bd463b feat: add option to show Hypa modal button in chat menu
- feat: add accessibility setting to control visibility of Hypa V2/V3 modal button in chat menu
- feat: add summarization condition tip to HypaV3 modal
2025-04-20 14:57:45 +09:00
bangonicdd
5f1d63dcfb feat: module lorebook sort, import, export 2025-04-19 17:00:18 +09:00
bangonicdd
a7aebab65c fix: preserve selected persona after sorting 2025-04-19 15:34:52 +09:00
bangonicdd
9af38ced76 feat: add persona sort 2025-04-19 12:01:53 +09:00
shirosaki-hana
1b62dc95ed Add duplex 2025-04-18 13:18:37 +09:00
shirosaki-hana
5168565b4f Update : server.cjs 2025-04-17 17:31:46 +09:00
shirosaki-hana
e0038749a4 Fix: Resolve account login issues in Node.js hosted version
In a previous commit, a new proxy endpoint was added to the backend to resolve CORS errors that occurred when the frontend directly fetched data from Risu Realm.

However, the proxy endpoint handler failed to properly process POST requests, causing account login failures. Additionally, the backend was inefficiently performing complex body processing.

The updated code now directly pipes the original request, providing a more efficient and reliable solution.
2025-04-17 13:14:12 +09:00
bangonicdd
bccb4a78ec fix: lorebook matches excluding dummy prefix/suffix 2025-04-17 11:43:06 +09:00
kwaroran
040652d618 Add requestTokenParts structure to manage token parts in chat requests 2025-04-16 11:14:13 +09:00
kwaroran
ed992407a7 Fix import var 2025-04-16 11:04:54 +09:00
kwaroran
36e0935bb0 Make tokenizer caching to an option 2025-04-16 10:57:48 +09:00
kwaroran
21561fe5ff Support multiple named assets 2025-04-14 17:14:33 +09:00
kwaroran
cf039b86af Add error handling for colorscheme 2025-04-14 16:17:09 +09:00
kwaroran
46c45238e5 remove style limits 2025-04-14 16:14:50 +09:00
kwaroran
ce24497bad fix v2StopPromptSending 2025-04-14 15:36:59 +09:00
kwaroran
35f0f8e1dc Add tests && add img lazy async 2025-04-14 15:28:14 +09:00
kwaroran
9016b506d9 Revert "refactor: regex caching" 2025-04-14 14:24:55 +09:00
kwaroran
666e1f71b0 refactor: regex caching (#803)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Description

### Since this PR affects both editRequest mode and editDisplay mode, I
recommend reviewing #812 first for context.

This PR aims to:

1. Fix an issue where the current regex caching is incompatible with
modules.
2. Slightly modify the hashing structure to handle non-deterministic
regex with cbs. Verified that this correctly handles expressions like
`{{#if A}}`.

Thanks for your time.
2025-04-14 14:12:22 +09:00
kwaroran
c7db37664e fix: Lua factory init failure under concurrent display editing (#812)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [x] Have you added type definitions?

# Description
This PR addresses an issue where `luaFactory` fails to initialize
correctly in 'editDisplay' mode under specific conditions.

## Problem Reproduction:
The initialization failure can be reliably reproduced under the
following conditions:
1. Disable all modules.
2. Select any chatbot with 'editDisplay' in trigger lua.
3. Select or make chat with length of 2 or more.
4. Restart app and revisit the chatbot

## Changes:
1. Guaranteed `luaFactory` initialization completes successfully during
concurrent calls.
2. Added `Promise Map` to ensure only one Lua engine instance is created
per mode, preventing redundant initializations.
3. Moved variable updates within mutex scope to prevent potential issues
during concurrent operations.
4.  Resolved merge conflicts with another PR. During the resolution:
* Removed logic related to caching or updating methods for Global Vars.
* **Reasoning:** Since Global Vars are stored directly in the database
and are not chat-specific, I believe caching/updating these methods to
be unnecessary, so I've simply made it calls exported one directly
without frequently re-cache itself.
* **Verification:** Re-validated that this change does not negatively
impact functionality.
* **Note:** Please let me know if anyone has concerns about this
approach to conflict resolution.
2025-04-14 14:12:03 +09:00
kwaroran
cf22306c8c Refactor: Caching tokenize result (#805)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Improved performance

![image](https://github.com/user-attachments/assets/c7fa773f-afbb-4eb6-ac24-35c8451be33d)
The picture above was taken when I sent a chat.
As you can see, the encode function occupies **0.68 seconds** out of 1.8
seconds.
This is **36.5%** of sending time

![image](https://github.com/user-attachments/assets/cd2c4bde-556e-4151-82a9-030d27f2872a)
This is a picture taken after adding a caching function.
encode time Reduced from **0.68 seconds to 0.12 seconds, an improvement
of 27.2%**

Since configuration values are also used as key values in the hash
function,
it is guaranteed that **different results will be produced when the
configuration changes**.
I tested this myself by changing the bot settings

# Implementation
I added the `mnemonist` library to implement this. At first, I used
lru-cache, but that library recommended using this one if performance is
important.
It actually performed better too.

# Integrity Check

![image](https://github.com/user-attachments/assets/ae1272a8-ea95-47ef-85f5-c22dd9f34be7)
Lastly,
the encoding result calculated without caching when sending the first
chat,
the newly calculated value when sending the second chat, and
the result cached when sending the first chat were all the same.
2025-04-14 14:10:24 +09:00
kwaroran
947738046c fix: improve error handling in HypaV3 (#808)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Description
This PR introduces following:
- fix: check empty summarization result in HypaV3
- fix: handle similarity search error in HypaV3
2025-04-14 14:07:25 +09:00
kwaroran
b1dfd9706e Fix: Resolve Realm CORS Violation for Node.js Hosted Version (#814)
# PR Checklist
- [] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
   - Not applicable
- [] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
   - Done
- [] Have you added type definitions?
   - Not applicable

# Description
## Problem
The Node.js hosted version of RisuAI encountered an issue where it
failed to fetch data from the Risu Realm server when accessed remotely.

RisuAI's frontend directly fetches data from the Realm server (e.g.,
sv.risuai.xyz). While the official web version did not exhibit CORS
errors (potentially due to same-origin deployment or specific
server-side CORS configurations), running the Node.js version on a
self-hosted server and accessing it remotely resulted in browser CORS
policy violations.

## Solution
The fix involves detecting when the frontend runs in the Node.js host
environment.

When this environment is detected, instead of requesting Realm data
directly from the external server (sv.risuai.xyz), the frontend now
directs the request to a new proxy endpoint (`/hub-proxy/*`) on its own
backend server.

The backend proxy then fetches the required data (including JSON and
images) from the actual Realm server, correctly handles content types
and compression, and relays the response back to the frontend.

This ensures that, from the browser's perspective, the frontend is
communicating with its same-origin backend, effectively bypassing
browser CORS restrictions and resolving the data fetching issue.
2025-04-14 14:07:10 +09:00