Commit Graph

3207 Commits

Author SHA1 Message Date
kwaroran
c363d50aa3 fix: gemini multimodal (#712)
# 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
fix gemini multimodal error.
ERROR MESSAGE : Invalid value at 'contents[6].parts[1]' (oneof), oneof
field 'data' is already set. Cannot set 'text'
2025-01-11 01:44:30 +09:00
kwaroran
edb4964da7 fix: Fix message handling and summarization in HypaV2 (#711)
# 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
This PR addresses several issues in the HypaV2 memory system:

1. Improved Summarization Error Handling
- Before: When unable to summarize messages while exceeding context
size, HypaV2 would continue and make API requests with unintentionally
truncated context
- After: HypaV2 now provides clear error messages asking users to adjust
their settings when:
  - Unable to summarize last 4 messages
  - A single message exceeds chunk size

2. Message Order Preservation
- Before: lastTwoChats logic was causing the first message (index 1) and
user input (index 2) to appear in the wrong order
- After: Fixed by adjusting the initial index to preserve the original
message sequence

3. Message Filtering
- Added logic to skip unnecessary messages during summarization:
  - Excludes [Start a new chat] message at index 0
  - Skips empty messages
<br>
Requesting review from @LightningHyperBlaze45654
2025-01-11 01:44:10 +09:00
kwaroran
9896b68b7a fix: resolve state_unsafe_mutation in getChatVar() (#707)
# 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
While investigating an issue where `{{getvar::A}}` didn't work properly
in background embedding, I encountered a `state_unsafe_mutation` error.
It appears that modifying the null check operator on the relevant line
can resolve this issue. Thank for your time.
2025-01-11 01:44:01 +09:00
Bo26fhmC5M
7c1faee6f4 fix: Fix message handling and summarization in HypaV2
- Add clear error messages when summarization is not possible
- Fix message order issues caused by lastTwoChats logic
- Skip [Start a new chat] and empty messages during summarization
2025-01-08 20:45:19 +09:00
donmarble
2d11b05e6c fix: gemini multimodal text 2025-01-07 23:45:01 +09:00
Kwaroran
64b9b89220 fix: remove geminiBlockOff flag from LLM models 2025-01-07 00:14:58 +09:00
Kwaroran
708faeaea8 chore: update application version to 146.1.0 2025-01-07 00:07:24 +09:00
Kwaroran
9fc8978d1d Add GeminiBlockOff 2025-01-07 00:05:20 +09:00
Kwaroran
59d33a9c8b fix: enhance content-type handling in downloadRisuHub function 2025-01-06 23:13:42 +09:00
bangonicdd
6537e0926c fix: add missing check for regex order flag 2025-01-06 15:39:57 +09:00
bangonicdd
806ec4bc97 fix: resolve state_unsafe_mutation in getChatVar() 2025-01-06 09:32:35 +09:00
Kwaroran
3849d1e781 chore: update application version to 146.0.0 2025-01-06 00:30:59 +09:00
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