UnisKB/ui/src/components/ai-chat/component/prologue-content/index.vue

38 lines
1.2 KiB
Vue
Raw Normal View History

2024-11-13 02:37:16 +00:00
<template>
<!-- 开场白组件 -->
<div class="item-content mb-16">
<div class="avatar">
2024-11-13 03:37:36 +00:00
<img v-if="application.avatar" :src="application.avatar" height="32px" width="32px" />
<LogoIcon v-else height="32px" width="32px" />
2024-11-13 02:37:16 +00:00
</div>
<div class="content">
<el-card shadow="always" class="dialog-card">
<MdRenderer :source="prologue" :send-message="sendMessage"></MdRenderer>
</el-card>
</div>
</div>
</template>
<script setup lang="ts">
import { type chatType } from '@/api/type/application'
import { computed } from 'vue'
import MdRenderer from '@/components/markdown/MdRenderer.vue'
const props = defineProps<{
application: any
available: boolean
type: 'log' | 'ai-chat' | 'debug-ai-chat'
sendMessage: (question: string, other_params_data?: any, chat?: chatType) => void
}>()
const toQuickQuestion = (match: string, offset: number, input: string) => {
return `<quick_question>${match.replace('- ', '')}</quick_question>`
}
const prologue = computed(() => {
const temp = props.available
? props.application?.prologue
: '抱歉,当前正在维护,无法提供服务,请稍后再试!'
return temp?.replace(/-\s.+/g, toQuickQuestion)
2024-11-13 02:37:16 +00:00
})
</script>
2024-12-04 08:20:41 +00:00
<style lang="scss" scoped>
</style>