Commit Graph

3195 Commits

Author SHA1 Message Date
Kwaroran
2ec13a4550 Modify some parts of PR 2025-01-06 00:30:33 +09:00
Kwaroran
c0e1311568 Add branches 2025-01-06 00:24:03 +09:00
kwaroran
aacb60eed9 fix: HypaV2 serialization and token calculation (#701)
# PR Checklist
- [x] 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
This PR addresses two issues in HypaV2:

1. Fixes JSON serialization of chatMemos in HypaV2Data by converting Set
to string array
2. Corrects token calculation by subtracting tokens from previously
summarized chats

Changes:
- Added SerializableHypaV2Data interface with string[] instead of
Set<string>
- Added conversion functions between HypaV2Data and
SerializableHypaV2Data
- Fixed token calculation by properly accounting for removed chats

Note:
I'm not entirely confident about the token calculation changes. A
thorough review would be appreciated, particularly regarding:
- Whether token subtraction for removed chats is the correct approach
- Potential edge cases in the current implementation 

Please review these changes, especially the token calculation logic, to
ensure it aligns with the intended behavior of the memory system.
2025-01-06 00:11:03 +09:00
kwaroran
7d1e9dc9bd feat: add prompt comparison feature (#704)
# 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
This PR adds a **prompt comparison feature** to the prompt preset
interface. Now, users can compare two different prompts to identify
differences.

## How to Use
1. Open the prompt preset window.
2. Click the diff button (next to the copy button) for the first prompt
to use as the baseline. The button will turn green, indicating
selection.
<img width="487" alt="c"
src="https://github.com/user-attachments/assets/c2dcf5fa-c4ee-4b3f-8e52-3f0866b12bc4"
/>

3. Click the diff button for the second prompt to compare against the
baseline. A diff view will appear.
4. Clicking the same diff button twice will clear the selection.

## Diff Display Details
- Line-level comparison
- Modified lines: blue vertical line.
- Deleted content: red text on red background with red vertical line.
- Added content: green text on light green background with green
vertical line.

<img width="597" alt="b"
src="https://github.com/user-attachments/assets/0d026e9e-a7a0-4a17-9b80-a2b57c74d7f9"
/>


- If the prompt content is identical, the following message will be
displayed at the top

<img width="600" alt="a"
src="https://github.com/user-attachments/assets/dd5f36f2-9e96-4279-9f9f-79a17f9e4c89"
/>


## Implementation Details
1. `handleDiffMode` manages prompt selection and clearing.
2. `checkDiff` compares prompts and uses `highlightChanges` to mark
differences.
3. Special characters are escaped with `escapeHtml` to ensure the text
is displayed as-is.
4. `resultHtml` is rendered via `alertMd`.

## Notes
- This feature uses the `jsdiff` library to compare prompts efficiently.
- The comparison includes the role, type1, and type2 fields (e.g., ##
system; plain; main). Even if the prompts' text is identical,
differences in these fields will be treated as a mismatch.
- The rendering process in `alertMd` appears to sanitize potentially
dangerous content. However, additional escaping is applied to ensure
that the text is displayed as-is.
- `botpreset.svelte` grew significantly due to this feature;
modularization was considered but not implemented.
- The reason for using the "Prompt Preset" window instead of the "Prompt
Preview" feature is that "Prompt Preview" displays the final form with
CBS processing applied. Even if the content in "Prompt Preview" appears
identical, the actual prompts can differ significantly.

If this feature, its implementation, or any other issue doesn't fit the
project's vision, feel free to reject this PR! Thank you for reviewing!
2025-01-06 00:10:51 +09:00
kwaroran
5c8adcb288 fix: replace unsupported Hrkt unicode property to Hira and Kana (#705)
# PR Checklist
- [x] 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?
- [ ] Have you added type definitions?

# Description
`Auto Regenerate On Characterset` feature can throw the following error
when `Hrkt` is enabled:
```
Error while parsing chat message: true, Invalid regular expression: /\p{Script=Hrkt}/gu: Invalid property name
```

This PR fixes regex parsing issues with unicode property:
1. Replaces unsupported `Hrkt` property with separate `Hira` and `Kana`
properties
2. Updates preview text for each property to match the changes
2025-01-06 00:10:35 +09:00
Bo26fhmC5M
bb93e04961 fix: replace unsupported Hrkt unicode property to Hira and Kana 2025-01-05 19:32:31 +09:00
poroyo
495163c9cf style: improve readability for added and removed lines with border-left 2025-01-05 16:11:00 +09:00
poroyo
8ba4417065 feat: add prompt comparison feature 2025-01-05 14:20:20 +09:00
kwaroran
bf8bf02e2f fix: backup size limit (#702)
## Issue track
Previously, the backup loading was depending on ArrayBuffer. In chromium
based browsers, ArrayBuffer's size is limited to 2GB, and anything more
will fail to read the data.

This affects Tauri too, as Tauri uses Edge webview2 which also is based
on chromium.

The proposed change uses file stream instead of ArrayBuffer, effectively
ignoring forced file size limit of 2GB.

# 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?
- [ ] Have you added type definitions?

# Description
Have to revise, if possible. But really didn't changed that much logic
and since it is only a typescript file change, it will work on most
cases.

Worked on node hosted chrome environment with 2.25GB of binary backup
file.
2025-01-03 18:58:26 +09:00
LightningHyperBlaze45654
48b377b1ad fix: backup size limit
## Issue track
Previously, the backup loading was depending on ArrayBuffer. In chromium based browsers, ArrayBuffer's size is limited to 2GB, and anything more will fail to read the data.

This affects Tauri too, as Tauri uses Edge webview2 which also is based on chromium.

The proposed change uses file stream instead of ArrayBuffer, effectively ignoring file size limit/
2025-01-02 11:52:32 -08:00
Bo26fhmC5M
0317a941f1 fix: token calculation for HypaV2 2025-01-02 20:52:37 +09:00
Bo26fhmC5M
2b92582df4 fix: resolve chatMemos serialization issue in HypaV2Data 2025-01-02 18:47:16 +09:00
Kwaroran
821ba1812f Merge branch 'main' of https://github.com/kwaroran/RisuAI 2025-01-02 03:03:03 +09:00
Kwaroran
866996ba1e chore: update version to 145.3.0 2025-01-02 03:02:54 +09:00
kwaroran
e97715843b Add Custom Character Folder Image Feature Using Global Module Assets (#697)
# 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
This PR adds a new feature that allows users to add custom images to
character folders. Instead of uploading images directly, this feature
utilizes the existing image pool from **the global module**. Users can
either select from existing images in the global module or upload new
images to the module.

The users can use a context menu on a folder to update its image.

## Why Use the Global Module?

The global module was chosen for several reasons:  
1. It allows the reuse of existing functions and code, minimizing the
need for new implementations.
2. Users can easily select existing images without re-uploading them.  
3. The global module provides reliable support for image upload and
deletion.
4. Images uploaded via the global module are accessible across all
platforms where the shared data is available.

## Note

To retrieve the list of assets from the global module, I used the
following code:

```typescript
let assetPaths: { [key: string]: { path: string } } = {};

const moduleAssets = getModuleAssets();
if (moduleAssets.length > 0) {
  for (const asset of moduleAssets) {
    const assetPath = await getFileSrc(asset[1]);
    assetPaths[asset[0].toLocaleLowerCase()] = {
      path: assetPath,
    };
  }
}
```

I reused the `parseAdditionalAssets` code from
`/src/ts/parser.svelte.ts` because it seemed simple and practical for
this feature. I thought about refactoring it into a shared function but
decided to keep it simple for now. I’m not sure if this is the best
approach, but it can always be changed later if needed.

---

If you are already working on a similar feature, find any issues with
this code, or feel this PR does not align with the project's direction,
I fully understand if this PR is not accepted.

Thank you!

---

One last note: With *transparent background images* and the existing
folder color functionality, users can differentiate categories even when
using the same image by applying different colors!
2025-01-02 02:56:49 +09:00
kwaroran
0c5aab06f7 Fix: Token counting fix (#699)
# 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

Emergency fix of PR #680, #696 


Source of problem: Every time when a chat is sent with HypaV2 active, it
always appended HypaAllocatedToken amount of tokens to the
currentTokens.

This did not get subtracted at the end, even though this is nothing more
than a virtual limit like the output tokens.
2025-01-02 02:56:10 +09:00
LightningHyperBlaze45654
d2042116aa Fix: Token counting fix 2024-12-31 21:52:13 -08:00
poroyo
2730e40b3b Refactor char folder image upload process to use direct upload method 2024-12-30 07:31:40 +09:00
poroyo
b83cb444b9 Add functionality to update char folder images 2024-12-29 07:28:04 +09:00
Kwaroran
b80f15f885 chore: update version to 145.2.0 in configuration files 2024-12-29 04:04:25 +09:00
Kwaroran
cd092a5a01 feat: add translation feature and ban character set functionality 2024-12-29 04:03:21 +09:00
kwaroran
03acfdc306 Bugfix on hypaV2 (#696)
# 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
When chat imported from json, it breaks
Fixed by changing the list back to set

Need to check if there is any bug on token counting(unknown issue, so
currently re-calculating the token accurately)
2024-12-28 05:36:22 +09:00
kwaroran
4ecf67417e Fix TTS TypeError issue when using gptsovits TTS by adding missing break statement (#695)
# 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?
- [ ] Have you added type definitions?

# Description
This pull request resolves a `TypeError` that occurred specifically when
executing TTS with the `gptsovits` model.

In Edge browsers, this manifested as:

`TTS Error: TypeError: Cannot read properties of undefined (reading
'model')`

While the TTS functionality itself was working, a missing `break`
statement in the `gptsovits` case of the `sayTTS` function caused this
error during runtime. This PR adds the necessary `break` statement to
prevent this `TypeError`.
2024-12-28 05:36:11 +09:00
kwaroran
b1e915d4cb Fixed example code error in plugin docs (#694)
# 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?

It's just a docs change.

# Description
Fixed example code in the plugin docs to match with Plugin Syntax.
2024-12-28 05:36:01 +09:00
kwaroran
663f89617a fix: add missing api definition (#693)
# 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 plugins.ts methods `addRisuScriptHandler` and
`removeRisuScriptHandler` are implemented but not defined (exported).
Thanks for your time.
2024-12-28 05:35:41 +09:00
HyperBlaze
9c1f65e518 Merge branch 'kwaroran:main' into main 2024-12-26 23:53:59 -08:00
LightningHyperBlaze45654
e51ec6c739 bugfix(read desc)
need to check if the token count is still bugged.
2024-12-26 23:53:05 -08:00
Kwaroran
ebdcd5ffcd Add new catagory 2024-12-27 16:16:36 +09:00
Kwaroran
4e2f5c24da chore: update version to 145.1.0 in configuration files 2024-12-27 16:00:20 +09:00
Kwaroran
828f612ed6 feat: add maxThoughtTagDepth property to preset configuration 2024-12-27 15:58:12 +09:00
Kwaroran
cc223dfefa feat: limit thoughts extraction based on maxThoughtTagDepth setting 2024-12-27 15:56:48 +09:00
Kwaroran
191be6d5c1 feat: add image translation feature and enhance regex list functionality 2024-12-27 15:51:29 +09:00
Do-hyun Ko
c841538c51 Fix semantic meaning error 2024-12-27 05:09:32 +09:00
Do-hyun Ko
98ddb3fc0f Fixed example code error in plugin docs 2024-12-27 04:06:03 +09:00
poroyo
823541af40 Fix sayTTS missing break in gptsovits case 2024-12-27 04:00:19 +09:00
bangonicdd
58755abd8d fix: add missing api definition 2024-12-26 22:19:00 +09:00
Kwaroran
c5f5786af7 fix: update image source reference in bot presets to use preset.image 2024-12-26 07:44:18 +09:00
Kwaroran
96de87f629 chore: update version to 145.0.1 in configuration files 2024-12-26 07:40:20 +09:00
Kwaroran
7fab5aaf90 feat: add image property to bot presets during save operation 2024-12-26 07:40:01 +09:00
Kwaroran
103b6fddb2 style: enhance loading state UI with improved layout and text visibility 2024-12-26 06:03:25 +09:00
Kwaroran
259181bbe2 Merge branch 'main' of https://github.com/kwaroran/RisuAI 2024-12-26 06:00:24 +09:00
Kwaroran
fe47f58c61 Add LoadingStatusState and improve tokenizer functionality 2024-12-26 06:00:07 +09:00
kwaroran
b874ed42ed HypaV2 context deletion safety (#680)
# PR Checklist
- [x] Did you check if it works normally in all models? *ignore this
when it dosen't uses models*
- [] Did you check if it works normally in all of web, local and node
hosted versions? if it dosen't, did you blocked it in those versions? <<
Checked on browser only, works fine
- [x] Did you added a type def?

# Description
HypaV2 data's large type definition update.
```ts
    mainChunks: { // summary itself
        id: number;
        text: string;
        chatMemos: Set<string>; // UUIDs of summarized chats
        lastChatMemo: string;
    }[];
    chunks: { // split mainChunks for retrieval or something. Although quite uncomfortable logic, so maybe I will delete it soon.
        mainChunkID: number;
        text:string;
    }[];
```
With this, ensure that mainChunks is relevant on chat context change by
deletion

If there is no UUID in the chat context, but it exists on chatMemos on
certain mainChunk, removes it.

Changed index.svelte.ts to update args on each call to ensure hypav2 to
stay adaptive on this change without refreshing the page

Also changed mainChunks to be pushed instead of unshifted
2024-12-26 05:02:33 +09:00
kwaroran
46065ebe13 fix: add missing definitions of plugin APIs (#690)
# PR Checklist
- [ ] Did you check if it works normally in all models? *ignore this
when it doesn't use models*
  - It doesn't use models.
- [ ] Did you check if it works normally in all of web, local and node
hosted versions? if it dosen't, did you blocked it in those versions?
  - Only checked on the browser
- [ ] Did you add a type def?
  - It does nothing with types
# Description
In plugins.ts methods `addRisuReplacer` and `removeRisuReplacer` are
implemented but not defined (exported).
I thought that the definitions were simply missing. So I added only two
lines.
2024-12-26 04:56:08 +09:00
kwaroran
14cd6aa9b8 ✏️ Fix typos and tones of the pr template (#691)
# PR Checklist
- [ ] Did you check if it works normally in all models? *ignore this
when it dosen't uses models*
- [ ] Did you check if it works normally in all of web, local and node
hosted versions? if it dosen't, did you blocked it in those versions?
- [ ] Did you added a type def?

- It's just a change in the document (native language).

# Description
Fixed typo & changed the tone of the PR template, with the help of
Copilot.
2024-12-26 04:55:50 +09:00
Kwaroran
575eb0505e Bump version to 145.0.0 in configuration and related files 2024-12-26 04:55:12 +09:00
Kwaroran
2672195d92 Add preset related features 2024-12-26 04:29:14 +09:00
Kwaroran
c6cc258a50 Refactor preset handling and improve database snapshot logic 2024-12-26 03:18:00 +09:00
Do-hyun Ko
e7f509b51e ✏️ Fix typos and tones of the pr template 2024-12-25 22:27:48 +09:00
Do-hyun Ko
47cf303d1f fix: add missing definitions of plugin APIs 2024-12-25 22:17:48 +09:00