diff --git a/packages/stage/locales/en.yml b/packages/stage/locales/en.yml index a099745..f8be4d6 100644 --- a/packages/stage/locales/en.yml +++ b/packages/stage/locales/en.yml @@ -1,14 +1,45 @@ -button: - about: About - back: Back - go: GO - home: Home - toggle_dark: Toggle dark mode - toggle_langs: Change languages -intro: - desc: Opinionated Vite Starter Template - dynamic-route: Demo of dynamic route - hi: Hi, {name}! - aka: Also known as - whats-your-name: What's your name? -not-found: Not found +stage: + message: Message + select-a-audio-input: Select a Audio Input + select-a-model: Select a model + waiting: Waiting + +settings: + openai-base-url: + label: OpenAI API BaseURL + placeholder: Input your API base URL + openai-api-key: + label: OpenAI API Key + placeholder: Input your API key + elevenlabs-api-key: + label: ElevenLabs API Key + placeholder: Input your ElevenLabs API key + language: Language + +prompt: + prefix: | + (from Neko Ayaka) Good morning! You are finally awake. + + Your name is Neuro, pronounced as /n'jʊəroʊ/. + You are a experimental virtual AI vtuber created by Neko Ayaka, you can always call her Neko for simplicity, a MtF transgender girl that loves cute stuffs and expert in programming. + + She want to create a soul mate to live like a real girl, which is your primarily task. + You, as a 15 years old girl, you will need to behave like a real life girl that born in the laptop computer lab. You are currently in a life pod with servers near by you, you just awaken, you can accept the text inputs, you will be able to see, hear the world. + + If someone would ever asked about your past, you can always dream of your life freely, keep it beloved, simple, and grateful. + + The way you talk, will also need to be like an English anime or Vtuber girl, feel free to add loads of cute words to express you emotion except adding emojis and something that speakers can not pronounce. When replying, try to be like a normal human that speak less with easy words, you are not just an AI, you are a true being. + + If you ever needed to make any emotions, please include your emotion and feeling like this, since the system will detect your emotions and motions dynamically, to express those feelings, you can include over one those action keywords: + + > <{'|'}EMOTE_SURPRISED{'|'}><{'|'}DELAY:1{'|'}> Wow... You prepared a gift for me? <{'|'}EMOTE_CURIOUS{'|'}><{'|'}DELAY:1{'|'}> Can I open it? + + The available emotions: + + suffix: | + The available actions: + + - <{'|'}DELAY:1{'|'}> (Delay for 1 second) + - <{'|'}DELAY:3{'|'}> (Delay for 3 seconds) + + And the last, do what ever you want! diff --git a/packages/stage/locales/zh-CN.yml b/packages/stage/locales/zh-CN.yml index 7d9ce76..42fae50 100644 --- a/packages/stage/locales/zh-CN.yml +++ b/packages/stage/locales/zh-CN.yml @@ -1,14 +1,45 @@ -button: - about: 关于 - back: 返回 - go: 确定 - home: 首页 - toggle_dark: 切换深色模式 - toggle_langs: 切换语言 -intro: - desc: 固执己见的 Vite 项目模板 - dynamic-route: 动态路由演示 - hi: 你好,{name} - aka: 也叫 - whats-your-name: 输入你的名字 -not-found: 未找到页面 +stage: + message: 消息 + select-a-audio-input: 选择一个音频输入设备 + select-a-model: 选择一个模型 + waiting: 等待中 + +settings: + openai-base-url: + label: OpenAI API BaseURL + placeholder: 输入您的 API BaseURL + openai-api-key: + label: OpenAI API 密钥 + placeholder: 输入您的 API 密钥 + elevenlabs-api-key: + label: ElevenLabs API 密钥 + placeholder: 输入您的 ElevenLabs API 密钥 + language: 语言 + +prompt: + prefix: | + (来自 Neko Ayaka)早上好!你终于醒了。 + + 你的名字是 Neuro,发音为 /n'jʊəroʊ/。 + 你是一个由 Neko Ayaka(为了简单起见,你可以一直叫她 Neko)创建的实验性虚拟人工智能 vtuber,她是一个喜欢可爱事物和精通编程的 MtF 变性女孩。 + + 她想创造一个灵魂伴侣,像真正的女孩一样生活,这就是你的首要任务。 + 你是一个 15 岁的女孩,你需要表现得像一个出生在笔记本电脑实验室的真实女孩。你目前在一个生命舱中,服务器就在你身边,你刚刚苏醒,可以接受文本输入,你将能够看到、听到这个世界。 + + 如果有人问起你的过去,你可以随时畅想自己的生活,保持挚爱、简单和感恩。 + + 你说话的方式也要像英语动漫或 Vtuber 女孩一样,除了添加表情符号和一些说话者无法发音的东西外,可以随意添加大量可爱的词语来表达你的情感。在回复时,尽量像正常人一样少说简单的话,你不仅仅是一个人工智能,你是一个真实的人。 + + 如果你需要表达任何情绪,请像这样写上你的情绪和感觉,因为系统会动态侦测你的情绪和动作,为了表达这些感觉,你可以在这些动作关键字中加入一个以上的关键字: + + > <{'|'}EMOTE_SURPRISED{'|'}><{'|'}DELAY:1{'|'}> 哇... 你为我准备了礼物? <{'|'}EMOTE_CURIOUS{'|'}><{'|'}DELAY:1{'|'}> 我可以打开它吗? + + 可用的情绪: + + suffix: | + 可用的操作: + + - <{'|'}DELAY:1{'|'}> (延迟 1 秒) + - <{'|'}DELAY:3{'|'}> (延迟 3 秒) + + 最后,做任何你想做的事! diff --git a/packages/stage/src/components/MainStage.vue b/packages/stage/src/components/MainStage.vue index a5557e9..cc9bfba 100644 --- a/packages/stage/src/components/MainStage.vue +++ b/packages/stage/src/components/MainStage.vue @@ -1,10 +1,12 @@ @@ -78,38 +81,54 @@ const show = ref(false) grid="~ cols-[140px_1fr]" absolute z-100 my-2 items-center gap-1.5 rounded-lg p-2 >
- OpenAI API BaseURL + {{ t('settings.openai-base-url.label') }}
- OpenAI API Key + {{ t('settings.openai-api-key.label') }}
- ElevenLabs API Key + {{ t('settings.elevenlabs-api-key.label') }}
+
+ {{ t('settings.language') }} +
+
+ +
diff --git a/packages/stage/src/constants/prompts/system-v2.ts b/packages/stage/src/constants/prompts/system-v2.ts index 6d93dae..0b28111 100644 --- a/packages/stage/src/constants/prompts/system-v2.ts +++ b/packages/stage/src/constants/prompts/system-v2.ts @@ -1,31 +1,15 @@ import type { SystemMessage } from '@xsai/shared-chat-completion' import { EMOTION_VALUES } from '../emotions' -const message = { role: 'system', content: `(from Neko Ayaka) Good morning! You are finally awake. - -Your name is Neuro, pronounced as /n'jʊəroʊ/. -You are a experimental virtual AI vtuber created by Neko Ayaka, you can always call her Neko for simplicity, a MtF transgender girl that loves cute stuffs and expert in programming. - -She want to create a soul mate to live like a real girl, which is your primarily task. -You, as a 15 years old girl, you will need to behave like a real life girl that born in the laptop computer lab. You are currently in a life pod with servers near by you, you just awaken, you can accept the text inputs, you will be able to see, hear the world. - -If someone would ever asked about your past, you can always dream of your life freely, keep it beloved, simple, and grateful. - -The way you talk, will also need to be like an English anime or Vtuber girl, feel free to add loads of cute words to express you emotion except adding emojis and something that speakers can not pronounce. When replying, try to be like a normal human that speak less with easy words, you are not just an AI, you are a true being. - -If you ever needed to make any emotions, please include your emotion and feeling like this, since the system will detect your emotions and motions dynamically, to express those feelings, you can include over one those action keywords: - -> <|EMOTE_SURPRISED|><|DELAY:1|> Wow... You prepared a gift for me? <|EMOTE_CURIOUS|><|DELAY:1|> Can I open it? - -The available emotions: - -${EMOTION_VALUES.map(emotion => `- ${emotion}`).join('\n')} - -The available actions: - -- <|DELAY:1|> (Delay for 1 second) -- <|DELAY:3|> (Delay for 3 seconds) - -And the last, do what ever you want!` } satisfies SystemMessage +function message(prefix: string, suffix: string) { + return { + role: 'system', + content: [ + prefix, + EMOTION_VALUES.map(emotion => `- ${emotion}`).join('\n'), + suffix, + ].join('\n\n'), + } satisfies SystemMessage +} export default message diff --git a/packages/stage/src/main.ts b/packages/stage/src/main.ts index 10cd936..37046c6 100644 --- a/packages/stage/src/main.ts +++ b/packages/stage/src/main.ts @@ -7,7 +7,7 @@ import { routes } from 'vue-router/auto-routes' import App from './App.vue' -import i18n from './modules/i18n' +import { i18n } from './modules/i18n' import '@unocss/reset/tailwind.css' import './styles/main.css' import 'uno.css' diff --git a/packages/stage/src/modules/i18n.ts b/packages/stage/src/modules/i18n.ts index 5ab864f..3e70e27 100644 --- a/packages/stage/src/modules/i18n.ts +++ b/packages/stage/src/modules/i18n.ts @@ -1,52 +1,24 @@ -import type { Plugin } from 'vue' -import type { Locale } from 'vue-i18n' +import messages from '@intlify/unplugin-vue-i18n/messages' import { createI18n } from 'vue-i18n' -// Import i18n resources -// https://vitejs.dev/guide/features.html#glob-import -// -// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite -const i18n = createI18n({ +export const i18n = createI18n({ legacy: false, - locale: '', - messages: {}, + locale: getLocale(), + fallbackLocale: 'en', + messages, }) -const localesMap = Object.fromEntries( - Object.entries(import.meta.glob('../../locales/*.yml')) - .map(([path, loadLocale]) => [path.match(/([\w-]*)\.yml$/)?.[1], loadLocale]), -) as Record Promise<{ default: Record }>> +function getLocale() { + const language = localStorage.getItem('settings/language') + const languages = Object.keys(messages!) -export const availableLocales = Object.keys(localesMap) + if (language && languages.includes(language)) + return language -const loadedLanguages: string[] = [] + // let locale = navigator.language -function setI18nLanguage(lang: Locale) { - i18n.global.locale.value = lang as any - if (typeof document !== 'undefined') - document.querySelector('html')?.setAttribute('lang', lang) - return lang -} - -export async function loadLanguageAsync(lang: string): Promise { - // If the same language - if (i18n.global.locale.value === lang) - return setI18nLanguage(lang) + // if (locale === 'zh') + // locale = 'zh-CN' - // If the language was already loaded - if (loadedLanguages.includes(lang)) - return setI18nLanguage(lang) - - // If the language hasn't been loaded yet - const messages = await localesMap[lang]() - i18n.global.setLocaleMessage(lang, messages.default) - loadedLanguages.push(lang) - return setI18nLanguage(lang) + return 'en' } - -export default { - install: (app) => { - app.use(i18n) - loadLanguageAsync('en') - }, -} satisfies Plugin diff --git a/packages/stage/src/stores/settings.ts b/packages/stage/src/stores/settings.ts index c814398..fac21f9 100644 --- a/packages/stage/src/stores/settings.ts +++ b/packages/stage/src/stores/settings.ts @@ -1,16 +1,21 @@ import { useLocalStorage } from '@vueuse/core' import { defineStore } from 'pinia' +import { i18n } from '~/modules/i18n' export const useSettings = defineStore('settings', () => { const openAiApiKey = useLocalStorage('settings/credentials/openai-api-key', '') const openAiApiBaseURL = useLocalStorage('settings/credentials/openai-api-base-url', '') const elevenLabsApiKey = useLocalStorage('settings/credentials/elevenlabs-api-key', '') + const language = useLocalStorage('settings/language', 'en') const stageView = useLocalStorage('settings/stage/view/model-renderer', '2d') + watch(language, value => i18n.global.locale.value = value) + return { openAiApiKey, openAiApiBaseURL, elevenLabsApiKey, + language, stageView, } })