[feat] added create oc bot with ai
This commit is contained in:
@@ -351,4 +351,6 @@ export const languageEnglish = {
|
||||
screenshot: "Screenshot",
|
||||
screenshotSaved: "Screenshot Saved",
|
||||
inputBotGenerationPrompt: "Input Bot Generation Prompt",
|
||||
createBotAI: "Create OC Bot from AI",
|
||||
createBotwithAI: "Create Bot from AI",
|
||||
}
|
||||
@@ -591,7 +591,7 @@
|
||||
on:click={BotCreator.createBotFromWeb}
|
||||
className="mt-2"
|
||||
>
|
||||
{language.createBotInternet}
|
||||
{language.createBotwithAI}
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,9 @@ import { get } from "svelte/store";
|
||||
import { sleep } from "../util";
|
||||
|
||||
|
||||
async function createBotFromWebMain(prompt:string):Promise<{ ok: false; data:string }|{ok:"creation";data:character}>{
|
||||
type creationResult = { ok: false; data:string }|{ok:"creation";data:character}
|
||||
|
||||
async function createBotFromWebMain(prompt:string):Promise<creationResult>{
|
||||
|
||||
|
||||
|
||||
@@ -230,11 +232,42 @@ async function createBotFromWebMain(prompt:string):Promise<{ ok: false; data:str
|
||||
|
||||
}
|
||||
|
||||
async function createBotByAI() {
|
||||
let search = await alertInput(language.inputBotGenerationPrompt)
|
||||
async function createBotByAI(search:string):Promise<creationResult> {
|
||||
if(search.length < 3){
|
||||
return
|
||||
}
|
||||
const ch = await requestChatData({
|
||||
formated: [{
|
||||
role: 'user',
|
||||
content: search
|
||||
},{
|
||||
role: 'system',
|
||||
content: "\n\n*Name*:\n*Age*:\n*gender*: \n*race*:\n*Hair style, color*:\n*color, shape of eye*:\n*Personality*:\n*Dress*:\n*Height (cm)*:\n*weight(kg)*:\n*Job*:\n*Specialty*:\n*Features*: \n*Likes*:\n*Dislikes*:\n*Character's background*: \n*Other informations*: \n\n[[This is a format. you must create a character based on this format according to the user's prompt. Fill up every section. the result must be long and detailed. now, only output the generated result. output the generated result.]]"
|
||||
},],
|
||||
maxTokens: 800,
|
||||
temperature: 0.5,
|
||||
bias: {}
|
||||
}, 'submodel')
|
||||
|
||||
if(ch.type === 'multiline' || ch.type === 'fail' || ch.type === 'streaming'){
|
||||
return {
|
||||
ok: false,
|
||||
data: "Request Fail: " + ch.result
|
||||
}
|
||||
}
|
||||
|
||||
const res = ch.result.trim().split("\n")
|
||||
let charname = res[0].split(":").at(-1).trim()
|
||||
|
||||
const char = createBlankChar()
|
||||
|
||||
char.name = charname.replaceAll("_"," ")
|
||||
char.desc = ch.result
|
||||
char.creatorNotes = `Generated by RisuAI from prompt: ` + search
|
||||
return {
|
||||
ok: "creation",
|
||||
data: char
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,11 +289,15 @@ async function createFirstMsg(charDesc:string) {
|
||||
}
|
||||
|
||||
async function createBotFromWeb() {
|
||||
if((!isTauri) && (!isNodeServer)){
|
||||
alertNormal(language.noweb)
|
||||
return
|
||||
const sel = parseInt(await alertSelect([language.createBotInternet, language.createBotAI]))
|
||||
if(sel === 0){
|
||||
if((!isTauri) && (!isNodeServer)){
|
||||
alertNormal(language.noweb)
|
||||
return
|
||||
}
|
||||
}
|
||||
let search = (await alertInput(language.createBotInternetAlert)).split("#")[0]
|
||||
|
||||
let search = (await alertInput((sel === 0) ? language.createBotInternetAlert : language.inputBotGenerationPrompt))
|
||||
if(search.length < 3){
|
||||
return
|
||||
}
|
||||
@@ -268,7 +305,7 @@ async function createBotFromWeb() {
|
||||
type: 'wait',
|
||||
msg: 'Fetching..'
|
||||
})
|
||||
const d = await createBotFromWebMain(search)
|
||||
const d = (sel === 0) ? (await createBotFromWebMain(search)) : (await createBotByAI(search))
|
||||
if(d.ok === 'creation'){
|
||||
const db = get(DataBase)
|
||||
const cha = d.data
|
||||
|
||||
Reference in New Issue
Block a user