This commit is contained in:
kwaroran
2023-05-13 19:05:05 +09:00
committed by GitHub
5 changed files with 20 additions and 4 deletions

View File

@@ -8,7 +8,7 @@
}, },
"package": { "package": {
"productName": "RisuAI", "productName": "RisuAI",
"version": "0.8.1" "version": "0.8.2"
}, },
"tauri": { "tauri": {
"allowlist": { "allowlist": {

View File

@@ -7,7 +7,7 @@ import { cloneDeep } from 'lodash';
export const DataBase = writable({} as any as Database) export const DataBase = writable({} as any as Database)
export const loadedStore = writable(false) export const loadedStore = writable(false)
export let appVer = '0.8.1' export let appVer = '0.8.2'
export function setDatabase(data:Database){ export function setDatabase(data:Database){

View File

@@ -28,6 +28,7 @@ export function exampleMessage(char:character):OpenAIChat[]{
role: "system", role: "system",
content: '[Start a new chat]' content: '[Start a new chat]'
}) })
currentMessage = null
} }
else if(lowered.startsWith('{{char}}:') || lowered.startsWith('<bot>:') || lowered.startsWith(`${char.name}:`)){ else if(lowered.startsWith('{{char}}:') || lowered.startsWith('<bot>:') || lowered.startsWith(`${char.name}:`)){
add() add()

View File

@@ -1,12 +1,15 @@
import { Body,fetch,ResponseType } from "@tauri-apps/api/http" import { Body,fetch,ResponseType } from "@tauri-apps/api/http"
import { isTauri } from "../globalApi" import { isTauri } from "../globalApi"
import { translatorPlugin } from "../process/plugins" import { translatorPlugin } from "../process/plugins"
import { sleep } from "../util"
let cache={ let cache={
origin: [''], origin: [''],
trans: [''] trans: ['']
} }
let waitTrans = 0
export async function translate(text:string, reverse:boolean) { export async function translate(text:string, reverse:boolean) {
if(!isTauri){ if(!isTauri){
return text return text
@@ -32,6 +35,15 @@ export async function translate(text:string, reverse:boolean) {
} }
async function googleTrans(text:string, reverse:boolean) { async function googleTrans(text:string, reverse:boolean) {
const time = Date.now()
if(time < waitTrans){
const waitTime = waitTrans - time
waitTrans += 5000
await sleep(waitTime)
}
else{
waitTrans = time + 5000
}
const arg = { const arg = {
from: reverse ? 'ko' : 'en', from: reverse ? 'ko' : 'en',
to: reverse ? 'en' : 'ko', to: reverse ? 'en' : 'ko',
@@ -54,5 +66,8 @@ async function googleTrans(text:string, reverse:boolean) {
if(typeof(f.data) === 'string'){ if(typeof(f.data) === 'string'){
return res as unknown as string return res as unknown as string
} }
return res.sentences.filter((s) => 'trans' in s).map((s) => s.trans).join(''); const result = res.sentences.filter((s) => 'trans' in s).map((s) => s.trans).join('');
cache.origin.push(reverse ? result : text)
cache.trans.push(reverse ? text : result)
return result
} }

View File

@@ -1 +1 @@
{"version":"0.8.1"} {"version":"0.8.2"}