[feat] added risuidentify
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="w-full h-full flex justify-center welcome-bg text-neutral-200">
|
<div class="w-full h-full flex justify-center welcome-bg text-neutral-200">
|
||||||
<article class="w-full overflow-y-hidden overflow-x-hidden max-w-full min-h-full h-full flex flex-col overflow-y-auto">
|
<article class="w-full overflow-x-hidden max-w-full min-h-full h-full flex flex-col overflow-y-auto">
|
||||||
<div class="w-full justify-center flex mt-8">
|
<div class="w-full justify-center flex mt-8">
|
||||||
<img src="/logo_typo_trans.png" alt="logo" class="w-full max-w-screen-sm mb-0">
|
<img src="/logo_typo_trans.png" alt="logo" class="w-full max-w-screen-sm mb-0">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,17 +4,14 @@ const reg:[RegExp,string][] = []
|
|||||||
export function autoMarkPlugin(data:string){
|
export function autoMarkPlugin(data:string){
|
||||||
if(reg.length === 0){
|
if(reg.length === 0){
|
||||||
const pluginRegex = [
|
const pluginRegex = [
|
||||||
{"comment":"──── ▼ Head 스크립트 ▼ ───────────────────────────────────────────────","in":"","out":"","type":"editinput","ableFlag":false,"flag":"g"},
|
|
||||||
{"comment":"[ 💱 ]ㅤ구조변환 #1ㅤ=ㅤ대사 부호 수정","in":"“|”","out":"\"","type":"editdisplay","ableFlag":false},
|
{"comment":"[ 💱 ]ㅤ구조변환 #1ㅤ=ㅤ대사 부호 수정","in":"“|”","out":"\"","type":"editdisplay","ableFlag":false},
|
||||||
{"comment":"[ 💱 ]ㅤ구조변환 #2ㅤ=ㅤ생각 부호 수정","in":"‘|’","out":"'","type":"editdisplay","ableFlag":false},
|
{"comment":"[ 💱 ]ㅤ구조변환 #2ㅤ=ㅤ생각 부호 수정","in":"‘|’","out":"'","type":"editdisplay","ableFlag":false},
|
||||||
{"comment":"──── ▼ Auto 스크립트 ▼ ───────────────────────────────────────────────","in":"","out":"","type":"editinput","ableFlag":false,"flag":"g"},
|
|
||||||
{"comment":"[ 🧷 ]ㅤ이탈릭체 #1ㅤ=ㅤ문장 앞 묶음 추가","in":"^(?!\\d\\.)([\\wㄱ-ㅎ가-힣'])(?!.*[{<>}])|(?<=^\\[.*\\] *|^\\(.*\\) *)([\\wㄱ-ㅎ가-힣'])(?!.*[{<>}])","out":"<em>$1$2","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
{"comment":"[ 🧷 ]ㅤ이탈릭체 #1ㅤ=ㅤ문장 앞 묶음 추가","in":"^(?!\\d\\.)([\\wㄱ-ㅎ가-힣'])(?!.*[{<>}])|(?<=^\\[.*\\] *|^\\(.*\\) *)([\\wㄱ-ㅎ가-힣'])(?!.*[{<>}])","out":"<em>$1$2","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
||||||
{"comment":"[ 🧷 ]ㅤ이탈릭체 #2ㅤ=ㅤ문장 뒤 묶음 추가","in":"(?<!^ +.*)(\".*|<em>.*)(?<!\")$","out":"$1</em>","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
{"comment":"[ 🧷 ]ㅤ이탈릭체 #2ㅤ=ㅤ문장 뒤 묶음 추가","in":"(?<!^ +.*)(\".*|<em>.*)(?<!\")$","out":"$1</em>","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
||||||
{"comment":"[ 🧷 ]ㅤ대사묶음 #1ㅤ=ㅤ대사 앞 묶음 추가","in":"(?<=<em>.*|^\".*)( +\"[\\S])|(?<=<em>.*|\" +.*)( *\\[)","out":"</em>$1$2","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
{"comment":"[ 🧷 ]ㅤ대사묶음 #1ㅤ=ㅤ대사 앞 묶음 추가","in":"(?<=<em>.*|^\".*)( +\"[\\S])|(?<=<em>.*|\" +.*)( *\\[)","out":"</em>$1$2","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
||||||
{"comment":"[ 🧷 ]ㅤ대사묶음 #2ㅤ=ㅤ대사 뒤 묶음 추가","in":"(?<=^\".*|<\\/em>.*)([\\S]\" +|[\\S]\"(?=[,.…ㄱ-ㅎ가-힣]))|(?<=<\\/em>.*)( *\\] *)","out":"$1$2<em>","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
{"comment":"[ 🧷 ]ㅤ대사묶음 #2ㅤ=ㅤ대사 뒤 묶음 추가","in":"(?<=^\".*|<\\/em>.*)([\\S]\" +|[\\S]\"(?=[,.…ㄱ-ㅎ가-힣]))|(?<=<\\/em>.*)( *\\] *)","out":"$1$2<em>","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
||||||
{"comment":"[ 🧷 ]ㅤ생각묶음 #1ㅤ=ㅤ생각 앞 묶음 추가","in":"(?<=<em>.*? +|\\[|\\[.* +|\\(|\\(.* +|\"|\".*? +)(?<!style=.*)(')|(?<=<em>)('[\\wㄱ-ㅎ가-힣])","out":"<strong><em>$1$2","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
{"comment":"[ 🧷 ]ㅤ생각묶음 #1ㅤ=ㅤ생각 앞 묶음 추가","in":"(?<=<em>.*? +|\\[|\\[.* +|\\(|\\(.* +|\"|\".*? +)(?<!style=.*)(')|(?<=<em>)('[\\wㄱ-ㅎ가-힣])","out":"<strong><em>$1$2","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
||||||
{"comment":"[ 🧷 ]ㅤ생각묶음 #2ㅤ=ㅤ생각 뒤 묶음 추가","in":"(?<=<strong><em>')(.*?')(?= +.+?|[ㄱ-ㅎ가-힣?!:;,.…—-])|(?<=<strong><em>'.*)(')(?=<\\/em>|\")|(?<=\\(<strong><em>')(?=\\))","out":"$1$2</em></strong>","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
{"comment":"[ 🧷 ]ㅤ생각묶음 #2ㅤ=ㅤ생각 뒤 묶음 추가","in":"(?<=<strong><em>')(.*?')(?= +.+?|[ㄱ-ㅎ가-힣?!:;,.…—-])|(?<=<strong><em>'.*)(')(?=<\\/em>|\")|(?<=\\(<strong><em>')(?=\\))","out":"$1$2</em></strong>","type":"editdisplay","ableFlag":true,"flag":"gm"},
|
||||||
{"comment":"──── ▼ Key 스크립트 ▼ ────────────────────────────────────────────────","in":"","out":"","type":"editinput","ableFlag":false},
|
|
||||||
{"comment":"[ 📝 ]ㅤ추가핫키 #1ㅤ=ㅤ따옴표 추가 : (`)","in":"(?<!`)`(?!`)","out":"\"","type":"editinput","ableFlag":false},
|
{"comment":"[ 📝 ]ㅤ추가핫키 #1ㅤ=ㅤ따옴표 추가 : (`)","in":"(?<!`)`(?!`)","out":"\"","type":"editinput","ableFlag":false},
|
||||||
{"comment":"[ 📝 ]ㅤ추가핫키 #2ㅤ=ㅤOOC 추가 : (``)","in":"^``(?!`) *(.*)$","out":"(OOC: $1)","type":"editinput","ableFlag":true,"flag":"gm"}
|
{"comment":"[ 📝 ]ㅤ추가핫키 #2ㅤ=ㅤOOC 추가 : (``)","in":"^``(?!`) *(.*)$","out":"(OOC: $1)","type":"editinput","ableFlag":true,"flag":"gm"}
|
||||||
]
|
]
|
||||||
@@ -25,5 +22,8 @@ export function autoMarkPlugin(data:string){
|
|||||||
for(let i=0;i<reg.length;i++){
|
for(let i=0;i<reg.length;i++){
|
||||||
data = data.replace(reg[i][0], reg[i][1])
|
data = data.replace(reg[i][0], reg[i][1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
@@ -167,6 +167,12 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
let replacerURL = aiModel === 'openrouter' ? "https://openrouter.ai/api/v1/chat/completions" :
|
let replacerURL = aiModel === 'openrouter' ? "https://openrouter.ai/api/v1/chat/completions" :
|
||||||
(aiModel === 'reverse_proxy') ? (db.forceReplaceUrl) : ('https://api.openai.com/v1/chat/completions')
|
(aiModel === 'reverse_proxy') ? (db.forceReplaceUrl) : ('https://api.openai.com/v1/chat/completions')
|
||||||
|
|
||||||
|
let risuIdentify = false
|
||||||
|
if(replacerURL.startsWith("risu::")){
|
||||||
|
risuIdentify = true
|
||||||
|
replacerURL.replace("risu::", '')
|
||||||
|
}
|
||||||
|
|
||||||
if(aiModel === 'reverse_proxy'){
|
if(aiModel === 'reverse_proxy'){
|
||||||
if(replacerURL.endsWith('v1')){
|
if(replacerURL.endsWith('v1')){
|
||||||
replacerURL += '/chat/completions'
|
replacerURL += '/chat/completions'
|
||||||
@@ -193,9 +199,13 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
headers["X-Title"] = 'RisuAI'
|
headers["X-Title"] = 'RisuAI'
|
||||||
headers["HTTP-Referer"] = 'https://risuai.xyz'
|
headers["HTTP-Referer"] = 'https://risuai.xyz'
|
||||||
}
|
}
|
||||||
|
if(risuIdentify){
|
||||||
|
headers["X-Proxy-Risu"] = 'RisuAI'
|
||||||
|
}
|
||||||
|
let throughProxi = (!isTauri) && (!isNodeServer) && (!db.usePlainFetch)
|
||||||
if(db.useStreaming && arg.useStreaming){
|
if(db.useStreaming && arg.useStreaming){
|
||||||
body.stream = true
|
body.stream = true
|
||||||
const da = ((!isTauri) && (!isNodeServer) && (!db.usePlainFetch))
|
const da = (throughProxi)
|
||||||
? await fetch(hubURL + `/proxy2`, {
|
? await fetch(hubURL + `/proxy2`, {
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
headers: {
|
headers: {
|
||||||
@@ -270,7 +280,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
body: body,
|
body: body,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
abortSignal,
|
abortSignal,
|
||||||
useRisuToken:true
|
useRisuToken:throughProxi
|
||||||
})
|
})
|
||||||
|
|
||||||
const dat = res.data as any
|
const dat = res.data as any
|
||||||
|
|||||||
Reference in New Issue
Block a user