Dev (#48)
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "RisuAI",
|
"productName": "RisuAI",
|
||||||
"version": "0.8.1"
|
"version": "0.8.2"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
|||||||
@@ -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){
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":"0.8.1"}
|
{"version":"0.8.2"}
|
||||||
Reference in New Issue
Block a user