Commit Graph

3563 Commits

Author SHA1 Message Date
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
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
kwaroran
0432ee7464 Add support for NovelAI V4 model and configuration settings (#816)
# 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
Add and enable temporary settings for NovelAI V4 models.
Character-specific prompt settings have been temporarily forcibly added,
so modifications are needed to allow custom prompt values to be input
later.
NovelAI V4 모델 추가.
캐릭터별 프롬프트는 임시추가 했기때문에 추후 커스텀 설정 할 수 있도록 변경해야함.
2025-04-14 14:05:56 +09:00
YH_KIM
517b2ff86b Update placeholder text for image model selection 2025-04-14 04:49:13 +09:00
YH_KIM
d11bff3f80 Add support for NAI v4 model configuration and inputs 2025-04-14 04:38:47 +09:00
kwaroran
7859e649d3 Merge branch 'main' of https://github.com/kwaroran/RisuAI 2025-04-13 00:34:01 +09:00
kwaroran
111a347c9e Update Ann 2025-04-13 00:33:21 +09:00
YH_KIM
834e1b7a2e Merge remote-tracking branch 'origin/main' 2025-04-12 23:34:20 +09:00
kyh11199
c37b6f612e Merge pull request #1 from kwaroran/main
merge
2025-04-12 23:32:07 +09:00
YH_KIM
668b8d171c Add support for NovelAI V4 model and configuration settings 2025-04-12 23:29:45 +09:00
shirosaki-hana
e2ae651557 Update server.cjs 2025-04-11 17:29:42 +09:00
shirosaki-hana
c1d4b4daa3 Fix: Resolve Realm CORS Violation for Node.js Hosted Version
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-10 17:16:21 +09:00
bangonicdd
2d50935079 fix: makes more concise by removing one-used var 2025-04-09 18:09:02 +09:00
bangonicdd
dc753adf1f fix: Lua factory init failure under concurrent display editing 2025-04-09 01:45:06 +09:00
kwaroran
d91dd1b825 Add HTTPS support for RisuAI Node.js hosting version (#795)
# PR Checklist
- [] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
   - N/A
- [] 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?
   - node hosted version only
- [] Have you added type definitions?
   - N/A

# Description
The Node.js hosting version of RisuAI previously used simple app.listen
for server execution, which didn't support native HTTPS. This caused
several functionality issues due to browser security restrictions when
accessing RisuAI externally, such as realm loading failures and
inability to insert prompt presets.

The updated code now checks for certificate files named server.key and
server.crt in the /server/node/ssl/certificate directory. If found, the
server will start using HTTPS.

The /ssl directory includes a script to generate a self-signed SSL
certificate using OpenSSL. To use it, add the server's public IP to the
[ alt_names ] section in server.conf before generating the certificate.
The CA certificate should be installed on the operating system or
browser of devices remotely accessing RisuAI.
2025-04-08 19:22:06 +09:00
kwaroran
f5abdad334 Add fixed chat textarea option to AccessibilitySettings (#809)
# 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 pull request introduces the following changes:
- Adds a new "fixedChatTextarea" option to control the positioning of
the chat window text area.
- Modifies Shift+Enter functionality to align with updated input
handling requirements.

To be honest, I'm not entirely sure if this approach is correct. Since
I've developed with React and Next.js, I'm still a beginner when it
comes to Vite. But as a PC user, I think this method will be convenient
to use.
2025-04-08 19:20:37 +09:00
kwaroran
b11b400aaa feat: Lua trigger getGlobal(Chat)Var (#810)
# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [x] 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
Allow usage of {{getglobalvar::}} equivalent in Lua trigger script

Further on, setting the global variable is the next scope to be
implemented.
2025-04-08 19:20:26 +09:00
Inha Hwang
c21dd9e755 fix: wrong type 2025-04-08 06:02:07 +09:00
Inha Hwang
31a480643b feat: luascript getGlobal(Chat)Var support
setGlobal(Chat)Var needs to be studied too.
2025-04-08 06:01:12 +09:00
YH_KIM
4c47480b7e Add fixed chat textarea option to AccessibilitySettings
Additionally, change 'send to center' to 'send to shift center'
2025-04-06 16:37:29 +09:00
Bo26fhmC5M
e8b93dba41 fix: handle similarity search error in HypaV3 2025-04-05 17:01:19 +09:00
Bo26fhmC5M
cf48e56082 fix: check empty summarization result in HypaV3 2025-04-05 16:24:16 +09:00
bangonicdd
2f425b7084 fix: code readability slightly 2025-04-05 05:38:41 +09:00
bangonicdd
20e3e9297d fix: change cache timing after lua trigger 2025-04-05 04:59:46 +09:00
sub-hub
a32e670108 reduce max tokenize cache size 2025-04-03 12:17:01 +09:00
bangonicdd
1867ea473d fix: increase regex cache size 2025-04-03 11:52:50 +09:00
sub-hub
99efcc5f23 Remove md5 function from getHash 2025-04-03 10:28:40 +09:00
sub-hub
4df80bf98b remove log for check caching 2025-04-02 22:34:22 +09:00
sub-hub
c553478a78 Refactor: caching tokenize result 2025-04-02 22:01:01 +09:00
kwaroran
ea570787c2 fix: 'previous_chat_log' cbs (#801)
# 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
It appears that the `previous_chat_log` cbs currently behaves
differently than described in the documentation.

Thank you for your time.
2025-04-02 21:24:41 +09:00
bangonicdd
df4f83eaa7 refactor: regex caching 2025-04-02 14:30:23 +09:00
bangonicdd
72e47afb49 fix: add null check on module integration for legacy preset 2025-04-02 02:45:51 +09:00
bangonicdd
88fd4ffaeb fix: 'previous_chat_log' cbs 2025-04-01 13:10:04 +09:00
kwaroran
9e00c9b17a Add gettokens API 2025-03-27 19:21:31 +09:00
kwaroran
58f1cb4fcc Add tokenize trigger 2025-03-27 19:19:59 +09:00
kwaroran
02401d4d09 Add igp prompt 2025-03-27 19:13:10 +09:00
kwaroran
294b0e2a52 Add 2.5 pro 0325 2025-03-26 20:53:16 +09:00
kwaroran
6020a92725 Bump version to 158.2.0 in configuration and related files 2025-03-26 20:49:13 +09:00
kwaroran
1b3b0e14d6 Add gemini 2.5 exp 2025-03-26 20:46:34 +09:00