From a862ffe0e38660b57d5328defd6a13fa5214400e Mon Sep 17 00:00:00 2001 From: kwaroran Date: Thu, 14 Nov 2024 21:42:56 +0900 Subject: [PATCH] Enhance chat setup options and improve UI responsiveness --- src/lang/en.ts | 28 ++- src/lib/ChatScreens/DefaultChatScreen.svelte | 3 +- src/lib/Others/WelcomeRisu.svelte | 206 ++++++++++++++++--- 3 files changed, 209 insertions(+), 28 deletions(-) diff --git a/src/lang/en.ts b/src/lang/en.ts index f60817ff..046b6ddc 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -182,13 +182,39 @@ export const languageEnglish = { inputName: "Lastly, Input your Nickname.", welcome: "Welcome to RisuAI! Here, I will guide you to setup. First, What may I call you?", welcome2: "Hello {username}! before we start, I will ask you some questions. You can change these settings later in settings.\n\nFirst select the AI provider.", - openAIProvider: "OpenAI GPT is a high quality AI model, but it is paid and filtered.", openrouterProvider: "Openrouter has a lot of models, some of them unfiltered and some of them free, but it is not as good as OpenAI.", hordeProvider: "Horde is a free provider, but the response time is long and the quality is low.", setProviderLater: "There are other providers, but you can set it later in settings. select this if you want to set it later.", setupOpenAI: "To use OpenAI, you need to get an API key. \n1. go to https://beta.openai.com/ \n2. login with your account \n3. go to https://beta.openai.com/account/api-keys \n4. click 'Create New API Key' and name your key whatever you want. \n5. copy the key in the website.\n6. go back to RisuAI\n7. paste it, and click send button.", setupOpenrouter: "To use Openrouter, you need to get an API key. \n1. go to https://openrouter.ai/keys\n2. click 'Create Key'\n3. set key name whatever you want.\n4. copy the key in the website\n5. go back to RisuAI\n6. paste it, and click send button.", allDone: "All Done! please wait a moment.", + setupLaterMessage: "Welcome {username}! do you want me to guide you to setup or do it yourself?", + setupMessageOption1: "Guide me to setup", + setupMessageOption1Desc: "Recommended for new users", + setupMessageOption2: "I will setup myself", + claudeDesc: "Claude is a AI model made by Antropic, competitor to OpenAI. its better than GPT if you want to use it in other languages than English.", + openAIDesc: "OpenAI GPT is a high quality AI model, but it is paid and filtered, and weak in other than English.", + chooseChatType: "Great! Now select the chat language.", + chooseChatTypeOption1: "Full English", + chooseChatTypeOption1Desc: "This will make AI to use English and input/output in English. Recommended for English speakers.", + chooseChatTypeOption2: "English Processing", + chooseChatTypeOption2Desc: "This will make AI to use English internaly, but input/output will be in your language. Recommended for non-English speakers.", + chooseChatTypeOption3: "No Language Focused", + chooseChatTypeOption3Desc: "This will make AI to use your language internaly, but this could make quality lower.", + chooseCheapOrMemory: "By the way, do you prefer memory or cheapness?", + chooseCheapOrMemoryOption1: "Memory", + chooseCheapOrMemoryOption1Desc: "This will make AI to remember more, but it will quite expensive.", + chooseCheapOrMemoryOption2: "Cheap", + chooseCheapOrMemoryOption2Desc: "This will make AI to remember less, but it will be cheaper.", + chooseCheapOrMemoryOption3: "Balanced", + chooseCheapOrMemoryOption3Desc: "This will make AI to remember more than cheap, but less than memory.", + chooseCheapOrMemoryOption4: "Unlimited", + chooseCheapOrMemoryOption4Desc: "This will make AI to remember almost everything, but it will be very expensive.", + finally: "Finally, do you want to enable advanced tools?", + finallyOption1: "Yes", + finallyOption1Desc: "This will enable advanced tools, but it will make the UI more complex. Recommended for advanced users.", + finallyOption2: "No", + finallyOption2Desc: "This will disable advanced tools, and make the UI more simple. Recommended for new users.", }, confirm: "Confirm", goback: "Go Back", diff --git a/src/lib/ChatScreens/DefaultChatScreen.svelte b/src/lib/ChatScreens/DefaultChatScreen.svelte index 036bd8af..96aa1dbe 100644 --- a/src/lib/ChatScreens/DefaultChatScreen.svelte +++ b/src/lib/ChatScreens/DefaultChatScreen.svelte @@ -464,7 +464,7 @@ }} oninput={()=>{updateInputSizeAll();updateInputTransateMessage(false)}} style:height={inputHeight} -> + > {:else} + {language.postFile} diff --git a/src/lib/Others/WelcomeRisu.svelte b/src/lib/Others/WelcomeRisu.svelte index f55a9c02..815f28c6 100644 --- a/src/lib/Others/WelcomeRisu.svelte +++ b/src/lib/Others/WelcomeRisu.svelte @@ -10,8 +10,10 @@ let step = $state(0) let provider = $state('') let input = $state('') + let chatLang = $state(0) + let chatMemorySelection = $state(0) - if(step === 0){ + { const browserLang = navigator.language const browserLangShort = browserLang.split('-')[0] const usableLangs = ['de', 'en', 'ko', 'cn', 'vi', 'zh-Hant'] @@ -41,18 +43,18 @@ } break } - case 3:{ + case 4:{ if(provider === 'openai'){ if(input.length > 0 && input.startsWith('sk-')){ DBState.db.openAIKey = input - step = 10 + step = 5 input = '' } } if(provider === 'openrouter'){ if(input.length > 0 && input.startsWith('sk-')){ DBState.db.openrouterKey = input - step = 10 + step = 5 input = '' } } @@ -66,20 +68,83 @@ DBState.db = setPreset(DBState.db, prebuiltPresets.OAI2) DBState.db.textTheme = 'highcontrast' updateTextThemeAndCSS() + + switch(chatMemorySelection){ + case 0:{ + DBState.db.maxContext = 16000 + DBState.db.maxResponse = 1000 + break + } + case 1:{ + DBState.db.maxContext = 8000 + DBState.db.maxResponse = 500 + break + } + case 2:{ + DBState.db.maxContext = 12000 + DBState.db.maxResponse = 800 + break + } + case 3:{ + DBState.db.maxContext = 100000 + DBState.db.maxResponse = 1000 + break + } + } + + if(provider === 'claude'){ + DBState.db.aiModel = 'claude-3-5-sonnet-20241022' + DBState.db.subModel = 'claude-3-5-sonnet-20241022' + } + + if(provider === 'openai'){ + DBState.db.aiModel = 'gpt4o-chatgpt' + DBState.db.subModel = 'gpt4o-chatgpt' + } + if(provider === 'openrouter'){ DBState.db.aiModel = 'openrouter' DBState.db.subModel = 'openrouter' DBState.db.openrouterRequestModel = 'risu/free' - DBState.db.maxContext = 6000 } if(provider === 'horde'){ DBState.db.aiModel = 'horde:::auto' DBState.db.subModel = 'horde:::auto' } - - if(provider === 'openai'){ - DBState.db.maxContext = 4000 + if(chatLang !== 0){ + switch(DBState.db.language){ + case 'de':{ + DBState.db.translator = 'de' + break + } + case 'en':{ + DBState.db.translator = 'en' + break + } + case 'ko':{ + DBState.db.translator = 'ko' + break + } + case 'cn':{ + DBState.db.translator = 'zh' + break + } + case 'vi':{ + DBState.db.translator = 'vi' + break + } + case 'zh-Hant':{ + DBState.db.translator = 'zh-TW' + break + } + } } + if(chatLang === 1){ + DBState.db.autoTranslate = true + DBState.db.translatorType = 'google' + DBState.db.useAutoTranslateInput = true + } + DBState.db.didFirstSetup = true }, 1000); } @@ -136,16 +201,43 @@ {#if step >= 2} - + {/if} {#if step === 2} +
+ + +
+ {/if} + {#if step >= 3} + + + {/if} + {#if step === 3}
+ -
{/if} - {#if step >= 3} + {#if step >= 4} {#if provider === 'openai'} @@ -179,11 +264,78 @@ {/if} {/if} + {#if step >= 5} + + + {/if} + {#if step === 5} +
+ + + +
+ {/if} + {#if step >= 6} + + + {/if} + {#if step === 6} +
+ + + + +
+ {/if} {#if step === 10} {/if} -
- + +
+ {/if}