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
2024-12-25 22:27:48 +09:00
2023-05-07 12:41:45 +09:00
2024-09-06 02:45:49 +09:00
2023-07-07 06:30:04 +09:00
2025-03-16 19:41:06 +09:00
2024-01-01 23:14:58 +09:00
2025-04-11 17:29:42 +09:00
2025-04-13 00:33:21 +09:00
2024-10-13 01:29:12 +09:00
2025-03-10 13:14:20 +09:00
2023-07-08 15:24:18 +09:00
2024-01-01 23:14:58 +09:00
2025-02-26 22:26:15 +09:00
2024-09-10 22:09:58 +09:00
2023-05-07 12:41:45 +09:00
2024-10-13 01:46:57 +09:00
2025-03-20 12:08:34 +09:00
2025-02-15 21:29:37 +09:00
2024-10-25 18:11:00 +09:00
2023-05-07 12:41:45 +09:00
2025-04-13 00:33:21 +09:00

RisuAI

text

Svelte Typescript Tauri

RisuAI, or Risu for short, is a cross platform AI chatting software / web application with powerful features such as multiple API support, assets in the chat, regex functions and much more.

Screenshots

Screenshot 1 Screenshot 2
Screenshot 1 Screenshot 2
Screenshot 3 Screenshot 4

Features

  • Multiple API Supports: Supports OAI, Claude, Ooba, OpenRouter... and More!
  • Emotion Images: Display the image of the current character, according to his/her expressions!
  • Group Chats: Multiple characters in one chat.
  • Plugins: Add your features and providers, and simply share.
  • Regex Script: Modify model's output by regex, to make a custom GUI and others
  • Powerful Translators: Automatically translate the input/output, so you can roleplay without knowing model's language.
  • Lorebook: Also known as world infos or memory book, which can make character memorize more.
  • Themes: Choose it from 3 themes, Classic, WaifuLike, WaifuCut.
  • Powerful Prompting: Change the prompting order easily, Impersonate inside prompts, Use conditions, variables... and more!
  • Customizable, Friendly UI: Great Accessibility and mobile friendly
  • TTS: Use TTS to make the output text into voice.
  • Additonal Assets: Embed your images, audios and videos to bot, and make it display at chat or background!
  • And More!

You can get detailed information on https://github.com/kwaroran/RisuAI/wiki (Work in Progress)

Discord

Installation

Docker Installation

You can also run RisuAI using Docker. This method is particularly useful for web hosting.

  1. Clone the repository:

    git clone https://github.com/kwaroran/RisuAI.git
    cd RisuAI
    
  2. Build and run the Docker container:

    docker-compose up -d
    
  3. Access RisuAI at http://localhost:6001 in your web browser.

Description
No description provided
Readme 62 MiB
Languages
TypeScript 58.9%
Svelte 35.1%
JavaScript 4.4%
Rust 0.5%
Lua 0.3%
Other 0.7%