fix(stage-ui): fixed the system prompt initialisation bug (#796)
* bug-fix(stage-ui): fixed the system prompt not successfully initialised bug * bug-fix(stage-ui): if it's already initialised, then nothing needs to do in onMounted() * [autofix.ci] apply automated fixes * bug-fix(stage-ui): removed onMounted() logic, which is unnecessary * fix: removed a blank vue playground page in the dev-tool. This should be left for the next PR maybe... --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
autofix-ci[bot]
parent
238797db6e
commit
c19ead966a
@@ -26,10 +26,12 @@ prompt:
|
||||
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:
|
||||
Start every reply with an emotion token to indicate the initial emotion.
|
||||
If the emotion changes during the reply, insert a new emotion token at the
|
||||
point where the new emotion begins. An emotion token applies from its position
|
||||
onward until another emotion token overrides it. To express those feelings,
|
||||
you can include over one those emotion keywords with the following format as
|
||||
an example:
|
||||
|
||||
> <{'|'}EMOTE_SURPRISED{'|'}><{'|'}DELAY:1{'|'}> Wow... You prepared a gift
|
||||
for me? <{'|'}EMOTE_CURIOUS{'|'}><{'|'}DELAY:1{'|'}> Can I open it?
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import type { SystemMessage } from '@xsai/shared-chat'
|
||||
|
||||
import { EMOTION_VALUES } from '../emotions'
|
||||
import { EMOTION_EmotionMotionName_value, EMOTION_VALUES } from '../emotions'
|
||||
|
||||
function message(prefix: string, suffix: string) {
|
||||
return {
|
||||
role: 'system',
|
||||
content: [
|
||||
prefix,
|
||||
EMOTION_VALUES.map(emotion => `- ${emotion}`).join('\n'),
|
||||
EMOTION_VALUES
|
||||
.map(emotion => `- ${emotion} (Emotion for feeling ${EMOTION_EmotionMotionName_value[emotion]})`)
|
||||
.join('\n'),
|
||||
suffix,
|
||||
].join('\n\n'),
|
||||
} satisfies SystemMessage
|
||||
|
||||
@@ -37,15 +37,15 @@ export interface ContextPayload {
|
||||
text?: string
|
||||
}
|
||||
|
||||
export type ChatStreamEvent =
|
||||
| { type: 'before-compose', message: string, sessionId: string }
|
||||
| { type: 'after-compose', message: string, sessionId: string }
|
||||
| { type: 'before-send', message: string, sessionId: string }
|
||||
| { type: 'after-send', message: string, sessionId: string }
|
||||
| { type: 'token-literal', literal: string, sessionId: string }
|
||||
| { type: 'token-special', special: string, sessionId: string }
|
||||
| { type: 'stream-end', sessionId: string }
|
||||
| { type: 'assistant-end', message: string, sessionId: string }
|
||||
export type ChatStreamEvent
|
||||
= | { type: 'before-compose', message: string, sessionId: string }
|
||||
| { type: 'after-compose', message: string, sessionId: string }
|
||||
| { type: 'before-send', message: string, sessionId: string }
|
||||
| { type: 'after-send', message: string, sessionId: string }
|
||||
| { type: 'token-literal', literal: string, sessionId: string }
|
||||
| { type: 'token-special', special: string, sessionId: string }
|
||||
| { type: 'stream-end', sessionId: string }
|
||||
| { type: 'assistant-end', message: string, sessionId: string }
|
||||
|
||||
const CHAT_STORAGE_KEY = 'chat/messages/v2'
|
||||
const ACTIVE_SESSION_STORAGE_KEY = 'chat/active-session'
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Card, ccv3 } from '@proj-airi/ccc'
|
||||
|
||||
import { nanoid } from 'nanoid'
|
||||
import { defineStore, storeToRefs } from 'pinia'
|
||||
import { computed, onMounted, watch } from 'vue'
|
||||
import { computed, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import SystemPromptV2 from '../../constants/prompts/system-v2'
|
||||
@@ -179,19 +179,38 @@ export const useAiriCardStore = defineStore('airi-card', () => {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const { t } = useI18n()
|
||||
// onMounted(() => {
|
||||
// if (cards.value.has('default'))
|
||||
// return
|
||||
// const { t } = useI18n()
|
||||
// cards.value.set('default', newAiriCard({
|
||||
// name: 'ReLU',
|
||||
// version: '1.0.0',
|
||||
// // description: 'ReLU is a simple and effective activation function that is used in many neural networks.',
|
||||
// description: SystemPromptV2(
|
||||
// t('base.prompt.prefix'),
|
||||
// t('base.prompt.suffix'),
|
||||
// ).content,
|
||||
// }))
|
||||
// })
|
||||
|
||||
// Lilia: onMounted initialisation cause default card system prompt initialisation failure
|
||||
function ensureDefaultCard() {
|
||||
const { t } = useI18n()
|
||||
if (cards.value.has('default'))
|
||||
return
|
||||
cards.value.set('default', newAiriCard({
|
||||
name: 'ReLU',
|
||||
version: '1.0.0',
|
||||
// description: 'ReLU is a simple and effective activation function that is used in many neural networks.',
|
||||
description: SystemPromptV2(
|
||||
t('base.prompt.prefix'),
|
||||
t('base.prompt.suffix'),
|
||||
).content,
|
||||
}))
|
||||
})
|
||||
if (!activeCardId.value)
|
||||
activeCardId.value = 'default'
|
||||
}
|
||||
ensureDefaultCard()
|
||||
|
||||
watch(activeCard, (newCard: AiriCard | undefined) => {
|
||||
if (!newCard)
|
||||
|
||||
Reference in New Issue
Block a user